summaryrefslogtreecommitdiffstats
path: root/chrome/browser/in_process_webkit
diff options
context:
space:
mode:
authorjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-01 20:16:48 +0000
committerjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-01 20:16:48 +0000
commit757b3eb7960cefa174123ca5a1c3915672d7fd6c (patch)
tree32c24ee9b0e58b76184c0d4d609307111e5579db /chrome/browser/in_process_webkit
parentba9766c27d2fba8b7f8fcee85054d8660d9018f6 (diff)
downloadchromium_src-757b3eb7960cefa174123ca5a1c3915672d7fd6c.zip
chromium_src-757b3eb7960cefa174123ca5a1c3915672d7fd6c.tar.gz
chromium_src-757b3eb7960cefa174123ca5a1c3915672d7fd6c.tar.bz2
Reverting 27756.
Review URL: http://codereview.chromium.org/249058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27759 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/in_process_webkit')
-rw-r--r--chrome/browser/in_process_webkit/browser_webkitclient_impl.cc13
-rw-r--r--chrome/browser/in_process_webkit/browser_webkitclient_impl.h3
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_context.cc39
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_context.h15
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc64
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h40
-rw-r--r--chrome/browser/in_process_webkit/storage_namespace.cc8
-rw-r--r--chrome/browser/in_process_webkit/storage_namespace.h6
-rw-r--r--chrome/browser/in_process_webkit/webkit_context.cc27
-rw-r--r--chrome/browser/in_process_webkit/webkit_context.h8
10 files changed, 34 insertions, 189 deletions
diff --git a/chrome/browser/in_process_webkit/browser_webkitclient_impl.cc b/chrome/browser/in_process_webkit/browser_webkitclient_impl.cc
index 53ced24..33fc0de 100644
--- a/chrome/browser/in_process_webkit/browser_webkitclient_impl.cc
+++ b/chrome/browser/in_process_webkit/browser_webkitclient_impl.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/in_process_webkit/browser_webkitclient_impl.h"
#include "base/logging.h"
-#include "chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h"
#include "webkit/api/public/WebData.h"
#include "webkit/api/public/WebString.h"
#include "webkit/api/public/WebURL.h"
@@ -106,15 +105,3 @@ BrowserWebKitClientImpl::createSessionStorageNamespace() {
NOTREACHED();
return 0;
}
-
-void BrowserWebKitClientImpl::dispatchStorageEvent(
- const WebKit::WebString& key, const WebKit::WebString& old_value,
- const WebKit::WebString& new_value, const WebKit::WebString& origin,
- bool is_local_storage) {
- // TODO(jorlow): Implement
- if (!is_local_storage)
- return;
-
- DOMStorageDispatcherHost::DispatchStorageEvent(key, old_value, new_value,
- origin, is_local_storage);
-}
diff --git a/chrome/browser/in_process_webkit/browser_webkitclient_impl.h b/chrome/browser/in_process_webkit/browser_webkitclient_impl.h
index 07824db..546100d 100644
--- a/chrome/browser/in_process_webkit/browser_webkitclient_impl.h
+++ b/chrome/browser/in_process_webkit/browser_webkitclient_impl.h
@@ -32,9 +32,6 @@ class BrowserWebKitClientImpl : public webkit_glue::WebKitClientImpl {
virtual WebKit::WebStorageNamespace* createLocalStorageNamespace(
const WebKit::WebString& path);
virtual WebKit::WebStorageNamespace* createSessionStorageNamespace();
- virtual void dispatchStorageEvent(const WebKit::WebString& key,
- const WebKit::WebString& oldValue, const WebKit::WebString& newValue,
- const WebKit::WebString& origin, bool isLocalStorage);
};
#endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_WEBKIT_CLIENT_IMPL_H_
diff --git a/chrome/browser/in_process_webkit/dom_storage_context.cc b/chrome/browser/in_process_webkit/dom_storage_context.cc
index 9f763e2..b22d976 100644
--- a/chrome/browser/in_process_webkit/dom_storage_context.cc
+++ b/chrome/browser/in_process_webkit/dom_storage_context.cc
@@ -14,18 +14,11 @@ DOMStorageContext::DOMStorageContext(WebKitContext* webkit_context)
: last_storage_area_id_(kFirstStorageAreaId),
last_storage_namespace_id_(kFirstStorageNamespaceId),
webkit_context_(webkit_context) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
}
DOMStorageContext::~DOMStorageContext() {
- // This should not go away until all DOM Storage Dispatcher hosts have gone
- // away. And they remove themselves from this list.
- DCHECK(dispatcher_host_set_.empty());
-
- // If we don't have any work to do on the WebKit thread, bail.
- if (storage_namespace_map_.empty())
- return;
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
-
// The storage namespace destructor unregisters the storage namespace, so
// our iterator becomes invalid. Thus we just keep deleting the first item
// until there are none left.
@@ -34,7 +27,6 @@ DOMStorageContext::~DOMStorageContext() {
}
StorageNamespace* DOMStorageContext::LocalStorage() {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
StorageNamespace* storage_namespace = GetStorageNamespace(
kLocalStorageNamespaceId);
if (storage_namespace)
@@ -48,26 +40,22 @@ StorageNamespace* DOMStorageContext::LocalStorage() {
}
StorageNamespace* DOMStorageContext::NewSessionStorage() {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
return StorageNamespace::CreateSessionStorageNamespace(this);
}
void DOMStorageContext::RegisterStorageArea(StorageArea* storage_area) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
int64 id = storage_area->id();
DCHECK(!GetStorageArea(id));
storage_area_map_[id] = storage_area;
}
void DOMStorageContext::UnregisterStorageArea(StorageArea* storage_area) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
int64 id = storage_area->id();
DCHECK(GetStorageArea(id));
storage_area_map_.erase(id);
}
StorageArea* DOMStorageContext::GetStorageArea(int64 id) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
StorageAreaMap::iterator iter = storage_area_map_.find(id);
if (iter == storage_area_map_.end())
return NULL;
@@ -76,7 +64,6 @@ StorageArea* DOMStorageContext::GetStorageArea(int64 id) {
void DOMStorageContext::RegisterStorageNamespace(
StorageNamespace* storage_namespace) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
int64 id = storage_namespace->id();
DCHECK(!GetStorageNamespace(id));
storage_namespace_map_[id] = storage_namespace;
@@ -84,38 +71,14 @@ void DOMStorageContext::RegisterStorageNamespace(
void DOMStorageContext::UnregisterStorageNamespace(
StorageNamespace* storage_namespace) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
int64 id = storage_namespace->id();
DCHECK(GetStorageNamespace(id));
storage_namespace_map_.erase(id);
}
StorageNamespace* DOMStorageContext::GetStorageNamespace(int64 id) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
StorageNamespaceMap::iterator iter = storage_namespace_map_.find(id);
if (iter == storage_namespace_map_.end())
return NULL;
return iter->second;
}
-
-void DOMStorageContext::RegisterDispatcherHost(
- DOMStorageDispatcherHost* dispatcher_host) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- DCHECK(dispatcher_host_set_.find(dispatcher_host) ==
- dispatcher_host_set_.end());
- dispatcher_host_set_.insert(dispatcher_host);
-}
-
-void DOMStorageContext::UnregisterDispatcherHost(
- DOMStorageDispatcherHost* dispatcher_host) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- DCHECK(dispatcher_host_set_.find(dispatcher_host) !=
- dispatcher_host_set_.end());
- dispatcher_host_set_.erase(dispatcher_host);
-}
-
-const DOMStorageContext::DispatcherHostSet*
-DOMStorageContext::GetDispatcherHostSet() const {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- return &dispatcher_host_set_;
-}
diff --git a/chrome/browser/in_process_webkit/dom_storage_context.h b/chrome/browser/in_process_webkit/dom_storage_context.h
index 5e85876..ba26ac2 100644
--- a/chrome/browser/in_process_webkit/dom_storage_context.h
+++ b/chrome/browser/in_process_webkit/dom_storage_context.h
@@ -7,7 +7,6 @@
#include "base/file_path.h"
#include "base/hash_tables.h"
-#include "chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h"
class StorageArea;
class StorageNamespace;
@@ -16,8 +15,7 @@ class WebKitContext;
// This is owned by WebKitContext and is all the dom storage information that's
// shared by all the ResourceMessageFilter/DOMStorageDispatcherHosts that share
// the same profile. The specifics of responsibilities are fairly well
-// documented here and in StorageNamespace and StorageArea. Everything is only
-// to be accessed on the WebKit thread unless noted otherwise.
+// documented here and in StorageNamespace and StorageArea.
class DOMStorageContext {
public:
explicit DOMStorageContext(WebKitContext* webkit_context);
@@ -46,13 +44,6 @@ class DOMStorageContext {
void UnregisterStorageNamespace(StorageNamespace* storage_namespace);
StorageNamespace* GetStorageNamespace(int64 id);
- // Sometimes an event from one DOM storage dispatcher host requires
- // communication to all of them.
- typedef base::hash_set<DOMStorageDispatcherHost*> DispatcherHostSet;
- void RegisterDispatcherHost(DOMStorageDispatcherHost* dispatcher_host);
- void UnregisterDispatcherHost(DOMStorageDispatcherHost* dispatcher_host);
- const DispatcherHostSet* GetDispatcherHostSet() const;
-
// The special ID used for local storage.
static const int64 kLocalStorageNamespaceId = 0;
@@ -66,10 +57,6 @@ class DOMStorageContext {
// We're owned by this WebKit context. Used while instantiating LocalStorage.
WebKitContext* webkit_context_;
- // All the DOMStorageDispatcherHosts that are attached to us. ONLY USE ON THE
- // IO THREAD!
- DispatcherHostSet dispatcher_host_set_;
-
// Maps ids to StorageAreas. We do NOT own these objects. StorageNamespace
// (which does own them) will notify us when we should remove the entries.
typedef base::hash_map<int64, StorageArea*> StorageAreaMap;
diff --git a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc
index 1856a37..ac39acb 100644
--- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc
+++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc
@@ -13,23 +13,6 @@
#include "chrome/browser/renderer_host/browser_render_process_host.h"
#include "chrome/common/render_messages.h"
-DOMStorageDispatcherHost* DOMStorageDispatcherHost::current_ = NULL;
-
-DOMStorageDispatcherHost::
-AutoSetCurrentDispatcherHost::AutoSetCurrentDispatcherHost(
- DOMStorageDispatcherHost* dispatcher_host) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
- DCHECK(!current_);
- current_ = dispatcher_host;
-}
-
-DOMStorageDispatcherHost::
-AutoSetCurrentDispatcherHost::~AutoSetCurrentDispatcherHost() {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
- DCHECK(current_);
- current_ = NULL;
-}
-
DOMStorageDispatcherHost::DOMStorageDispatcherHost(
IPC::Message::Sender* message_sender, WebKitContext* webkit_context,
WebKitThread* webkit_thread)
@@ -49,9 +32,6 @@ DOMStorageDispatcherHost::~DOMStorageDispatcherHost() {
}
void DOMStorageDispatcherHost::Init(base::ProcessHandle process_handle) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- Context()->RegisterDispatcherHost(this);
-
DCHECK(!process_handle_);
process_handle_ = process_handle;
DCHECK(process_handle_);
@@ -59,7 +39,6 @@ void DOMStorageDispatcherHost::Init(base::ProcessHandle process_handle) {
void DOMStorageDispatcherHost::Shutdown() {
if (ChromeThread::CurrentlyOn(ChromeThread::IO)) {
- Context()->UnregisterDispatcherHost(this);
message_sender_ = NULL;
if (!ever_used_) {
// No need to (possibly) spin up the WebKit thread for a no-op.
@@ -79,24 +58,12 @@ void DOMStorageDispatcherHost::Shutdown() {
DCHECK(!shutdown_);
shutdown_ = true;
- // TODO(jorlow): Do stuff that needs to be run on the WebKit thread. Locks
- // and others will likely need this, so let's not delete this
- // code even though it doesn't do anyting yet.
+ // TODO(jorlow): If we have any locks or are tracking resources that need to
+ // be released on the WebKit thread, do it here.
}
-/* static */
-void DOMStorageDispatcherHost::DispatchStorageEvent(const string16& key,
- const NullableString16& old_value, const NullableString16& new_value,
- const string16& origin, bool is_local_storage) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
- DCHECK(current_);
- current_->webkit_thread_->PostIOThreadTask(FROM_HERE, NewRunnableMethod(
- current_, &DOMStorageDispatcherHost::OnStorageEvent, key, old_value,
- new_value, origin, is_local_storage));
-}
-
-bool DOMStorageDispatcherHost::OnMessageReceived(const IPC::Message& message,
- bool *msg_is_ok) {
+bool DOMStorageDispatcherHost::OnMessageReceived(
+ const IPC::Message& message, bool *msg_is_ok) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
DCHECK(!shutdown_);
DCHECK(process_handle_);
@@ -305,8 +272,6 @@ void DOMStorageDispatcherHost::OnSetItem(int64 storage_area_id,
ViewHostMsg_DOMStorageSetItem::ID, process_handle_);
return;
}
-
- AutoSetCurrentDispatcherHost auto_set(this);
storage_area->SetItem(key, value, &quota_exception);
DCHECK(!quota_exception); // This is tracked by the renderer.
}
@@ -328,8 +293,6 @@ void DOMStorageDispatcherHost::OnRemoveItem(int64 storage_area_id,
ViewHostMsg_DOMStorageRemoveItem::ID, process_handle_);
return;
}
-
- AutoSetCurrentDispatcherHost auto_set(this);
storage_area->RemoveItem(key);
}
@@ -349,24 +312,5 @@ void DOMStorageDispatcherHost::OnClear(int64 storage_area_id) {
ViewHostMsg_DOMStorageClear::ID, process_handle_);
return;
}
-
- AutoSetCurrentDispatcherHost auto_set(this);
storage_area->Clear();
}
-
-void DOMStorageDispatcherHost::OnStorageEvent(const string16& key,
- const NullableString16& old_value, const NullableString16& new_value,
- const string16& origin, bool is_local_storage) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- DCHECK(is_local_storage); // Only LocalStorage is implemented right now.
- DOMStorageType dom_storage_type = is_local_storage ? DOM_STORAGE_LOCAL
- : DOM_STORAGE_SESSION;
- const DOMStorageContext::DispatcherHostSet* set =
- Context()->GetDispatcherHostSet();
- DOMStorageContext::DispatcherHostSet::const_iterator cur = set->begin();
- while (cur != set->end()) {
- (*cur)->Send(new ViewMsg_DOMStorageEvent(key, old_value, new_value, origin,
- dom_storage_type));
- ++cur;
- }
-}
diff --git a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h
index 7b34ad7..a0d3d77 100644
--- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h
+++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h
@@ -29,22 +29,14 @@ class DOMStorageDispatcherHost :
// Only call from ResourceMessageFilter on the IO thread.
void Init(base::ProcessHandle process_handle);
- // Only call from ResourceMessageFilter on the IO thread. Calls self on the
- // WebKit thread in some cases.
- void Shutdown();
-
// Only call from ResourceMessageFilter on the IO thread.
+ void Shutdown();
bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok);
// Send a message to the renderer process associated with our
// message_sender_ via the IO thread. May be called from any thread.
void Send(IPC::Message* message);
- // Only call on the WebKit thread.
- static void DispatchStorageEvent(const string16& key,
- const NullableString16& old_value, const NullableString16& new_value,
- const string16& origin, bool is_local_storage);
-
private:
friend class base::RefCountedThreadSafe<DOMStorageDispatcherHost>;
~DOMStorageDispatcherHost();
@@ -63,27 +55,12 @@ class DOMStorageDispatcherHost :
void OnRemoveItem(int64 storage_area_id, const string16& key);
void OnClear(int64 storage_area_id);
- // Only call on the IO thread.
- void OnStorageEvent(const string16& key, const NullableString16& old_value,
- const NullableString16& new_value, const string16& origin,
- bool is_local_storage);
-
// A shortcut for accessing our context.
DOMStorageContext* Context() {
DCHECK(!shutdown_);
- return webkit_context_->dom_storage_context();
+ return webkit_context_->GetDOMStorageContext();
}
- // Use whenever there's a chance OnStorageEvent will be called.
- class AutoSetCurrentDispatcherHost {
- public:
- AutoSetCurrentDispatcherHost(DOMStorageDispatcherHost* dispatcher_host);
- ~AutoSetCurrentDispatcherHost();
- };
-
- // Only access on the WebKit thread! Used for storage events.
- static DOMStorageDispatcherHost* current_;
-
// Data shared between renderer processes with the same profile.
scoped_refptr<WebKitContext> webkit_context_;
@@ -110,17 +87,4 @@ class DOMStorageDispatcherHost :
DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageDispatcherHost);
};
-#if defined(COMPILER_GCC)
-namespace __gnu_cxx {
-
-template<>
-struct hash<DOMStorageDispatcherHost*> {
- std::size_t operator()(DOMStorageDispatcherHost* const& p) const {
- return reinterpret_cast<std::size_t>(p);
- }
-};
-
-} // namespace __gnu_cxx
-#endif
-
#endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_DISPATCHER_HOST_H_
diff --git a/chrome/browser/in_process_webkit/storage_namespace.cc b/chrome/browser/in_process_webkit/storage_namespace.cc
index fb49259..fa2c74a 100644
--- a/chrome/browser/in_process_webkit/storage_namespace.cc
+++ b/chrome/browser/in_process_webkit/storage_namespace.cc
@@ -42,11 +42,11 @@ StorageNamespace* StorageNamespace::CreateSessionStorageNamespace(
StorageNamespace::StorageNamespace(DOMStorageContext* dom_storage_context,
WebStorageNamespace* storage_namespace,
- int64 id, DOMStorageType dom_storage_type)
+ int64 id, DOMStorageType storage_type)
: dom_storage_context_(dom_storage_context),
storage_namespace_(storage_namespace),
id_(id),
- dom_storage_type_(dom_storage_type) {
+ storage_type_(storage_type) {
DCHECK(dom_storage_context_);
DCHECK(storage_namespace_);
dom_storage_context_->RegisterStorageNamespace(this);
@@ -82,12 +82,12 @@ StorageArea* StorageNamespace::GetStorageArea(const string16& origin) {
}
StorageNamespace* StorageNamespace::Copy() {
- DCHECK(dom_storage_type_ == DOM_STORAGE_SESSION);
+ DCHECK(storage_type_ == DOM_STORAGE_SESSION);
int64 id = dom_storage_context_->AllocateStorageNamespaceId();
DCHECK(!dom_storage_context_->GetStorageNamespace(id));
WebStorageNamespace* new_storage_namespace = storage_namespace_->copy();
return new StorageNamespace(dom_storage_context_, new_storage_namespace, id,
- dom_storage_type_);
+ storage_type_);
}
void StorageNamespace::Close() {
diff --git a/chrome/browser/in_process_webkit/storage_namespace.h b/chrome/browser/in_process_webkit/storage_namespace.h
index 9752212..91e0ae6 100644
--- a/chrome/browser/in_process_webkit/storage_namespace.h
+++ b/chrome/browser/in_process_webkit/storage_namespace.h
@@ -31,11 +31,7 @@ class StorageNamespace {
StorageNamespace* Copy();
void Close();
- const DOMStorageContext* dom_storage_context() const {
- return dom_storage_context_;
- }
int64 id() const { return id_; }
- DOMStorageType dom_storage_type() const { return dom_storage_type_; }
private:
// Called by the static factory methods above.
@@ -57,7 +53,7 @@ class StorageNamespace {
int64 id_;
// SessionStorage vs. LocalStorage.
- const DOMStorageType dom_storage_type_;
+ const DOMStorageType storage_type_;
DISALLOW_IMPLICIT_CONSTRUCTORS(StorageNamespace);
};
diff --git a/chrome/browser/in_process_webkit/webkit_context.cc b/chrome/browser/in_process_webkit/webkit_context.cc
index 0768284..ae647d6 100644
--- a/chrome/browser/in_process_webkit/webkit_context.cc
+++ b/chrome/browser/in_process_webkit/webkit_context.cc
@@ -9,17 +9,24 @@
WebKitContext::WebKitContext(const FilePath& data_path, bool is_incognito)
: data_path_(data_path),
- is_incognito_(is_incognito),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- dom_storage_context_(new DOMStorageContext(this))) {
+ is_incognito_(is_incognito) {
}
WebKitContext::~WebKitContext() {
- // If the WebKit thread was ever spun up, delete the object there. If we're
- // on the IO thread, this is safe because the WebKit thread goes away after
- // the IO. If we're on the UI thread, we're safe because the UI thread kills
- // the WebKit thread.
- MessageLoop* webkit_loop = ChromeThread::GetMessageLoop(ChromeThread::WEBKIT);
- if (webkit_loop)
- webkit_loop->DeleteSoon(FROM_HERE, dom_storage_context_.release());
+ // 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();
}
diff --git a/chrome/browser/in_process_webkit/webkit_context.h b/chrome/browser/in_process_webkit/webkit_context.h
index b359ab0..ee4c61b 100644
--- a/chrome/browser/in_process_webkit/webkit_context.h
+++ b/chrome/browser/in_process_webkit/webkit_context.h
@@ -10,7 +10,6 @@
#include "base/scoped_ptr.h"
class DOMStorageContext;
-class WebKitThread;
// There's one WebKitContext per profile. Various DispatcherHost classes
// have a pointer to the Context to store shared state.
@@ -20,9 +19,9 @@ class WebKitContext : public base::RefCountedThreadSafe<WebKitContext> {
const FilePath& data_path() const { return data_path_; }
bool is_incognito() const { return is_incognito_; }
- DOMStorageContext* dom_storage_context() {
- return dom_storage_context_.get();
- }
+
+ // Initialized lazily. Pointer is valid for the lifetime of this instance.
+ DOMStorageContext* GetDOMStorageContext();
private:
friend class base::RefCountedThreadSafe<WebKitContext>;
@@ -32,6 +31,7 @@ class WebKitContext : public base::RefCountedThreadSafe<WebKitContext> {
const FilePath data_path_;
const bool is_incognito_;
+ // The state for DOM Storage.
scoped_ptr<DOMStorageContext> dom_storage_context_;
DISALLOW_IMPLICIT_CONSTRUCTORS(WebKitContext);