summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browsing_data_remover.cc
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-06 03:08:04 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-06 03:08:04 +0000
commit72cfd90fdb683cf513e2f50db4ec0488729ed0a3 (patch)
tree35cc742f0d79cd9070e003c0be0eed61304af248 /chrome/browser/browsing_data_remover.cc
parent0ecf8bd18d15550e2dc744a38d1665ffc2b958bd (diff)
downloadchromium_src-72cfd90fdb683cf513e2f50db4ec0488729ed0a3.zip
chromium_src-72cfd90fdb683cf513e2f50db4ec0488729ed0a3.tar.gz
chromium_src-72cfd90fdb683cf513e2f50db4ec0488729ed0a3.tar.bz2
Delete HTML5 database in BrowsingDataRemover, part 1.
This part deletes databases except for when they're currently used by a renderer. BUG=34633 TEST=open the webkit html5 database demo, create some notes. close the tab. clear browsing data. open the demo again. notes should be gone. Review URL: http://codereview.chromium.org/570032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38296 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browsing_data_remover.cc')
-rw-r--r--chrome/browser/browsing_data_remover.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc
index 37b4cd4..312297f 100644
--- a/chrome/browser/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data_remover.cc
@@ -19,9 +19,11 @@
#include "chrome/common/notification_service.h"
#include "chrome/common/url_constants.h"
#include "net/base/cookie_monster.h"
+#include "net/base/net_errors.h"
#include "net/disk_cache/disk_cache.h"
#include "net/http/http_cache.h"
#include "net/url_request/url_request_context.h"
+#include "webkit/database/database_tracker.h"
#include "webkit/glue/password_form.h"
// Done so that we can use PostTask on BrowsingDataRemovers and not have
@@ -40,6 +42,9 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
: profile_(profile),
delete_begin_(delete_begin),
delete_end_(delete_end),
+ ALLOW_THIS_IN_INITIALIZER_LIST(database_cleared_callback_(
+ this, &BrowsingDataRemover::OnClearedDatabases)),
+ waiting_for_clear_databases_(false),
waiting_for_clear_history_(false),
waiting_for_clear_cache_(false) {
DCHECK(profile);
@@ -51,6 +56,9 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
: profile_(profile),
delete_begin_(CalculateBeginDeleteTime(time_period)),
delete_end_(delete_end),
+ ALLOW_THIS_IN_INITIALIZER_LIST(database_cleared_callback_(
+ this, &BrowsingDataRemover::OnClearedDatabases)),
+ waiting_for_clear_databases_(false),
waiting_for_clear_history_(false),
waiting_for_clear_cache_(false) {
DCHECK(profile);
@@ -115,6 +123,17 @@ void BrowsingDataRemover::Remove(int remove_mask) {
cookie_monster->DeleteAllCreatedBetween(delete_begin_, delete_end_, true);
profile_->GetWebKitContext()->DeleteDataModifiedSince(
delete_begin_, chrome::kExtensionScheme);
+
+ database_tracker_ = profile_->GetDatabaseTracker();
+ if (database_tracker_.get()) {
+ waiting_for_clear_databases_ = true;
+ ChromeThread::PostTask(
+ ChromeThread::FILE, FROM_HERE,
+ NewRunnableMethod(
+ this,
+ &BrowsingDataRemover::ClearDatabasesOnFILEThread,
+ delete_begin_));
+ }
}
if (remove_mask & REMOVE_PASSWORDS) {
@@ -276,3 +295,28 @@ void BrowsingDataRemover::ClearCacheOnIOThread(
ChromeThread::UI, FROM_HERE,
NewRunnableMethod(this, &BrowsingDataRemover::ClearedCache));
}
+
+void BrowsingDataRemover::OnClearedDatabases(int rv) {
+ if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) {
+ bool result = ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &BrowsingDataRemover::OnClearedDatabases, rv));
+ DCHECK(result);
+ return;
+ }
+ // Notify the UI thread that we are done.
+ database_tracker_ = NULL;
+ waiting_for_clear_databases_ = false;
+
+ NotifyAndDeleteIfDone();
+}
+
+void BrowsingDataRemover::ClearDatabasesOnFILEThread(base::Time delete_begin) {
+ // This function should be called on the FILE thread.
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
+
+ int rv = database_tracker_->DeleteDataModifiedSince(
+ delete_begin, &database_cleared_callback_);
+ if (rv != net::ERR_IO_PENDING)
+ OnClearedDatabases(rv);
+}