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

Side by Side Diff: content/renderer/indexed_db_dispatcher.h

Issue 8747002: Dispatch IndexedDB IPC messages to worker threads (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove OVERRIDE from dtor Created 9 years 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
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/indexed_db_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_RENDERER_INDEXED_DB_DISPATCHER_H_ 5 #ifndef CONTENT_RENDERER_INDEXED_DB_DISPATCHER_H_
6 #define CONTENT_RENDERER_INDEXED_DB_DISPATCHER_H_ 6 #define CONTENT_RENDERER_INDEXED_DB_DISPATCHER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/id_map.h" 12 #include "base/id_map.h"
13 #include "base/nullable_string16.h" 13 #include "base/nullable_string16.h"
14 #include "ipc/ipc_channel.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebExceptionCode.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebExceptionCode.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbac ks.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransactionCall backs.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransactionCall backs.h"
20 #include "webkit/glue/worker_task_runner.h"
20 21
21 class IndexedDBKey; 22 class IndexedDBKey;
23 struct IndexedDBMsg_CallbacksSuccessCursorContinue_Params;
24 struct IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params;
25 struct IndexedDBMsg_CallbacksSuccessIDBCursor_Params;
22 class RendererWebIDBCursorImpl; 26 class RendererWebIDBCursorImpl;
23 27
28 namespace IPC {
29 class Message;
30 }
31
24 namespace WebKit { 32 namespace WebKit {
25 class WebFrame; 33 class WebFrame;
26 class WebIDBKeyRange; 34 class WebIDBKeyRange;
27 class WebIDBTransaction; 35 class WebIDBTransaction;
28 } 36 }
29 37
30 namespace content { 38 namespace content {
31 class SerializedScriptValue; 39 class SerializedScriptValue;
32 } 40 }
33 41
34 // Handle the indexed db related communication for this entire renderer. 42 // Handle the indexed db related communication for this context thread - the
35 class IndexedDBDispatcher : public IPC::Channel::Listener { 43 // main thread and each worker thread have their own copies.
44 class IndexedDBDispatcher : public webkit_glue::WorkerTaskRunner::Observer {
36 public: 45 public:
37 IndexedDBDispatcher();
38 virtual ~IndexedDBDispatcher(); 46 virtual ~IndexedDBDispatcher();
47 static IndexedDBDispatcher* ThreadSpecificInstance();
39 48
40 // IPC::Channel::Listener implementation. 49 // webkit_glue::WorkerTaskRunner::Observer implementation.
41 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 50 virtual void OnWorkerRunLoopStopped() OVERRIDE;
51
52 void OnMessageReceived(const IPC::Message& msg);
42 void Send(IPC::Message* msg); 53 void Send(IPC::Message* msg);
43 54
44 void RequestIDBFactoryGetDatabaseNames( 55 void RequestIDBFactoryGetDatabaseNames(
45 WebKit::WebIDBCallbacks* callbacks, 56 WebKit::WebIDBCallbacks* callbacks,
46 const string16& origin, 57 const string16& origin,
47 WebKit::WebFrame* web_frame); 58 WebKit::WebFrame* web_frame);
48 59
49 void RequestIDBFactoryOpen( 60 void RequestIDBFactoryOpen(
50 const string16& name, 61 const string16& name,
51 WebKit::WebIDBCallbacks* callbacks, 62 WebKit::WebIDBCallbacks* callbacks,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 173
163 void RegisterWebIDBTransactionCallbacks( 174 void RegisterWebIDBTransactionCallbacks(
164 WebKit::WebIDBTransactionCallbacks* callbacks, 175 WebKit::WebIDBTransactionCallbacks* callbacks,
165 int32 id); 176 int32 id);
166 177
167 void CursorDestroyed(int32 cursor_id); 178 void CursorDestroyed(int32 cursor_id);
168 179
169 static int32 TransactionId(const WebKit::WebIDBTransaction& transaction); 180 static int32 TransactionId(const WebKit::WebIDBTransaction& transaction);
170 181
171 private: 182 private:
183 IndexedDBDispatcher();
172 // IDBCallback message handlers. 184 // IDBCallback message handlers.
173 void OnSuccessNull(int32 response_id); 185 void OnSuccessNull(int32 response_id);
174 void OnSuccessIDBDatabase(int32 response_id, int32 object_id); 186 void OnSuccessIDBDatabase(int32 thread_id,
175 void OnSuccessIndexedDBKey(int32 response_id, const IndexedDBKey& key); 187 int32 response_id,
176 void OnSuccessIDBTransaction(int32 response_id, int32 object_id); 188 int32 object_id);
177 void OnSuccessOpenCursor(int32 response_id, int32 object_id, 189 void OnSuccessIndexedDBKey(int32 thread_id,
178 const IndexedDBKey& key, 190 int32 response_id,
179 const IndexedDBKey& primary_key, 191 const IndexedDBKey& key);
180 const content::SerializedScriptValue& value); 192 void OnSuccessIDBTransaction(int32 thread_id,
181 void OnSuccessCursorContinue(int32 response_id, 193 int32 response_id,
182 int32 cursor_id, 194 int32 object_id);
183 const IndexedDBKey& key, 195 void OnSuccessOpenCursor(
184 const IndexedDBKey& primary_key, 196 const IndexedDBMsg_CallbacksSuccessIDBCursor_Params& p);
185 const content::SerializedScriptValue& value); 197 void OnSuccessCursorContinue(
198 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p);
186 void OnSuccessCursorPrefetch( 199 void OnSuccessCursorPrefetch(
187 int32 response_id, 200 const IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params& p);
188 int32 cursor_id, 201 void OnSuccessStringList(int32 thread_id,
189 const std::vector<IndexedDBKey>& keys, 202 int32 response_id,
190 const std::vector<IndexedDBKey>& primary_keys,
191 const std::vector<content::SerializedScriptValue>& values);
192 void OnSuccessStringList(int32 response_id,
193 const std::vector<string16>& value); 203 const std::vector<string16>& value);
194 void OnSuccessSerializedScriptValue( 204 void OnSuccessSerializedScriptValue(
205 int32 thread_id,
195 int32 response_id, 206 int32 response_id,
196 const content::SerializedScriptValue& value); 207 const content::SerializedScriptValue& value);
197 void OnError(int32 response_id, int code, const string16& message); 208 void OnError(int32 thread_id,
198 void OnBlocked(int32 response_id); 209 int32 response_id,
199 void OnAbort(int32 transaction_id); 210 int code,
200 void OnComplete(int32 transaction_id); 211 const string16& message);
201 void OnVersionChange(int32 database_id, const string16& newVersion); 212 void OnBlocked(int32 thread_id, int32 response_id);
213 void OnAbort(int32 thread_id, int32 transaction_id);
214 void OnComplete(int32 thread_id, int32 transaction_id);
215 void OnVersionChange(int32 thread_id,
216 int32 database_id,
217 const string16& newVersion);
202 218
203 // Reset cursor prefetch caches for all cursors except exception_cursor_id. 219 // Reset cursor prefetch caches for all cursors except exception_cursor_id.
204 void ResetCursorPrefetchCaches(int32 exception_cursor_id = -1); 220 void ResetCursorPrefetchCaches(int32 exception_cursor_id = -1);
205 221
206 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be 222 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be
207 // destroyed and used on the same thread it was created on. 223 // destroyed and used on the same thread it was created on.
208 IDMap<WebKit::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; 224 IDMap<WebKit::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_;
209 IDMap<WebKit::WebIDBTransactionCallbacks, IDMapOwnPointer> 225 IDMap<WebKit::WebIDBTransactionCallbacks, IDMapOwnPointer>
210 pending_transaction_callbacks_; 226 pending_transaction_callbacks_;
211 IDMap<WebKit::WebIDBDatabaseCallbacks, IDMapOwnPointer> 227 IDMap<WebKit::WebIDBDatabaseCallbacks, IDMapOwnPointer>
212 pending_database_callbacks_; 228 pending_database_callbacks_;
213 229
214 // Map from cursor id to RendererWebIDBCursorImpl. 230 // Map from cursor id to RendererWebIDBCursorImpl.
215 std::map<int32, RendererWebIDBCursorImpl*> cursors_; 231 std::map<int32, RendererWebIDBCursorImpl*> cursors_;
216 232
217 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); 233 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher);
218 }; 234 };
219 235
220 #endif // CONTENT_RENDERER_INDEXED_DB_DISPATCHER_H_ 236 #endif // CONTENT_RENDERER_INDEXED_DB_DISPATCHER_H_
OLDNEW
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/indexed_db_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698