Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2065)

Unified Diff: components/leveldb_proto/proto_database_impl.h

Issue 1420003004: Wipe out offline page data on clearing cookie and site data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address more feedback Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/leveldb_proto/proto_database.h ('k') | components/leveldb_proto/testing/fake_db.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/leveldb_proto/proto_database_impl.h
diff --git a/components/leveldb_proto/proto_database_impl.h b/components/leveldb_proto/proto_database_impl.h
index 71ee23b8796126165b224973365bca547d144217..163396c224aa647c93d262ca258074fe2cd05933 100644
--- a/components/leveldb_proto/proto_database_impl.h
+++ b/components/leveldb_proto/proto_database_impl.h
@@ -49,6 +49,8 @@ class ProtoDatabaseImpl : public ProtoDatabase<T> {
const typename ProtoDatabase<T>::UpdateCallback& callback) override;
void LoadEntries(
const typename ProtoDatabase<T>::LoadCallback& callback) override;
+ void Destroy(
+ const typename ProtoDatabase<T>::DestroyCallback& callback) override;
// Allow callers to provide their own Database implementation.
void InitWithDatabase(
@@ -63,6 +65,7 @@ class ProtoDatabaseImpl : public ProtoDatabase<T> {
scoped_refptr<base::SequencedTaskRunner> task_runner_;
scoped_ptr<LevelDB> db_;
+ base::FilePath database_dir_;
DISALLOW_COPY_AND_ASSIGN(ProtoDatabaseImpl);
};
@@ -89,6 +92,13 @@ void RunLoadCallback(const typename ProtoDatabase<T>::LoadCallback& callback,
callback.Run(*success, entries.Pass());
}
+template <typename T>
+void RunDestroyCallback(
+ const typename ProtoDatabase<T>::DestroyCallback& callback,
+ const bool* success) {
+ callback.Run(*success);
+}
+
void InitFromTaskRunner(LevelDB* database, const base::FilePath& database_dir,
bool* success) {
DCHECK(success);
@@ -97,6 +107,12 @@ void InitFromTaskRunner(LevelDB* database, const base::FilePath& database_dir,
*success = database->Init(database_dir);
}
+void DestroyFromTaskRunner(const base::FilePath& database_dir, bool* success) {
+ CHECK(success);
+
+ *success = LevelDB::Destroy(database_dir);
+}
+
template <typename T>
void UpdateEntriesFromTaskRunner(
LevelDB* database,
@@ -158,11 +174,25 @@ void ProtoDatabaseImpl<T>::Init(
const base::FilePath& database_dir,
const typename ProtoDatabase<T>::InitCallback& callback) {
DCHECK(thread_checker_.CalledOnValidThread());
+ database_dir_ = database_dir;
InitWithDatabase(make_scoped_ptr(new LevelDB(client_name)), database_dir,
callback);
}
template <typename T>
+void ProtoDatabaseImpl<T>::Destroy(
+ const typename ProtoDatabase<T>::DestroyCallback& callback) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(db_);
+ DCHECK(!database_dir_.empty());
+ db_.reset();
+ bool* success = new bool(false);
+ task_runner_->PostTaskAndReply(
+ FROM_HERE, base::Bind(DestroyFromTaskRunner, database_dir_, success),
+ base::Bind(RunDestroyCallback<T>, callback, base::Owned(success)));
+}
+
+template <typename T>
void ProtoDatabaseImpl<T>::InitWithDatabase(
scoped_ptr<LevelDB> database,
const base::FilePath& database_dir,
« no previous file with comments | « components/leveldb_proto/proto_database.h ('k') | components/leveldb_proto/testing/fake_db.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698