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

Unified Diff: webkit/database/database_tracker.h

Issue 7234014: Move code to clear web databases on shutdown to the database tracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 9 years, 6 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
Index: webkit/database/database_tracker.h
diff --git a/webkit/database/database_tracker.h b/webkit/database/database_tracker.h
index bbc308adfc33be0487f6c32931e201272da9816c..92af0d9fc9102d3c98f6ddab49365ec4e657dfbf 100644
--- a/webkit/database/database_tracker.h
+++ b/webkit/database/database_tracker.h
@@ -88,7 +88,9 @@ class DatabaseTracker
virtual ~Observer() {}
};
- DatabaseTracker(const FilePath& profile_path, bool is_incognito,
+ DatabaseTracker(const FilePath& profile_path,
+ bool is_incognito,
+ bool clear_local_state_on_exit,
quota::SpecialStoragePolicy* special_storage_policy,
quota::QuotaManagerProxy* quota_manager_proxy,
base::MessageLoopProxy* db_tracker_thread);
@@ -123,6 +125,12 @@ class DatabaseTracker
return quota_manager_proxy_.get();
}
+ // Safe to call on any thread.
+ quota::SpecialStoragePolicy* special_storage_policy() const {
+ return special_storage_policy_.get();
+ }
+
+
bool IsDatabaseScheduledForDeletion(const string16& origin_identifier,
const string16& database_name);
@@ -149,6 +157,11 @@ class DatabaseTracker
virtual int DeleteDataForOrigin(const string16& origin_identifier,
net::CompletionCallback* callback);
+ // Delete all files belonging to the given origin given that no database
+ // connections within this origin are open, or if |force| is true, delete
+ // the meta data and rename the associated directory.
+ bool DeleteOrigin(const string16& origin_identifier, bool force);
+
bool IsIncognitoProfile() const { return is_incognito_; }
void GetIncognitoFileHandle(const string16& vfs_file_path,
@@ -161,7 +174,11 @@ class DatabaseTracker
// Deletes the directory that stores all DBs in incognito mode, if it exists.
void DeleteIncognitoDBDirectory();
- static void ClearLocalState(const FilePath& profile_path);
+ // Deletes databases not protected by the special storage policy if
+ // |clear_local_state_on_exit_| is true and blocks databases from being
+ // created/opened.
+ void Shutdown();
+ void SetClearLocalStateOnExit(bool clear_local_state_on_exit);
private:
friend class base::RefCountedThreadSafe<DatabaseTracker>;
@@ -195,7 +212,6 @@ class DatabaseTracker
bool DeleteClosedDatabase(const string16& origin_identifier,
const string16& database_name);
- bool DeleteOrigin(const string16& origin_identifier);
void DeleteDatabaseIfNeeded(const string16& origin_identifier,
const string16& database_name);
@@ -228,6 +244,7 @@ class DatabaseTracker
bool is_initialized_;
const bool is_incognito_;
+ bool clear_local_state_on_exit_;
bool shutting_down_;
const FilePath profile_path_;
const FilePath db_dir_;
@@ -247,6 +264,9 @@ class DatabaseTracker
scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
+ // The database tracker thread we're supposed to run file IO on.
+ scoped_refptr<base::MessageLoopProxy> db_tracker_thread_;
+
// When in incognito mode, store a DELETE_ON_CLOSE handle to each
// main DB and journal file that was accessed. When the incognito profile
// goes away (or when the browser crashes), all these handles will be

Powered by Google App Engine
This is Rietveld 408576698