| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_DISPATCHER_HOST_H_ | 5 #ifndef CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_DISPATCHER_HOST_H_ |
| 6 #define CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_DISPATCHER_HOST_H_ | 6 #define CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_DISPATCHER_HOST_H_ |
| 7 | 7 |
| 8 #include "base/process.h" | 8 #include "base/process.h" |
| 9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
| 10 #include "base/tracked.h" | 10 #include "base/tracked.h" |
| 11 #include "chrome/browser/in_process_webkit/dom_storage_area.h" | 11 #include "chrome/browser/in_process_webkit/dom_storage_area.h" |
| 12 #include "chrome/browser/in_process_webkit/webkit_context.h" | 12 #include "chrome/browser/in_process_webkit/webkit_context.h" |
| 13 #include "chrome/common/dom_storage_type.h" | |
| 14 #include "ipc/ipc_message.h" | 13 #include "ipc/ipc_message.h" |
| 15 | 14 |
| 16 class DOMStorageContext; | 15 class DOMStorageContext; |
| 17 class GURL; | 16 class GURL; |
| 18 class Task; | 17 class Task; |
| 19 class WebKitThread; | 18 class WebKitThread; |
| 20 struct ViewMsg_DOMStorageEvent_Params; | 19 struct ViewMsg_DOMStorageEvent_Params; |
| 21 | 20 |
| 22 // This class handles the logistics of DOM Storage within the browser process. | 21 // This class handles the logistics of DOM Storage within the browser process. |
| 23 // It mostly ferries information between IPCs and the WebKit implementations, | 22 // It mostly ferries information between IPCs and the WebKit implementations, |
| 24 // but it also handles some special cases like when renderer processes die. | 23 // but it also handles some special cases like when renderer processes die. |
| 25 class DOMStorageDispatcherHost | 24 class DOMStorageDispatcherHost |
| 26 : public base::RefCountedThreadSafe<DOMStorageDispatcherHost> { | 25 : public base::RefCountedThreadSafe<DOMStorageDispatcherHost> { |
| 27 public: | 26 public: |
| 28 // Only call the constructor from the UI thread. | 27 // Only call the constructor from the UI thread. |
| 29 DOMStorageDispatcherHost(IPC::Message::Sender* message_sender, | 28 DOMStorageDispatcherHost(IPC::Message::Sender* message_sender, |
| 30 WebKitContext* webkit_context, WebKitThread* webkit_thread); | 29 WebKitContext* webkit_context, WebKitThread* webkit_thread); |
| 31 | 30 |
| 32 // Only call from ResourceMessageFilter on the IO thread. | 31 // Only call from ResourceMessageFilter on the IO thread. |
| 33 void Init(base::ProcessHandle process_handle); | 32 void Init(base::ProcessHandle process_handle); |
| 34 | 33 |
| 35 // Only call from ResourceMessageFilter on the IO thread. Calls self on the | 34 // Only call from ResourceMessageFilter on the IO thread. Calls self on the |
| 36 // WebKit thread in some cases. | 35 // WebKit thread in some cases. |
| 37 void Shutdown(); | 36 void Shutdown(); |
| 38 | 37 |
| 39 // Only call from ResourceMessageFilter on the IO thread. | 38 // Only call from ResourceMessageFilter on the IO thread. |
| 40 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); | 39 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); |
| 41 | 40 |
| 41 // Clones a session storage namespace and returns the cloned namespaces' id. |
| 42 // Only call on the IO thread. |
| 43 int64 CloneSessionStorage(int64 original_id); |
| 44 |
| 42 // Send a message to the renderer process associated with our | 45 // Send a message to the renderer process associated with our |
| 43 // message_sender_ via the IO thread. May be called from any thread. | 46 // message_sender_ via the IO thread. May be called from any thread. |
| 44 void Send(IPC::Message* message); | 47 void Send(IPC::Message* message); |
| 45 | 48 |
| 46 // Only call on the WebKit thread. | 49 // Only call on the WebKit thread. |
| 47 static void DispatchStorageEvent(const NullableString16& key, | 50 static void DispatchStorageEvent(const NullableString16& key, |
| 48 const NullableString16& old_value, const NullableString16& new_value, | 51 const NullableString16& old_value, const NullableString16& new_value, |
| 49 const string16& origin, const GURL& url, bool is_local_storage); | 52 const string16& origin, const GURL& url, bool is_local_storage); |
| 50 | 53 |
| 51 private: | 54 private: |
| 52 friend class base::RefCountedThreadSafe<DOMStorageDispatcherHost>; | 55 friend class base::RefCountedThreadSafe<DOMStorageDispatcherHost>; |
| 53 ~DOMStorageDispatcherHost(); | 56 ~DOMStorageDispatcherHost(); |
| 54 | 57 |
| 55 // Message Handlers. | 58 // Message Handlers. |
| 56 void OnNamespaceId(DOMStorageType storage_type, IPC::Message* reply_msg); | |
| 57 void OnCloneNamespaceId(int64 namespace_id, IPC::Message* reply_msg); | |
| 58 void OnStorageAreaId(int64 namespace_id, const string16& origin, | 59 void OnStorageAreaId(int64 namespace_id, const string16& origin, |
| 59 IPC::Message* reply_msg); | 60 IPC::Message* reply_msg); |
| 60 void OnLength(int64 storage_area_id, IPC::Message* reply_msg); | 61 void OnLength(int64 storage_area_id, IPC::Message* reply_msg); |
| 61 void OnKey(int64 storage_area_id, unsigned index, IPC::Message* reply_msg); | 62 void OnKey(int64 storage_area_id, unsigned index, IPC::Message* reply_msg); |
| 62 void OnGetItem(int64 storage_area_id, const string16& key, | 63 void OnGetItem(int64 storage_area_id, const string16& key, |
| 63 IPC::Message* reply_msg); | 64 IPC::Message* reply_msg); |
| 64 void OnSetItem(int64 storage_area_id, const string16& key, | 65 void OnSetItem(int64 storage_area_id, const string16& key, |
| 65 const string16& value, const GURL& url, | 66 const string16& value, const GURL& url, |
| 66 IPC::Message* reply_msg); | 67 IPC::Message* reply_msg); |
| 67 void OnRemoveItem(int64 storage_area_id, const string16& key, | 68 void OnRemoveItem(int64 storage_area_id, const string16& key, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 98 IPC::Message::Sender* message_sender_; | 99 IPC::Message::Sender* message_sender_; |
| 99 | 100 |
| 100 // If we get a corrupt message from a renderer, we need to kill it using this | 101 // If we get a corrupt message from a renderer, we need to kill it using this |
| 101 // handle. | 102 // handle. |
| 102 base::ProcessHandle process_handle_; | 103 base::ProcessHandle process_handle_; |
| 103 | 104 |
| 104 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageDispatcherHost); | 105 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageDispatcherHost); |
| 105 }; | 106 }; |
| 106 | 107 |
| 107 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_DISPATCHER_HOST_H_ | 108 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_DISPATCHER_HOST_H_ |
| OLD | NEW |