OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ |
6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ | 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/id_map.h" | 10 #include "base/id_map.h" |
(...skipping 27 matching lines...) Expand all Loading... | |
38 // Only call the constructor from the UI thread. | 38 // Only call the constructor from the UI thread. |
39 IndexedDBDispatcherHost(int process_id, WebKitContext* webkit_context); | 39 IndexedDBDispatcherHost(int process_id, WebKitContext* webkit_context); |
40 | 40 |
41 // BrowserMessageFilter implementation. | 41 // BrowserMessageFilter implementation. |
42 virtual void OnChannelClosing(); | 42 virtual void OnChannelClosing(); |
43 virtual void OverrideThreadForMessage(const IPC::Message& message, | 43 virtual void OverrideThreadForMessage(const IPC::Message& message, |
44 BrowserThread::ID* thread); | 44 BrowserThread::ID* thread); |
45 virtual bool OnMessageReceived(const IPC::Message& message, | 45 virtual bool OnMessageReceived(const IPC::Message& message, |
46 bool* message_was_ok); | 46 bool* message_was_ok); |
47 | 47 |
48 void TransactionComplete(int32 transaction_id); | |
michaeln
2011/07/27 01:31:35
Would it make sense to make this method private? I
dgrogan
2011/07/29 18:14:04
Right, IndexedDBTransactionCallbacks needs to call
| |
49 | |
48 // A shortcut for accessing our context. | 50 // A shortcut for accessing our context. |
49 IndexedDBContext* Context() { | 51 IndexedDBContext* Context() { |
50 return webkit_context_->indexed_db_context(); | 52 return webkit_context_->indexed_db_context(); |
51 } | 53 } |
52 | 54 |
53 // The various IndexedDBCallbacks children call these methods to add the | 55 // The various IndexedDBCallbacks children call these methods to add the |
54 // results into the applicable map. See below for more details. | 56 // results into the applicable map. See below for more details. |
55 int32 Add(WebKit::WebIDBCursor* idb_cursor); | 57 int32 Add(WebKit::WebIDBCursor* idb_cursor); |
56 int32 Add(WebKit::WebIDBDatabase* idb_database, const GURL& origin_url); | 58 int32 Add(WebKit::WebIDBDatabase* idb_database, const GURL& origin_url); |
57 int32 Add(WebKit::WebIDBIndex* idb_index); | 59 int32 Add(WebKit::WebIDBIndex* idb_index); |
58 int32 Add(WebKit::WebIDBObjectStore* idb_object_store); | 60 int32 Add(WebKit::WebIDBObjectStore* idb_object_store); |
59 int32 Add(WebKit::WebIDBTransaction* idb_transaction); | 61 int32 Add(WebKit::WebIDBTransaction* idb_transaction, const GURL& origin_url); |
60 | 62 |
61 private: | 63 private: |
62 virtual ~IndexedDBDispatcherHost(); | 64 virtual ~IndexedDBDispatcherHost(); |
63 | 65 |
64 // Message processing. Most of the work is delegated to the dispatcher hosts | 66 // Message processing. Most of the work is delegated to the dispatcher hosts |
65 // below. | 67 // below. |
66 void OnIDBFactoryOpen(const IndexedDBHostMsg_FactoryOpen_Params& p); | 68 void OnIDBFactoryOpen(const IndexedDBHostMsg_FactoryOpen_Params& p); |
67 | 69 |
68 void OnIDBFactoryDeleteDatabase( | 70 void OnIDBFactoryDeleteDatabase( |
69 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& p); | 71 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& p); |
70 | 72 |
71 void ResetDispatcherHosts(); | 73 void ResetDispatcherHosts(); |
72 | 74 |
73 // Helper templates. | 75 // Helper templates. |
74 template <class ReturnType> | 76 template <class ReturnType> |
75 ReturnType* GetOrTerminateProcess( | 77 ReturnType* GetOrTerminateProcess( |
76 IDMap<ReturnType, IDMapOwnPointer>* map, int32 return_object_id); | 78 IDMap<ReturnType, IDMapOwnPointer>* map, int32 return_object_id); |
77 | 79 |
78 template <typename ReplyType, typename WebObjectType, typename Method> | 80 template <typename ReplyType, typename WebObjectType, typename Method> |
79 void SyncGetter(IDMap<WebObjectType, IDMapOwnPointer>* map, int32 object_id, | 81 void SyncGetter(IDMap<WebObjectType, IDMapOwnPointer>* map, int32 object_id, |
80 ReplyType* reply, Method method); | 82 ReplyType* reply, Method method); |
81 | 83 |
82 template <typename ObjectType> | 84 template <typename ObjectType> |
83 void DestroyObject(IDMap<ObjectType, IDMapOwnPointer>* map, int32 object_id); | 85 void DestroyObject(IDMap<ObjectType, IDMapOwnPointer>* map, int32 object_id); |
84 | 86 |
87 // Used in nested classes. | |
88 typedef std::map<int32, GURL> WebIDBObjectIDToURLMap; | |
89 typedef std::map<int32, int64> WebIDBTransactionIDToSizeMap; | |
90 | |
85 class DatabaseDispatcherHost { | 91 class DatabaseDispatcherHost { |
86 public: | 92 public: |
87 explicit DatabaseDispatcherHost(IndexedDBDispatcherHost* parent); | 93 explicit DatabaseDispatcherHost(IndexedDBDispatcherHost* parent); |
88 ~DatabaseDispatcherHost(); | 94 ~DatabaseDispatcherHost(); |
89 | 95 |
90 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); | 96 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); |
91 void Send(IPC::Message* message); | 97 void Send(IPC::Message* message); |
92 | 98 |
93 void OnName(int32 idb_database_id, string16* name); | 99 void OnName(int32 idb_database_id, string16* name); |
94 void OnVersion(int32 idb_database_id, string16* version); | 100 void OnVersion(int32 idb_database_id, string16* version); |
(...skipping 14 matching lines...) Expand all Loading... | |
109 const std::vector<string16>& names, | 115 const std::vector<string16>& names, |
110 int32 mode, int32 timeout, | 116 int32 mode, int32 timeout, |
111 int32* idb_transaction_id, | 117 int32* idb_transaction_id, |
112 WebKit::WebExceptionCode* ec); | 118 WebKit::WebExceptionCode* ec); |
113 void OnOpen(int32 idb_database_id, int32 response_id); | 119 void OnOpen(int32 idb_database_id, int32 response_id); |
114 void OnClose(int32 idb_database_id); | 120 void OnClose(int32 idb_database_id); |
115 void OnDestroyed(int32 idb_database_id); | 121 void OnDestroyed(int32 idb_database_id); |
116 | 122 |
117 IndexedDBDispatcherHost* parent_; | 123 IndexedDBDispatcherHost* parent_; |
118 IDMap<WebKit::WebIDBDatabase, IDMapOwnPointer> map_; | 124 IDMap<WebKit::WebIDBDatabase, IDMapOwnPointer> map_; |
119 typedef std::map<int32, GURL> WebIDBDatabaseIDToURLMap; | 125 WebIDBObjectIDToURLMap database_url_map_; |
120 WebIDBDatabaseIDToURLMap url_map_; | |
121 }; | 126 }; |
122 | 127 |
123 class IndexDispatcherHost { | 128 class IndexDispatcherHost { |
124 public: | 129 public: |
125 explicit IndexDispatcherHost(IndexedDBDispatcherHost* parent); | 130 explicit IndexDispatcherHost(IndexedDBDispatcherHost* parent); |
126 ~IndexDispatcherHost(); | 131 ~IndexDispatcherHost(); |
127 | 132 |
128 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); | 133 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); |
129 void Send(IPC::Message* message); | 134 void Send(IPC::Message* message); |
130 | 135 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 void OnObjectStore(int32 transaction_id, | 252 void OnObjectStore(int32 transaction_id, |
248 const string16& name, | 253 const string16& name, |
249 int32* object_store_id, | 254 int32* object_store_id, |
250 WebKit::WebExceptionCode* ec); | 255 WebKit::WebExceptionCode* ec); |
251 void OnDidCompleteTaskEvents(int transaction_id); | 256 void OnDidCompleteTaskEvents(int transaction_id); |
252 void OnDestroyed(int32 idb_transaction_id); | 257 void OnDestroyed(int32 idb_transaction_id); |
253 | 258 |
254 IndexedDBDispatcherHost* parent_; | 259 IndexedDBDispatcherHost* parent_; |
255 typedef IDMap<WebKit::WebIDBTransaction, IDMapOwnPointer> MapType; | 260 typedef IDMap<WebKit::WebIDBTransaction, IDMapOwnPointer> MapType; |
256 MapType map_; | 261 MapType map_; |
262 WebIDBObjectIDToURLMap transaction_url_map_; | |
263 WebIDBTransactionIDToSizeMap transaction_size_map_; | |
257 }; | 264 }; |
258 | 265 |
259 // Data shared between renderer processes with the same profile. | 266 // Data shared between renderer processes with the same profile. |
260 scoped_refptr<WebKitContext> webkit_context_; | 267 scoped_refptr<WebKitContext> webkit_context_; |
261 | 268 |
262 // Only access on WebKit thread. | 269 // Only access on WebKit thread. |
263 scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_; | 270 scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_; |
264 scoped_ptr<IndexDispatcherHost> index_dispatcher_host_; | 271 scoped_ptr<IndexDispatcherHost> index_dispatcher_host_; |
265 scoped_ptr<ObjectStoreDispatcherHost> object_store_dispatcher_host_; | 272 scoped_ptr<ObjectStoreDispatcherHost> object_store_dispatcher_host_; |
266 scoped_ptr<CursorDispatcherHost> cursor_dispatcher_host_; | 273 scoped_ptr<CursorDispatcherHost> cursor_dispatcher_host_; |
267 scoped_ptr<TransactionDispatcherHost> transaction_dispatcher_host_; | 274 scoped_ptr<TransactionDispatcherHost> transaction_dispatcher_host_; |
268 | 275 |
269 // Used to dispatch messages to the correct view host. | 276 // Used to dispatch messages to the correct view host. |
270 int process_id_; | 277 int process_id_; |
271 | 278 |
272 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); | 279 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); |
273 }; | 280 }; |
274 | 281 |
275 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ | 282 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ |
OLD | NEW |