summaryrefslogtreecommitdiffstats
path: root/chrome/browser/in_process_webkit/webkit_context.cc
diff options
context:
space:
mode:
authorjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-08 03:54:49 +0000
committerjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-08 03:54:49 +0000
commitc7fd0cbdbd381035ecd95d164a59d874b41d9339 (patch)
tree9956e58e7eb8b9098301cca6f1330ed5a3a1a348 /chrome/browser/in_process_webkit/webkit_context.cc
parentb4599a15c90a853930187cc751c951beb819c02d (diff)
downloadchromium_src-c7fd0cbdbd381035ecd95d164a59d874b41d9339.zip
chromium_src-c7fd0cbdbd381035ecd95d164a59d874b41d9339.tar.gz
chromium_src-c7fd0cbdbd381035ecd95d164a59d874b41d9339.tar.bz2
Refactor DOM storage to be more object oriented. All the DOMStorageDispatcher hosts (which are each owned by one ResourceMessageFilter) for the same profile share a WebKit context, and each one of those contexts owns a DOMStorageContext. The DOMStorageContext owns storage namespace objects which own storage area objects which wrap their WebKit counterparts.
Not only is this cleaner code wise and more efficient (we're not duplicating WebStorageNamespaces and Areas for each DOMStorageDispatcherHost) but this is necessary for events and locking. TEST=none BUG=none Review URL: http://codereview.chromium.org/192003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25609 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/in_process_webkit/webkit_context.cc')
-rw-r--r--chrome/browser/in_process_webkit/webkit_context.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/chrome/browser/in_process_webkit/webkit_context.cc b/chrome/browser/in_process_webkit/webkit_context.cc
index e7d7d1a..ae647d6 100644
--- a/chrome/browser/in_process_webkit/webkit_context.cc
+++ b/chrome/browser/in_process_webkit/webkit_context.cc
@@ -4,10 +4,29 @@
#include "chrome/browser/in_process_webkit/webkit_context.h"
+#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/in_process_webkit/dom_storage_context.h"
+
WebKitContext::WebKitContext(const FilePath& data_path, bool is_incognito)
: data_path_(data_path),
is_incognito_(is_incognito) {
}
WebKitContext::~WebKitContext() {
+ // If a dom storage context was ever created, we need to destroy it on the
+ // WebKit thread. Luckily we're guaranteed that the WebKit thread is still
+ // alive since the ResourceDispatcherHost (which owns the WebKit thread) goes
+ // away after all the ResourceMessageFilters and the profiles (i.e. all the
+ // objects with a reference to us).
+ if (dom_storage_context_.get()) {
+ MessageLoop* loop = ChromeThread::GetMessageLoop(ChromeThread::WEBKIT);
+ loop->DeleteSoon(FROM_HERE, dom_storage_context_.release());
+ }
+}
+
+DOMStorageContext* WebKitContext::GetDOMStorageContext() {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
+ if (!dom_storage_context_.get())
+ dom_storage_context_.reset(new DOMStorageContext(this));
+ return dom_storage_context_.get();
}