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

Unified Diff: chrome/browser/in_process_webkit/webkit_context.cc

Issue 5359005: Moved deleting the indexed db context to the WebKitContext destructor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Includes cleanup. Created 10 years, 1 month 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: chrome/browser/in_process_webkit/webkit_context.cc
diff --git a/chrome/browser/in_process_webkit/webkit_context.cc b/chrome/browser/in_process_webkit/webkit_context.cc
index 32fccf7b7c702e60c9bcca9ba77a3a35b7be86e2..6e39e3ee40b189d2086f495acd619c504da90e12 100644
--- a/chrome/browser/in_process_webkit/webkit_context.cc
+++ b/chrome/browser/in_process_webkit/webkit_context.cc
@@ -7,15 +7,25 @@
#include "base/command_line.h"
#include "chrome/browser/browser_thread.h"
#include "chrome/browser/profile.h"
+#include "chrome/browser/prefs/pref_service.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/notification_details.h"
+#include "chrome/common/notification_type.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/url_constants.h"
WebKitContext::WebKitContext(Profile* profile)
: data_path_(profile->IsOffTheRecord() ? FilePath() : profile->GetPath()),
is_incognito_(profile->IsOffTheRecord()),
+ profile_(profile),
ALLOW_THIS_IN_INITIALIZER_LIST(
dom_storage_context_(new DOMStorageContext(this))),
ALLOW_THIS_IN_INITIALIZER_LIST(
indexed_db_context_(new IndexedDBContext(this))) {
+ PrefService* prefs = profile->GetPrefs();
+ clear_on_exit_ = prefs->GetBoolean(prefs::kClearSiteDataOnExit);
+ pref_change_registrar_.Init(prefs);
+ pref_change_registrar_.Add(prefs::kClearSiteDataOnExit, this);
}
WebKitContext::~WebKitContext() {
@@ -30,6 +40,13 @@ WebKitContext::~WebKitContext() {
delete dom_storage_context;
}
+ if (clear_on_exit()) {
jochen (gone - plz use gerrit) 2010/11/27 19:02:27 since we're explicitly deleting the context, you c
pastarmovj 2010/11/27 20:45:15 Done. As a result I had to push(done upon constr
+ const char* url_scheme_skipped = chrome::kExtensionScheme;
+ BrowserThread::PostTask(
+ BrowserThread::WEBKIT, FROM_HERE,
+ NewRunnableFunction(&IndexedDBContext::ClearLocalState,
+ data_path_, url_scheme_skipped));
+ }
IndexedDBContext* indexed_db_context = indexed_db_context_.release();
if (!BrowserThread::DeleteSoon(
BrowserThread::WEBKIT, FROM_HERE, indexed_db_context)) {
@@ -37,6 +54,11 @@ WebKitContext::~WebKitContext() {
}
}
+bool WebKitContext::clear_on_exit() const {
+ AutoLock auto_lock(lock_);
+ return clear_on_exit_;
pastarmovj 2010/11/27 20:45:15 Not needed anymore.
+}
+
void WebKitContext::PurgeMemory() {
if (!BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)) {
BrowserThread::PostTask(
@@ -78,3 +100,19 @@ void WebKitContext::DeleteSessionStorageNamespace(
dom_storage_context_->DeleteSessionStorageNamespace(
session_storage_namespace_id);
}
+
+void WebKitContext::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
jochen (gone - plz use gerrit) 2010/11/27 19:02:27 that shouldn't be required
pastarmovj 2010/11/27 20:45:15 Removed it.
+
+ if (NotificationType::PREF_CHANGED == type) {
+ std::string* name = Details<std::string>(details).ptr();
+ if (prefs::kClearSiteDataOnExit == *name) {
+ AutoLock auto_lock(lock_);
+ clear_on_exit_ = profile_->GetPrefs()->GetBoolean(
+ prefs::kClearSiteDataOnExit);
+ LOG(WARNING) << "Option changed " << clear_on_exit_;
jochen (gone - plz use gerrit) 2010/11/27 19:02:27 please remove
pastarmovj 2010/11/27 20:45:15 Done. It was debug output to test if it is getting
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698