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

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

Issue 8747002: Dispatch IndexedDB IPC messages to worker threads (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: inject thread ids into ipcs 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
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 #include "content/renderer/indexed_db_dispatcher.h" 5 #include "content/renderer/indexed_db_dispatcher.h"
6 6
7 #include "content/common/indexed_db_messages.h" 7 #include "content/common/indexed_db_messages.h"
8 #include "content/renderer/render_thread_impl.h" 8 #include "content/renderer/render_thread_impl.h"
9 #include "content/renderer/render_view_impl.h" 9 #include "content/renderer/render_view_impl.h"
10 #include "content/renderer/renderer_webidbcursor_impl.h" 10 #include "content/renderer/renderer_webidbcursor_impl.h"
(...skipping 13 matching lines...) Expand all
24 using WebKit::WebExceptionCode; 24 using WebKit::WebExceptionCode;
25 using WebKit::WebFrame; 25 using WebKit::WebFrame;
26 using WebKit::WebIDBCallbacks; 26 using WebKit::WebIDBCallbacks;
27 using WebKit::WebIDBKeyRange; 27 using WebKit::WebIDBKeyRange;
28 using WebKit::WebIDBDatabase; 28 using WebKit::WebIDBDatabase;
29 using WebKit::WebIDBDatabaseCallbacks; 29 using WebKit::WebIDBDatabaseCallbacks;
30 using WebKit::WebIDBDatabaseError; 30 using WebKit::WebIDBDatabaseError;
31 using WebKit::WebIDBTransaction; 31 using WebKit::WebIDBTransaction;
32 using WebKit::WebIDBTransactionCallbacks; 32 using WebKit::WebIDBTransactionCallbacks;
33 33
34 IndexedDBDispatcher::IndexedDBDispatcher() { 34 IndexedDBDispatcher::IndexedDBDispatcher(IndexedDBMessageFilter* filter) :
35 pending_callbacks_(filter),
36 pending_transaction_callbacks_(filter),
37 pending_database_callbacks_(filter) {
35 } 38 }
36 39
37 IndexedDBDispatcher::~IndexedDBDispatcher() { 40 IndexedDBDispatcher::~IndexedDBDispatcher() {
38 } 41 }
39 42
40 bool IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) { 43 void IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) {
41 bool handled = true; 44 bool handled = true;
42 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg) 45 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg)
43 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBCursor, 46 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBCursor,
44 OnSuccessOpenCursor) 47 OnSuccessOpenCursor)
45 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorContinue, 48 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorContinue,
46 OnSuccessCursorContinue) 49 OnSuccessCursorContinue)
47 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBDatabase, 50 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBDatabase,
48 OnSuccessIDBDatabase) 51 OnSuccessIDBDatabase)
49 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey, 52 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey,
50 OnSuccessIndexedDBKey) 53 OnSuccessIndexedDBKey)
51 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBTransaction, 54 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBTransaction,
52 OnSuccessIDBTransaction) 55 OnSuccessIDBTransaction)
53 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessStringList, 56 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessStringList,
54 OnSuccessStringList) 57 OnSuccessStringList)
55 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessSerializedScriptValue, 58 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessSerializedScriptValue,
56 OnSuccessSerializedScriptValue) 59 OnSuccessSerializedScriptValue)
57 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksError, OnError) 60 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksError, OnError)
58 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksBlocked, OnBlocked) 61 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksBlocked, OnBlocked)
59 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksAbort, OnAbort) 62 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksAbort, OnAbort)
60 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksComplete, OnComplete) 63 IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksComplete, OnComplete)
61 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksVersionChange, 64 IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksVersionChange,
62 OnVersionChange) 65 OnVersionChange)
63 IPC_MESSAGE_UNHANDLED(handled = false) 66 IPC_MESSAGE_UNHANDLED(handled = false)
64 IPC_END_MESSAGE_MAP() 67 IPC_END_MESSAGE_MAP()
65 return handled; 68 // If a message gets here, IndexedDBMessageFilter already determined that it
69 // is an IndexedDB message.
70 DCHECK(handled);
66 } 71 }
67 72
68 void IndexedDBDispatcher::Send(IPC::Message* msg) { 73 void IndexedDBDispatcher::Send(IPC::Message* msg) {
69 ChildThread::current()->Send(msg); 74 ChildThread::current()->Send(msg);
70 } 75 }
71 76
72 void IndexedDBDispatcher::RequestIDBCursorUpdate( 77 void IndexedDBDispatcher::RequestIDBCursorUpdate(
73 const content::SerializedScriptValue& value, 78 const content::SerializedScriptValue& value,
74 WebIDBCallbacks* callbacks_ptr, 79 WebIDBCallbacks* callbacks_ptr,
75 int32 idb_cursor_id, 80 int32 idb_cursor_id,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 pending_callbacks_.Remove(response_id); 114 pending_callbacks_.Remove(response_id);
110 } 115 }
111 116
112 void IndexedDBDispatcher::RequestIDBFactoryOpen( 117 void IndexedDBDispatcher::RequestIDBFactoryOpen(
113 const string16& name, 118 const string16& name,
114 WebIDBCallbacks* callbacks_ptr, 119 WebIDBCallbacks* callbacks_ptr,
115 const string16& origin, 120 const string16& origin,
116 WebFrame* web_frame) { 121 WebFrame* web_frame) {
117 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 122 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
118 123
119 if (!web_frame)
michaeln 2011/12/01 21:42:05 does this no longer apply?
dgrogan 2011/12/01 22:49:00 This was to make the webkit side easier, so I didn
120 return; // We must be shutting down.
121 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view());
122 if (!render_view)
123 return; // We must be shutting down.
124
125 IndexedDBHostMsg_FactoryOpen_Params params; 124 IndexedDBHostMsg_FactoryOpen_Params params;
126 params.response_id = pending_callbacks_.Add(callbacks.release()); 125 params.response_id = pending_callbacks_.Add(callbacks.release());
127 params.origin = origin; 126 params.origin = origin;
128 params.name = name; 127 params.name = name;
129 Send(new IndexedDBHostMsg_FactoryOpen(params)); 128 Send(new IndexedDBHostMsg_FactoryOpen(params));
130 } 129 }
131 130
132 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames( 131 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames(
133 WebIDBCallbacks* callbacks_ptr, 132 WebIDBCallbacks* callbacks_ptr,
134 const string16& origin, 133 const string16& origin,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { 169 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) {
171 Send(new IndexedDBHostMsg_DatabaseClose(idb_database_id)); 170 Send(new IndexedDBHostMsg_DatabaseClose(idb_database_id));
172 pending_database_callbacks_.Remove(idb_database_id); 171 pending_database_callbacks_.Remove(idb_database_id);
173 } 172 }
174 173
175 void IndexedDBDispatcher::RequestIDBDatabaseOpen( 174 void IndexedDBDispatcher::RequestIDBDatabaseOpen(
176 WebIDBDatabaseCallbacks* callbacks_ptr, 175 WebIDBDatabaseCallbacks* callbacks_ptr,
177 int32 idb_database_id) { 176 int32 idb_database_id) {
178 scoped_ptr<WebIDBDatabaseCallbacks> callbacks(callbacks_ptr); 177 scoped_ptr<WebIDBDatabaseCallbacks> callbacks(callbacks_ptr);
179 178
180 int32 response_id = pending_database_callbacks_.Add(callbacks.release()); 179 pending_database_callbacks_.AddWithID(callbacks.release(), idb_database_id);
181 Send(new IndexedDBHostMsg_DatabaseOpen(response_id, idb_database_id)); 180 Send(new IndexedDBHostMsg_DatabaseOpen(idb_database_id, idb_database_id));
182 } 181 }
183 182
184 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion( 183 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion(
185 const string16& version, 184 const string16& version,
186 WebIDBCallbacks* callbacks_ptr, 185 WebIDBCallbacks* callbacks_ptr,
187 int32 idb_database_id, 186 int32 idb_database_id,
188 WebExceptionCode* ec) { 187 WebExceptionCode* ec) {
189 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 188 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
190 189
191 int32 response_id = pending_callbacks_.Add(callbacks.release()); 190 int32 response_id = pending_callbacks_.Add(callbacks.release());
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 void IndexedDBDispatcher::OnVersionChange(int32 database_id, 492 void IndexedDBDispatcher::OnVersionChange(int32 database_id,
494 const string16& newVersion) { 493 const string16& newVersion) {
495 WebIDBDatabaseCallbacks* callbacks = 494 WebIDBDatabaseCallbacks* callbacks =
496 pending_database_callbacks_.Lookup(database_id); 495 pending_database_callbacks_.Lookup(database_id);
497 // callbacks would be NULL if a versionchange event is received after close 496 // callbacks would be NULL if a versionchange event is received after close
498 // has been called. 497 // has been called.
499 if (!callbacks) 498 if (!callbacks)
500 return; 499 return;
501 callbacks->onVersionChange(newVersion); 500 callbacks->onVersionChange(newVersion);
502 } 501 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698