diff options
author | dgrogan@chromium.org <dgrogan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-08 02:52:32 +0000 |
---|---|---|
committer | dgrogan@chromium.org <dgrogan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-08 02:52:32 +0000 |
commit | 0afaf1a928dea560da5731a2811569724e11de6f (patch) | |
tree | 6e07bb93cf1820a23b0352ef8f5270aab2dd337d /content/browser/indexed_db | |
parent | 0c2d584ab97619534f19b8c3fb1c48123dbcfde6 (diff) | |
download | chromium_src-0afaf1a928dea560da5731a2811569724e11de6f.zip chromium_src-0afaf1a928dea560da5731a2811569724e11de6f.tar.gz chromium_src-0afaf1a928dea560da5731a2811569724e11de6f.tar.bz2 |
Don't reset the database when there was an I/O error.
Unlike corruption errors, I/O errors have the potential to be ephemeral.
We shouldn't aggressively delete the database in those cases. Instead,
punt that decision up to the web app.
Also, can remove the full disk catch-all. That was intended to catch
full disks masquerading as other I/O errors.
BUG=239882
Review URL: https://codereview.chromium.org/26045002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227444 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/indexed_db')
-rw-r--r-- | content/browser/indexed_db/indexed_db_backing_store.cc | 44 | ||||
-rw-r--r-- | content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc | 6 |
2 files changed, 6 insertions, 44 deletions
diff --git a/content/browser/indexed_db/indexed_db_backing_store.cc b/content/browser/indexed_db/indexed_db_backing_store.cc index b6da42ae..5733b6e 100644 --- a/content/browser/indexed_db/indexed_db_backing_store.cc +++ b/content/browser/indexed_db/indexed_db_backing_store.cc @@ -396,48 +396,12 @@ enum IndexedDBBackingStoreOpenResult { INDEXED_DB_BACKING_STORE_OPEN_FAILED_UNKNOWN_ERR, INDEXED_DB_BACKING_STORE_OPEN_MEMORY_FAILED, INDEXED_DB_BACKING_STORE_OPEN_ATTEMPT_NON_ASCII, - INDEXED_DB_BACKING_STORE_OPEN_DISK_FULL, + INDEXED_DB_BACKING_STORE_OPEN_DISK_FULL_DEPRECATED, INDEXED_DB_BACKING_STORE_OPEN_ORIGIN_TOO_LONG, INDEXED_DB_BACKING_STORE_OPEN_NO_RECOVERY, INDEXED_DB_BACKING_STORE_OPEN_MAX, }; -// TODO(dgrogan): Move to leveldb_env. -bool RecoveryCouldBeFruitful(leveldb::Status status) { - leveldb_env::MethodID method; - int error = -1; - leveldb_env::ErrorParsingResult result = leveldb_env::ParseMethodAndError( - status.ToString().c_str(), &method, &error); - switch (result) { - case leveldb_env::NONE: - return true; - case leveldb_env::METHOD_AND_PFE: { - base::PlatformFileError pfe = static_cast<base::PlatformFileError>(error); - switch (pfe) { - case base::PLATFORM_FILE_ERROR_TOO_MANY_OPENED: - case base::PLATFORM_FILE_ERROR_NO_MEMORY: - case base::PLATFORM_FILE_ERROR_NO_SPACE: - return false; - default: - return true; - } - } - case leveldb_env::METHOD_AND_ERRNO: { - switch (error) { - case EMFILE: - case ENOMEM: - case ENOSPC: - return false; - default: - return true; - } - } - default: - return true; - } - return true; -} - scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::Open( const std::string& origin_identifier, const base::FilePath& path_base, @@ -551,15 +515,11 @@ scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::Open( if (db) { HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_SUCCESS); - } else if (!RecoveryCouldBeFruitful(status)) { + } else if (leveldb_env::IsIOError(status)) { LOG(ERROR) << "Unable to open backing store, not trying to recover - " << status.ToString(); HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_NO_RECOVERY); return scoped_refptr<IndexedDBBackingStore>(); - } else if (*is_disk_full) { - LOG(ERROR) << "Unable to open backing store - disk is full."; - HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_DISK_FULL); - return scoped_refptr<IndexedDBBackingStore>(); } else { LOG(ERROR) << "IndexedDB backing store open failed, attempting cleanup"; *data_loss = WebKit::WebIDBCallbacks::DataLossTotal; diff --git a/content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc b/content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc index 6b60a4f..a848090 100644 --- a/content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc +++ b/content/browser/indexed_db/indexed_db_cleanup_on_io_error_unittest.cc @@ -79,6 +79,8 @@ TEST(IndexedDBIOErrorTest, CleanUpTest) { &mock_leveldb_factory); } +// TODO(dgrogan): Remove expect_destroy if we end up not using it again. It is +// currently set to false in all 4 calls below. template <class T> class MockErrorLevelDBFactory : public LevelDBFactory { public: @@ -138,7 +140,7 @@ TEST(IndexedDBNonRecoverableIOErrorTest, NuancedCleanupTest) { &disk_full, &mock_leveldb_factory2); - MockErrorLevelDBFactory<int> mock_leveldb_factory3(EIO, true); + MockErrorLevelDBFactory<int> mock_leveldb_factory3(EIO, false); scoped_refptr<IndexedDBBackingStore> backing_store3 = IndexedDBBackingStore::Open(origin_identifier, path, @@ -148,7 +150,7 @@ TEST(IndexedDBNonRecoverableIOErrorTest, NuancedCleanupTest) { &mock_leveldb_factory3); MockErrorLevelDBFactory<base::PlatformFileError> mock_leveldb_factory4( - base::PLATFORM_FILE_ERROR_FAILED, true); + base::PLATFORM_FILE_ERROR_FAILED, false); scoped_refptr<IndexedDBBackingStore> backing_store4 = IndexedDBBackingStore::Open(origin_identifier, path, |