summaryrefslogtreecommitdiff
path: root/dom/indexedDB
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-11-08 10:49:03 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-11-08 10:49:03 +0100
commitae78b7da609238ea4ae0efbea79c6670133ad90b (patch)
tree90b3528a725b148a1e05f3a5a520ca3d336ca0d9 /dom/indexedDB
parent6308e5657b1197750b1e46ea59d27e158d23a356 (diff)
downloaduxp-ae78b7da609238ea4ae0efbea79c6670133ad90b.tar.gz
Issue mcp-graveyard/UXP#1263 - Part 1: Remove DiskSpaceWatcher
Diffstat (limited to 'dom/indexedDB')
-rw-r--r--dom/indexedDB/ActorsParent.cpp56
-rw-r--r--dom/indexedDB/IndexedDatabaseManager.cpp75
-rw-r--r--dom/indexedDB/IndexedDatabaseManager.h17
3 files changed, 2 insertions, 146 deletions
diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp
index cd998c31c2..74afef4523 100644
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -4427,18 +4427,6 @@ CreateStorageConnection(nsIFile* aDBFile,
nsresult rv;
bool exists;
- if (IndexedDatabaseManager::InLowDiskSpaceMode()) {
- rv = aDBFile->Exists(&exists);
- if (NS_WARN_IF(NS_FAILED(rv))) {
- return rv;
- }
-
- if (!exists) {
- NS_WARNING("Refusing to create database because disk space is low!");
- return NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR;
- }
- }
-
nsCOMPtr<nsIFileURL> dbFileUrl;
rv = GetDatabaseFileURL(aDBFile,
aPersistenceType,
@@ -19103,23 +19091,6 @@ DatabaseMaintenance::DetermineMaintenanceAction(
return NS_OK;
}
- bool lowDiskSpace = IndexedDatabaseManager::InLowDiskSpaceMode();
-
- if (QuotaManager::IsRunningXPCShellTests()) {
- // If we're running XPCShell then we want to test both the low disk space
- // and normal disk space code paths so pick semi-randomly based on the
- // current time.
- lowDiskSpace = ((PR_Now() / PR_USEC_PER_MSEC) % 2) == 0;
- }
-
- // If we're low on disk space then the best we can hope for is that an
- // incremental vacuum might free some space. That is a journaled operation so
- // it may not be possible even then.
- if (lowDiskSpace) {
- *aMaintenanceAction = MaintenanceAction::IncrementalVacuum;
- return NS_OK;
- }
-
// This method shouldn't make any permanent changes to the database, so make
// sure everything gets rolled back when we leave.
mozStorageTransaction transaction(aConnection,
@@ -24233,11 +24204,6 @@ CreateFileOp::DoDatabaseWork()
"CreateFileOp::DoDatabaseWork",
js::ProfileEntry::Category::STORAGE);
- if (NS_WARN_IF(IndexedDatabaseManager::InLowDiskSpaceMode())) {
- NS_WARNING("Refusing to create file because disk space is low!");
- return NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR;
- }
-
if (NS_WARN_IF(QuotaManager::IsShuttingDown()) || !OperationMayProceed()) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
@@ -24378,10 +24344,6 @@ CreateObjectStoreOp::DoDatabaseWork(DatabaseConnection* aConnection)
"CreateObjectStoreOp::DoDatabaseWork",
js::ProfileEntry::Category::STORAGE);
- if (NS_WARN_IF(IndexedDatabaseManager::InLowDiskSpaceMode())) {
- return NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR;
- }
-
#ifdef DEBUG
{
// Make sure that we're not creating an object store with the same name as
@@ -24705,10 +24667,6 @@ RenameObjectStoreOp::DoDatabaseWork(DatabaseConnection* aConnection)
"RenameObjectStoreOp::DoDatabaseWork",
js::ProfileEntry::Category::STORAGE);
- if (NS_WARN_IF(IndexedDatabaseManager::InLowDiskSpaceMode())) {
- return NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR;
- }
-
#ifdef DEBUG
{
// Make sure that we're not renaming an object store with the same name as
@@ -24798,7 +24756,6 @@ CreateIndexOp::InsertDataFromObjectStore(DatabaseConnection* aConnection)
{
MOZ_ASSERT(aConnection);
aConnection->AssertIsOnConnectionThread();
- MOZ_ASSERT(!IndexedDatabaseManager::InLowDiskSpaceMode());
MOZ_ASSERT(mMaybeUniqueIndexTable);
PROFILER_LABEL("IndexedDB",
@@ -24849,7 +24806,6 @@ CreateIndexOp::InsertDataFromObjectStoreInternal(
{
MOZ_ASSERT(aConnection);
aConnection->AssertIsOnConnectionThread();
- MOZ_ASSERT(!IndexedDatabaseManager::InLowDiskSpaceMode());
MOZ_ASSERT(mMaybeUniqueIndexTable);
DebugOnly<void*> storageConnection = aConnection->GetStorageConnection();
@@ -24926,10 +24882,6 @@ CreateIndexOp::DoDatabaseWork(DatabaseConnection* aConnection)
"CreateIndexOp::DoDatabaseWork",
js::ProfileEntry::Category::STORAGE);
- if (NS_WARN_IF(IndexedDatabaseManager::InLowDiskSpaceMode())) {
- return NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR;
- }
-
#ifdef DEBUG
{
// Make sure that we're not creating an index with the same name and object
@@ -25806,10 +25758,6 @@ RenameIndexOp::DoDatabaseWork(DatabaseConnection* aConnection)
"RenameIndexOp::DoDatabaseWork",
js::ProfileEntry::Category::STORAGE);
- if (NS_WARN_IF(IndexedDatabaseManager::InLowDiskSpaceMode())) {
- return NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR;
- }
-
#ifdef DEBUG
{
// Make sure that we're not renaming an index with the same name as another
@@ -26294,10 +26242,6 @@ ObjectStoreAddOrPutRequestOp::DoDatabaseWork(DatabaseConnection* aConnection)
"ObjectStoreAddOrPutRequestOp::DoDatabaseWork",
js::ProfileEntry::Category::STORAGE);
- if (NS_WARN_IF(IndexedDatabaseManager::InLowDiskSpaceMode())) {
- return NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR;
- }
-
DatabaseConnection::AutoSavepoint autoSave;
nsresult rv = autoSave.Start(Transaction());
if (NS_WARN_IF(NS_FAILED(rv))) {
diff --git a/dom/indexedDB/IndexedDatabaseManager.cpp b/dom/indexedDB/IndexedDatabaseManager.cpp
index 62ba51c086..213de5cc98 100644
--- a/dom/indexedDB/IndexedDatabaseManager.cpp
+++ b/dom/indexedDB/IndexedDatabaseManager.cpp
@@ -8,11 +8,9 @@
#include "chrome/common/ipc_channel.h" // for IPC::Channel::kMaximumMessageSize
#include "nsIConsoleService.h"
-#include "nsIDiskSpaceWatcher.h"
#include "nsIDOMWindow.h"
#include "nsIEventTarget.h"
#include "nsIFile.h"
-#include "nsIObserverService.h"
#include "nsIScriptError.h"
#include "nsIScriptGlobalObject.h"
@@ -64,11 +62,6 @@
#define IDB_STR "indexedDB"
-// The two possible values for the data argument when receiving the disk space
-// observer notification.
-#define LOW_DISK_SPACE_DATA_FULL "full"
-#define LOW_DISK_SPACE_DATA_FREE "free"
-
namespace mozilla {
namespace dom {
namespace indexedDB {
@@ -313,8 +306,6 @@ Atomic<IndexedDatabaseManager::LoggingMode>
IndexedDatabaseManager::sLoggingMode(
IndexedDatabaseManager::Logging_Disabled);
-mozilla::Atomic<bool> IndexedDatabaseManager::sLowDiskSpaceMode(false);
-
// static
IndexedDatabaseManager*
IndexedDatabaseManager::GetOrCreate()
@@ -329,24 +320,6 @@ IndexedDatabaseManager::GetOrCreate()
if (!gDBManager) {
sIsMainProcess = XRE_IsParentProcess();
- if (sIsMainProcess && Preferences::GetBool("disk_space_watcher.enabled", false)) {
- // See if we're starting up in low disk space conditions.
- nsCOMPtr<nsIDiskSpaceWatcher> watcher =
- do_GetService(DISKSPACEWATCHER_CONTRACTID);
- if (watcher) {
- bool isDiskFull;
- if (NS_SUCCEEDED(watcher->GetIsDiskFull(&isDiskFull))) {
- sLowDiskSpaceMode = isDiskFull;
- }
- else {
- NS_WARNING("GetIsDiskFull failed!");
- }
- }
- else {
- NS_WARNING("No disk space watcher component available!");
- }
- }
-
RefPtr<IndexedDatabaseManager> instance(new IndexedDatabaseManager());
nsresult rv = instance->Init();
@@ -380,13 +353,6 @@ IndexedDatabaseManager::Init()
// During Init() we can't yet call IsMainProcess(), just check sIsMainProcess
// directly.
if (sIsMainProcess) {
- nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
- NS_ENSURE_STATE(obs);
-
- nsresult rv =
- obs->AddObserver(this, DISKSPACEWATCHER_OBSERVER_TOPIC, false);
- NS_ENSURE_SUCCESS(rv, rv);
-
mDeleteTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
NS_ENSURE_STATE(mDeleteTimer);
@@ -680,16 +646,6 @@ IndexedDatabaseManager::IsMainProcess()
return sIsMainProcess;
}
-//static
-bool
-IndexedDatabaseManager::InLowDiskSpaceMode()
-{
- NS_ASSERTION(gDBManager,
- "InLowDiskSpaceMode() called before indexedDB has been "
- "initialized!");
- return sLowDiskSpaceMode;
-}
-
// static
IndexedDatabaseManager::LoggingMode
IndexedDatabaseManager::GetLoggingMode()
@@ -1087,36 +1043,7 @@ IndexedDatabaseManager::GetLocale()
NS_IMPL_ADDREF(IndexedDatabaseManager)
NS_IMPL_RELEASE_WITH_DESTROY(IndexedDatabaseManager, Destroy())
-NS_IMPL_QUERY_INTERFACE(IndexedDatabaseManager, nsIObserver, nsITimerCallback)
-
-NS_IMETHODIMP
-IndexedDatabaseManager::Observe(nsISupports* aSubject, const char* aTopic,
- const char16_t* aData)
-{
- NS_ASSERTION(IsMainProcess(), "Wrong process!");
- NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-
- if (!strcmp(aTopic, DISKSPACEWATCHER_OBSERVER_TOPIC)) {
- NS_ASSERTION(aData, "No data?!");
-
- const nsDependentString data(aData);
-
- if (data.EqualsLiteral(LOW_DISK_SPACE_DATA_FULL)) {
- sLowDiskSpaceMode = true;
- }
- else if (data.EqualsLiteral(LOW_DISK_SPACE_DATA_FREE)) {
- sLowDiskSpaceMode = false;
- }
- else {
- NS_NOTREACHED("Unknown data value!");
- }
-
- return NS_OK;
- }
-
- NS_NOTREACHED("Unknown topic!");
- return NS_ERROR_UNEXPECTED;
-}
+NS_IMPL_QUERY_INTERFACE(IndexedDatabaseManager, nsITimerCallback)
NS_IMETHODIMP
IndexedDatabaseManager::Notify(nsITimer* aTimer)
diff --git a/dom/indexedDB/IndexedDatabaseManager.h b/dom/indexedDB/IndexedDatabaseManager.h
index d63c548ec6..fb43764261 100644
--- a/dom/indexedDB/IndexedDatabaseManager.h
+++ b/dom/indexedDB/IndexedDatabaseManager.h
@@ -7,8 +7,6 @@
#ifndef mozilla_dom_indexeddatabasemanager_h__
#define mozilla_dom_indexeddatabasemanager_h__
-#include "nsIObserver.h"
-
#include "js/TypeDecls.h"
#include "mozilla/Atomics.h"
#include "mozilla/dom/quota/PersistenceType.h"
@@ -43,8 +41,7 @@ class FileManagerInfo;
} // namespace indexedDB
class IndexedDatabaseManager final
- : public nsIObserver
- , public nsITimerCallback
+ : public nsITimerCallback
{
typedef mozilla::dom::quota::PersistenceType PersistenceType;
typedef mozilla::dom::quota::QuotaManager QuotaManager;
@@ -62,7 +59,6 @@ public:
};
NS_DECL_ISUPPORTS
- NS_DECL_NSIOBSERVER
NS_DECL_NSITIMERCALLBACK
// Returns a non-owning reference.
@@ -87,16 +83,6 @@ public:
#endif
static bool
- InLowDiskSpaceMode()
-#ifdef DEBUG
- ;
-#else
- {
- return !!sLowDiskSpaceMode;
- }
-#endif
-
- static bool
InTestingMode();
static bool
@@ -244,7 +230,6 @@ private:
static bool sFullSynchronousMode;
static LazyLogModule sLoggingModule;
static Atomic<LoggingMode> sLoggingMode;
- static mozilla::Atomic<bool> sLowDiskSpaceMode;
};
} // namespace dom