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

Side by Side Diff: chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h

Issue 3107029: Revert 56862 - Add transaction coordinator. Allow idle transactions to be abo... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ 5 #ifndef CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_
6 #define CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ 6 #define CHROME_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"
11 #include "base/process.h" 11 #include "base/process.h"
12 #include "base/ref_counted.h" 12 #include "base/ref_counted.h"
13 #include "chrome/browser/in_process_webkit/webkit_context.h" 13 #include "chrome/browser/in_process_webkit/webkit_context.h"
14 #include "ipc/ipc_message.h" 14 #include "ipc/ipc_message.h"
15 15
16 class IndexedDBKey; 16 class IndexedDBKey;
17 class SerializedScriptValue; 17 class SerializedScriptValue;
18 struct ViewHostMsg_IDBDatabaseCreateObjectStore_Params; 18 struct ViewHostMsg_IDBDatabaseCreateObjectStore_Params;
19 struct ViewHostMsg_IDBFactoryOpen_Params; 19 struct ViewHostMsg_IDBFactoryOpen_Params;
20 struct ViewHostMsg_IDBObjectStoreCreateIndex_Params; 20 struct ViewHostMsg_IDBObjectStoreCreateIndex_Params;
21 struct ViewHostMsg_IDBObjectStoreOpenCursor_Params; 21 struct ViewHostMsg_IDBObjectStoreOpenCursor_Params;
22 22
23 namespace WebKit { 23 namespace WebKit {
24 class WebIDBCursor; 24 class WebIDBCursor;
25 class WebIDBDatabase; 25 class WebIDBDatabase;
26 class WebIDBIndex; 26 class WebIDBIndex;
27 class WebIDBObjectStore; 27 class WebIDBObjectStore;
28 class WebIDBTransaction;
29 } 28 }
30 29
31 // Handles all IndexedDB related messages from a particular renderer process. 30 // Handles all IndexedDB related messages from a particular renderer process.
32 class IndexedDBDispatcherHost 31 class IndexedDBDispatcherHost
33 : public base::RefCountedThreadSafe<IndexedDBDispatcherHost> { 32 : public base::RefCountedThreadSafe<IndexedDBDispatcherHost> {
34 public: 33 public:
35 // Only call the constructor from the UI thread. 34 // Only call the constructor from the UI thread.
36 IndexedDBDispatcherHost(IPC::Message::Sender* sender, 35 IndexedDBDispatcherHost(IPC::Message::Sender* sender,
37 WebKitContext* webkit_context); 36 WebKitContext* webkit_context);
38 37
(...skipping 15 matching lines...) Expand all
54 IndexedDBContext* Context() { 53 IndexedDBContext* Context() {
55 return webkit_context_->indexed_db_context(); 54 return webkit_context_->indexed_db_context();
56 } 55 }
57 56
58 // The various IndexedDBCallbacks children call these methods to add the 57 // The various IndexedDBCallbacks children call these methods to add the
59 // results into the applicable map. See below for more details. 58 // results into the applicable map. See below for more details.
60 int32 Add(WebKit::WebIDBCursor* idb_cursor); 59 int32 Add(WebKit::WebIDBCursor* idb_cursor);
61 int32 Add(WebKit::WebIDBDatabase* idb_database); 60 int32 Add(WebKit::WebIDBDatabase* idb_database);
62 int32 Add(WebKit::WebIDBIndex* idb_index); 61 int32 Add(WebKit::WebIDBIndex* idb_index);
63 int32 Add(WebKit::WebIDBObjectStore* idb_object_store); 62 int32 Add(WebKit::WebIDBObjectStore* idb_object_store);
64 void Add(WebKit::WebIDBTransaction* idb_transaction);
65 63
66 private: 64 private:
67 friend class base::RefCountedThreadSafe<IndexedDBDispatcherHost>; 65 friend class base::RefCountedThreadSafe<IndexedDBDispatcherHost>;
68 ~IndexedDBDispatcherHost(); 66 ~IndexedDBDispatcherHost();
69 67
70 // Message processing. Most of the work is delegated to the dispatcher hosts 68 // Message processing. Most of the work is delegated to the dispatcher hosts
71 // below. 69 // below.
72 void OnMessageReceivedWebKit(const IPC::Message& message); 70 void OnMessageReceivedWebKit(const IPC::Message& message);
73 void OnIDBFactoryOpen(const ViewHostMsg_IDBFactoryOpen_Params& p); 71 void OnIDBFactoryOpen(const ViewHostMsg_IDBFactoryOpen_Params& p);
74 void OnIDBFactoryAbortPendingTransactions(const std::vector<int32>& ids);
75 72
76 // Helper templates. 73 // Helper templates.
77 template <class ReturnType> 74 template <class ReturnType>
78 ReturnType* GetOrTerminateProcess( 75 ReturnType* GetOrTerminateProcess(
79 IDMap<ReturnType, IDMapOwnPointer>* map, int32 return_object_id, 76 IDMap<ReturnType, IDMapOwnPointer>* map, int32 return_object_id,
80 IPC::Message* reply_msg, uint32 message_type); 77 IPC::Message* reply_msg, uint32 message_type);
81 78
82 template <typename ReplyType, typename MessageType, 79 template <typename ReplyType, typename MessageType,
83 typename WebObjectType, typename Method> 80 typename WebObjectType, typename Method>
84 void SyncGetter(IDMap<WebObjectType, IDMapOwnPointer>* map, int32 object_id, 81 void SyncGetter(IDMap<WebObjectType, IDMapOwnPointer>* map, int32 object_id,
(...skipping 14 matching lines...) Expand all
99 void OnName(int32 idb_database_id, IPC::Message* reply_msg); 96 void OnName(int32 idb_database_id, IPC::Message* reply_msg);
100 void OnDescription(int32 idb_database_id, IPC::Message* reply_msg); 97 void OnDescription(int32 idb_database_id, IPC::Message* reply_msg);
101 void OnVersion(int32 idb_database_id, IPC::Message* reply_msg); 98 void OnVersion(int32 idb_database_id, IPC::Message* reply_msg);
102 void OnObjectStores(int32 idb_database_id, IPC::Message* reply_msg); 99 void OnObjectStores(int32 idb_database_id, IPC::Message* reply_msg);
103 void OnCreateObjectStore( 100 void OnCreateObjectStore(
104 const ViewHostMsg_IDBDatabaseCreateObjectStore_Params& params); 101 const ViewHostMsg_IDBDatabaseCreateObjectStore_Params& params);
105 void OnObjectStore(int32 idb_database_id, const string16& name, int32 mode, 102 void OnObjectStore(int32 idb_database_id, const string16& name, int32 mode,
106 IPC::Message* reply_msg); 103 IPC::Message* reply_msg);
107 void OnRemoveObjectStore(int32 idb_database_id, int32 response_id, 104 void OnRemoveObjectStore(int32 idb_database_id, int32 response_id,
108 const string16& name); 105 const string16& name);
109 void OnTransaction(int32 idb_database_id,
110 const std::vector<string16>& names,
111 int32 mode, int32 timeout, IPC::Message* reply_msg);
112 void OnDestroyed(int32 idb_database_id); 106 void OnDestroyed(int32 idb_database_id);
113 107
114 IndexedDBDispatcherHost* parent_; 108 IndexedDBDispatcherHost* parent_;
115 IDMap<WebKit::WebIDBDatabase, IDMapOwnPointer> map_; 109 IDMap<WebKit::WebIDBDatabase, IDMapOwnPointer> map_;
116 }; 110 };
117 111
118 class IndexDispatcherHost { 112 class IndexDispatcherHost {
119 public: 113 public:
120 explicit IndexDispatcherHost(IndexedDBDispatcherHost* parent); 114 explicit IndexDispatcherHost(IndexedDBDispatcherHost* parent);
121 ~IndexDispatcherHost(); 115 ~IndexDispatcherHost();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 void OnOpenCursor( 167 void OnOpenCursor(
174 const ViewHostMsg_IDBObjectStoreOpenCursor_Params& params); 168 const ViewHostMsg_IDBObjectStoreOpenCursor_Params& params);
175 void OnDirection(int32 idb_object_store_id, IPC::Message* reply_msg); 169 void OnDirection(int32 idb_object_store_id, IPC::Message* reply_msg);
176 void OnKey(int32 idb_object_store_id, IPC::Message* reply_msg); 170 void OnKey(int32 idb_object_store_id, IPC::Message* reply_msg);
177 void OnValue(int32 idb_object_store_id, IPC::Message* reply_msg); 171 void OnValue(int32 idb_object_store_id, IPC::Message* reply_msg);
178 void OnDestroyed(int32 idb_cursor_id); 172 void OnDestroyed(int32 idb_cursor_id);
179 173
180 IndexedDBDispatcherHost* parent_; 174 IndexedDBDispatcherHost* parent_;
181 IDMap<WebKit::WebIDBCursor, IDMapOwnPointer> map_; 175 IDMap<WebKit::WebIDBCursor, IDMapOwnPointer> map_;
182 }; 176 };
183
184 class TransactionDispatcherHost {
185 public:
186 explicit TransactionDispatcherHost(IndexedDBDispatcherHost* parent);
187 ~TransactionDispatcherHost();
188
189 bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok);
190 void Send(IPC::Message* message);
191
192 // TODO: add the rest of the transaction methods.
193 void OnDestroyed(int32 idb_transaction_id);
194
195 IndexedDBDispatcherHost* parent_;
196 IDMap<WebKit::WebIDBTransaction, IDMapOwnPointer> map_;
197 };
198
199 // Only use on the IO thread. 177 // Only use on the IO thread.
200 IPC::Message::Sender* sender_; 178 IPC::Message::Sender* sender_;
201 179
202 // Data shared between renderer processes with the same profile. 180 // Data shared between renderer processes with the same profile.
203 scoped_refptr<WebKitContext> webkit_context_; 181 scoped_refptr<WebKitContext> webkit_context_;
204 182
205 // Only access on WebKit thread. 183 // Only access on WebKit thread.
206 scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_; 184 scoped_ptr<DatabaseDispatcherHost> database_dispatcher_host_;
207 scoped_ptr<IndexDispatcherHost> index_dispatcher_host_; 185 scoped_ptr<IndexDispatcherHost> index_dispatcher_host_;
208 scoped_ptr<ObjectStoreDispatcherHost> object_store_dispatcher_host_; 186 scoped_ptr<ObjectStoreDispatcherHost> object_store_dispatcher_host_;
209 scoped_ptr<CursorDispatcherHost> cursor_dispatcher_host_; 187 scoped_ptr<CursorDispatcherHost> cursor_dispatcher_host_;
210 scoped_ptr<TransactionDispatcherHost> transaction_dispatcher_host_;
211
212 188
213 // If we get a corrupt message from a renderer, we need to kill it using this 189 // If we get a corrupt message from a renderer, we need to kill it using this
214 // handle. 190 // handle.
215 base::ProcessHandle process_handle_; 191 base::ProcessHandle process_handle_;
216 192
217 // Used to dispatch messages to the correct view host. 193 // Used to dispatch messages to the correct view host.
218 int process_id_; 194 int process_id_;
219 195
220 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost); 196 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBDispatcherHost);
221 }; 197 };
222 198
223 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_ 199 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698