Index: chrome/browser/in_process_webkit/dom_storage_message_filter.h |
=================================================================== |
--- chrome/browser/in_process_webkit/dom_storage_message_filter.h (revision 68139) |
+++ chrome/browser/in_process_webkit/dom_storage_message_filter.h (working copy) |
@@ -2,84 +2,66 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_DISPATCHER_HOST_H_ |
-#define CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_DISPATCHER_HOST_H_ |
+#ifndef CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_MESSAGE_FILTER_H_ |
+#define CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_MESSAGE_FILTER_H_ |
#pragma once |
#include "base/process.h" |
#include "base/ref_counted.h" |
#include "base/tracked.h" |
+#include "chrome/browser/browser_message_filter.h" |
#include "chrome/browser/in_process_webkit/dom_storage_area.h" |
#include "chrome/browser/in_process_webkit/webkit_context.h" |
+#include "chrome/browser/content_settings/host_content_settings_map.h" |
#include "chrome/common/dom_storage_common.h" |
#include "ipc/ipc_message.h" |
class DOMStorageContext; |
class GURL; |
-class HostContentSettingsMap; |
-class ResourceMessageFilter; |
-class Task; |
-struct ViewMsg_DOMStorageEvent_Params; |
+class Profile; |
+struct DOMStorageMsg_Event_Params; |
// This class handles the logistics of DOM Storage within the browser process. |
// It mostly ferries information between IPCs and the WebKit implementations, |
// but it also handles some special cases like when renderer processes die. |
-class DOMStorageDispatcherHost |
- : public base::RefCountedThreadSafe<DOMStorageDispatcherHost> { |
+class DOMStorageMessageFilter : public BrowserMessageFilter { |
public: |
// Only call the constructor from the UI thread. |
- DOMStorageDispatcherHost( |
- ResourceMessageFilter* resource_message_filter, |
- WebKitContext* webkit_context); |
+ DOMStorageMessageFilter(int process_id, Profile* profile); |
- // Only call from ResourceMessageFilter on the IO thread. |
- void Init(int process_id, base::ProcessHandle process_handle); |
+ // BrowserMessageFilter implementation |
+ virtual void OnChannelConnected(int32 peer_pid); |
+ virtual void OverrideThreadForMessage(const IPC::Message& message, |
+ BrowserThread::ID* thread); |
+ virtual bool OnMessageReceived(const IPC::Message& message, |
+ bool* message_was_ok); |
- // 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. |
- bool OnMessageReceived(const IPC::Message& message, bool* msg_is_ok); |
- |
- // Clones a session storage namespace and returns the cloned namespaces' id. |
- // Only call on the IO thread. |
- int64 CloneSessionStorage(int64 original_id); |
- |
- // 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 NullableString16& key, |
const NullableString16& old_value, const NullableString16& new_value, |
const string16& origin, const GURL& url, bool is_local_storage); |
private: |
- friend class base::RefCountedThreadSafe<DOMStorageDispatcherHost>; |
- ~DOMStorageDispatcherHost(); |
+ friend class base::RefCountedThreadSafe<DOMStorageMessageFilter>; |
+ ~DOMStorageMessageFilter(); |
// Message Handlers. |
void OnStorageAreaId(int64 namespace_id, const string16& origin, |
- IPC::Message* reply_msg); |
- void OnLength(int64 storage_area_id, IPC::Message* reply_msg); |
- void OnKey(int64 storage_area_id, unsigned index, IPC::Message* reply_msg); |
+ int64* storage_area_id); |
+ void OnLength(int64 storage_area_id, unsigned* length); |
+ void OnKey(int64 storage_area_id, unsigned index, NullableString16* key); |
void OnGetItem(int64 storage_area_id, const string16& key, |
- IPC::Message* reply_msg); |
- void OnSetItem(int64 storage_area_id, const string16& key, |
+ NullableString16* value); |
+ void OnSetItem(int render_view_id, int64 storage_area_id, const string16& key, |
const string16& value, const GURL& url, |
- IPC::Message* reply_msg); |
+ WebKit::WebStorageArea::Result* result, |
+ NullableString16* old_value); |
void OnRemoveItem(int64 storage_area_id, const string16& key, |
- const GURL& url, IPC::Message* reply_msg); |
- void OnClear(int64 storage_area_id, const GURL& url, IPC::Message* reply_msg); |
+ const GURL& url, NullableString16* old_value); |
+ void OnClear(int64 storage_area_id, const GURL& url, bool* something_cleared); |
- // WebKit thread half of OnStorageAreaId |
- void OnStorageAreaIdWebKit( |
- int64 namespace_id, const string16& origin, IPC::Message* reply_msg, |
- HostContentSettingsMap* host_context_settings_map); |
- |
// Only call on the IO thread. |
- void OnStorageEvent(const ViewMsg_DOMStorageEvent_Params& params); |
+ void OnStorageEvent(const DOMStorageMsg_Event_Params& params); |
// A shortcut for accessing our context. |
DOMStorageContext* Context() { |
@@ -89,29 +71,25 @@ |
// Use whenever there's a chance OnStorageEvent will be called. |
class ScopedStorageEventContext { |
public: |
- ScopedStorageEventContext(DOMStorageDispatcherHost* dispatcher_host, |
- const GURL* url); |
+ ScopedStorageEventContext( |
+ DOMStorageMessageFilter* dispatcher_message_filter, |
+ const GURL* url); |
~ScopedStorageEventContext(); |
}; |
// Only access on the WebKit thread! Used for storage events. |
- static DOMStorageDispatcherHost* storage_event_host_; |
+ static DOMStorageMessageFilter* storage_event_message_filter; |
static const GURL* storage_event_url_; |
// Data shared between renderer processes with the same profile. |
scoped_refptr<WebKitContext> webkit_context_; |
- // Only set and use on the IO thread. |
- ResourceMessageFilter* resource_message_filter_; |
- |
- // If we get a corrupt message from a renderer, we need to kill it using this |
- // handle. |
- base::ProcessHandle process_handle_; |
- |
// Used to dispatch messages to the correct view host. |
int process_id_; |
- DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageDispatcherHost); |
+ scoped_refptr<HostContentSettingsMap> host_content_settings_map_; |
+ |
+ DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageMessageFilter); |
}; |
-#endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_DISPATCHER_HOST_H_ |
+#endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_MESSAGE_FILTER_H_ |