mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1182987 - Part 2: Add getQuotaObjects() to mozIStorageConnection; r=mak
This commit is contained in:
parent
f3d631abd1
commit
7bb929b877
9
dom/cache/Connection.cpp
vendored
9
dom/cache/Connection.cpp
vendored
@ -13,6 +13,8 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
namespace cache {
|
||||
|
||||
using mozilla::dom::quota::QuotaObject;
|
||||
|
||||
NS_IMPL_ISUPPORTS(cache::Connection, mozIStorageAsyncConnection,
|
||||
mozIStorageConnection);
|
||||
|
||||
@ -272,6 +274,13 @@ Connection::EnableModule(const nsACString& aModule)
|
||||
return mBase->EnableModule(aModule);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Connection::GetQuotaObjects(QuotaObject** aDatabaseQuotaObject,
|
||||
QuotaObject** aJournalQuotaObject)
|
||||
{
|
||||
return mBase->GetQuotaObjects(aDatabaseQuotaObject, aJournalQuotaObject);
|
||||
}
|
||||
|
||||
} // namespace cache
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -888,5 +888,15 @@ sqlite3_vfs* ConstructTelemetryVFS()
|
||||
return tvfs;
|
||||
}
|
||||
|
||||
already_AddRefed<QuotaObject>
|
||||
GetQuotaObjectForFile(sqlite3_file *pFile)
|
||||
{
|
||||
MOZ_ASSERT(pFile);
|
||||
|
||||
telemetry_file *p = (telemetry_file *)pFile;
|
||||
RefPtr<QuotaObject> result = p->quotaObject;
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
} // namespace storage
|
||||
} // namespace mozilla
|
||||
|
@ -6,6 +6,19 @@
|
||||
#include "nsISupports.idl"
|
||||
#include "mozIStorageAsyncConnection.idl"
|
||||
|
||||
%{C++
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace quota {
|
||||
class QuotaObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
[ptr] native QuotaObject(mozilla::dom::quota::QuotaObject);
|
||||
|
||||
interface mozIStorageAggregateFunction;
|
||||
interface mozIStorageCompletionCallback;
|
||||
interface mozIStorageFunction;
|
||||
@ -238,4 +251,17 @@ interface mozIStorageConnection : mozIStorageAsyncConnection {
|
||||
* For unknown module names.
|
||||
*/
|
||||
[noscript] void enableModule(in ACString aModuleName);
|
||||
|
||||
/**
|
||||
* Get quota objects.
|
||||
*
|
||||
* @param[out] aDatabaseQuotaObject
|
||||
* The QuotaObject associated with the database file.
|
||||
* @param[out] aJournalQuotaObject
|
||||
* The QuotaObject associated with the journal file.
|
||||
*
|
||||
* @throws NS_ERROR_NOT_INITIALIZED.
|
||||
*/
|
||||
[noscript] void getQuotaObjects(out QuotaObject aDatabaseQuotaObject,
|
||||
out QuotaObject aJournalQuotaObject);
|
||||
};
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ErrorNames.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "mozilla/dom/quota/QuotaObject.h"
|
||||
|
||||
#include "mozIStorageAggregateFunction.h"
|
||||
#include "mozIStorageCompletionCallback.h"
|
||||
@ -67,6 +68,8 @@ mozilla::LazyLogModule gStorageLog("mozStorage");
|
||||
namespace mozilla {
|
||||
namespace storage {
|
||||
|
||||
using mozilla::dom::quota::QuotaObject;
|
||||
|
||||
namespace {
|
||||
|
||||
int
|
||||
@ -1915,5 +1918,46 @@ Connection::EnableModule(const nsACString& aModuleName)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Implemented in TelemetryVFS.cpp
|
||||
already_AddRefed<QuotaObject>
|
||||
GetQuotaObjectForFile(sqlite3_file *pFile);
|
||||
|
||||
NS_IMETHODIMP
|
||||
Connection::GetQuotaObjects(QuotaObject** aDatabaseQuotaObject,
|
||||
QuotaObject** aJournalQuotaObject)
|
||||
{
|
||||
MOZ_ASSERT(aDatabaseQuotaObject);
|
||||
MOZ_ASSERT(aJournalQuotaObject);
|
||||
|
||||
if (!mDBConn) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
sqlite3_file* file;
|
||||
int srv = ::sqlite3_file_control(mDBConn,
|
||||
nullptr,
|
||||
SQLITE_FCNTL_FILE_POINTER,
|
||||
&file);
|
||||
if (srv != SQLITE_OK) {
|
||||
return convertResultCode(srv);
|
||||
}
|
||||
|
||||
RefPtr<QuotaObject> databaseQuotaObject = GetQuotaObjectForFile(file);
|
||||
|
||||
srv = ::sqlite3_file_control(mDBConn,
|
||||
nullptr,
|
||||
SQLITE_FCNTL_JOURNAL_POINTER,
|
||||
&file);
|
||||
if (srv != SQLITE_OK) {
|
||||
return convertResultCode(srv);
|
||||
}
|
||||
|
||||
RefPtr<QuotaObject> journalQuotaObject = GetQuotaObjectForFile(file);
|
||||
|
||||
databaseQuotaObject.forget(aDatabaseQuotaObject);
|
||||
journalQuotaObject.forget(aJournalQuotaObject);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace storage
|
||||
} // namespace mozilla
|
||||
|
Loading…
Reference in New Issue
Block a user