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

Unified Diff: chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h

Issue 223013: Another stab at the Chromium side of storage events. The WebKit side can be ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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: chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h
===================================================================
--- chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h (revision 27652)
+++ chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h (working copy)
@@ -29,14 +29,22 @@
// 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();
@@ -55,12 +63,27 @@
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_->GetDOMStorageContext();
+ return webkit_context_->dom_storage_context();
}
+ // 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_;
@@ -87,4 +110,17 @@
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_

Powered by Google App Engine
This is Rietveld 408576698