Commit 65d7ba6c authored by Chris Mumford's avatar Chris Mumford Committed by Commit Bot

Using leveldb_chrome::PossiblyValidDB in GCMStoreImpl.

Replaced DatabaseExists with new leveldb_chrome::PossiblyValidDB.

Bug: None
Change-Id: Iecb181588355c3f59953230ad0946f8e531c8a3f
Reviewed-on: https://chromium-review.googlesource.com/1090998Reviewed-by: default avatarDmitry Titov <dimich@chromium.org>
Commit-Queue: Chris Mumford <cmumford@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567480}
parent 128fd383
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "google_apis/gcm/base/mcs_util.h" #include "google_apis/gcm/base/mcs_util.h"
#include "google_apis/gcm/protocol/mcs.pb.h" #include "google_apis/gcm/protocol/mcs.pb.h"
#include "third_party/leveldatabase/env_chromium.h" #include "third_party/leveldatabase/env_chromium.h"
#include "third_party/leveldatabase/leveldb_chrome.h"
#include "third_party/leveldatabase/src/include/leveldb/db.h" #include "third_party/leveldatabase/src/include/leveldb/db.h"
#include "third_party/leveldatabase/src/include/leveldb/write_batch.h" #include "third_party/leveldatabase/src/include/leveldb/write_batch.h"
...@@ -176,13 +177,6 @@ leveldb::Slice MakeSlice(const base::StringPiece& s) { ...@@ -176,13 +177,6 @@ leveldb::Slice MakeSlice(const base::StringPiece& s) {
return leveldb::Slice(s.begin(), s.size()); return leveldb::Slice(s.begin(), s.size());
} }
bool DatabaseExists(const base::FilePath& path) {
// It's not enough to check that the directory exists, since DestroyDB
// sometimes leaves behind an empty directory
// (https://github.com/google/leveldb/issues/215).
return base::PathExists(path.Append(FILE_PATH_LITERAL("CURRENT")));
}
} // namespace } // namespace
class GCMStoreImpl::Backend class GCMStoreImpl::Backend
...@@ -292,7 +286,8 @@ LoadStatus GCMStoreImpl::Backend::OpenStoreAndLoadData(StoreOpenMode open_mode, ...@@ -292,7 +286,8 @@ LoadStatus GCMStoreImpl::Backend::OpenStoreAndLoadData(StoreOpenMode open_mode,
// Checks if the store exists or not. Opening a db with create_if_missing // Checks if the store exists or not. Opening a db with create_if_missing
// not set will still create a new directory if the store does not exist. // not set will still create a new directory if the store does not exist.
if (open_mode == DO_NOT_CREATE && !DatabaseExists(path_)) { if (open_mode == DO_NOT_CREATE &&
!leveldb_chrome::PossiblyValidDB(path_, leveldb::Env::Default())) {
DVLOG(2) << "Database " << path_.value() << " does not exist"; DVLOG(2) << "Database " << path_.value() << " does not exist";
return STORE_DOES_NOT_EXIST; return STORE_DOES_NOT_EXIST;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment