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

Side by Side Diff: content/common/indexed_db/indexed_db_dispatcher.cc

Issue 10917099: Chromium side of "consolidate two-phase connection to avoid race conditions". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Backwards compatible with current WK API Created 8 years, 3 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/common/indexed_db/indexed_db_dispatcher.h" 5 #include "content/common/indexed_db/indexed_db_dispatcher.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/threading/thread_local.h" 8 #include "base/threading/thread_local.h"
9 #include "content/common/child_thread.h" 9 #include "content/common/child_thread.h"
10 #include "content/common/indexed_db/indexed_db_messages.h" 10 #include "content/common/indexed_db/indexed_db_messages.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 ResetCursorPrefetchCaches(); 191 ResetCursorPrefetchCaches();
192 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 192 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
193 193
194 int32 response_id = pending_callbacks_.Add(callbacks.release()); 194 int32 response_id = pending_callbacks_.Add(callbacks.release());
195 Send(new IndexedDBHostMsg_CursorDelete(idb_cursor_id, CurrentWorkerId(), 195 Send(new IndexedDBHostMsg_CursorDelete(idb_cursor_id, CurrentWorkerId(),
196 response_id, ec)); 196 response_id, ec));
197 if (*ec) 197 if (*ec)
198 pending_callbacks_.Remove(response_id); 198 pending_callbacks_.Remove(response_id);
199 } 199 }
200 200
201 // TODO(jsbell): Remove this overload once WK90411 rolls.
201 void IndexedDBDispatcher::RequestIDBFactoryOpen( 202 void IndexedDBDispatcher::RequestIDBFactoryOpen(
202 const string16& name, 203 const string16& name,
203 int64 version, 204 int64 version,
204 WebIDBCallbacks* callbacks_ptr, 205 WebIDBCallbacks* callbacks_ptr,
205 const string16& origin, 206 const string16& origin,
206 WebFrame* web_frame) { 207 WebFrame* web_frame) {
207 ResetCursorPrefetchCaches(); 208 ResetCursorPrefetchCaches();
208 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 209 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
209 210
210 if (!CurrentWorkerId() && 211 if (!CurrentWorkerId() &&
211 !ChildThread::current()->IsWebFrameValid(web_frame)) 212 !ChildThread::current()->IsWebFrameValid(web_frame))
212 return; 213 return;
213 214
214 IndexedDBHostMsg_FactoryOpen_Params params; 215 IndexedDBHostMsg_FactoryOpen_Params params;
215 params.thread_id = CurrentWorkerId(); 216 params.thread_id = CurrentWorkerId();
216 params.response_id = pending_callbacks_.Add(callbacks.release()); 217 params.response_id = pending_callbacks_.Add(callbacks.release());
218 params.database_response_id = 0; // Unused in this message.
217 params.origin = origin; 219 params.origin = origin;
218 params.name = name; 220 params.name = name;
219 params.version = version; 221 params.version = version;
222 Send(new IndexedDBHostMsg_FactoryOpenLegacy(params));
223 }
224
225 void IndexedDBDispatcher::RequestIDBFactoryOpen(
226 const string16& name,
227 int64 version,
228 WebIDBCallbacks* callbacks_ptr,
229 WebIDBDatabaseCallbacks* database_callbacks_ptr,
230 const string16& origin,
231 WebFrame* web_frame) {
232 ResetCursorPrefetchCaches();
233 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
234 scoped_ptr<WebIDBDatabaseCallbacks>
235 database_callbacks(database_callbacks_ptr);
236
237 if (!CurrentWorkerId() &&
238 !ChildThread::current()->IsWebFrameValid(web_frame))
239 return;
240
241 IndexedDBHostMsg_FactoryOpen_Params params;
242 params.thread_id = CurrentWorkerId();
243 params.response_id = pending_callbacks_.Add(callbacks.release());
244 params.database_response_id = pending_database_callbacks_.Add(
245 database_callbacks.release());
246 params.origin = origin;
247 params.name = name;
248 params.version = version;
220 Send(new IndexedDBHostMsg_FactoryOpen(params)); 249 Send(new IndexedDBHostMsg_FactoryOpen(params));
221 } 250 }
222 251
223 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames( 252 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames(
224 WebIDBCallbacks* callbacks_ptr, 253 WebIDBCallbacks* callbacks_ptr,
225 const string16& origin, 254 const string16& origin,
226 WebFrame* web_frame) { 255 WebFrame* web_frame) {
227 ResetCursorPrefetchCaches(); 256 ResetCursorPrefetchCaches();
228 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 257 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
229 258
(...skipping 30 matching lines...) Expand all
260 289
261 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { 290 void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) {
262 ResetCursorPrefetchCaches(); 291 ResetCursorPrefetchCaches();
263 Send(new IndexedDBHostMsg_DatabaseClose(idb_database_id)); 292 Send(new IndexedDBHostMsg_DatabaseClose(idb_database_id));
264 // There won't be pending database callbacks if the transaction was aborted in 293 // There won't be pending database callbacks if the transaction was aborted in
265 // the initial upgradeneeded event handler. 294 // the initial upgradeneeded event handler.
266 if (pending_database_callbacks_.Lookup(idb_database_id)) 295 if (pending_database_callbacks_.Lookup(idb_database_id))
267 pending_database_callbacks_.Remove(idb_database_id); 296 pending_database_callbacks_.Remove(idb_database_id);
268 } 297 }
269 298
299 // TODO(jsbell): Remove once WK90411 has rolled.
270 void IndexedDBDispatcher::RequestIDBDatabaseOpen( 300 void IndexedDBDispatcher::RequestIDBDatabaseOpen(
271 WebIDBDatabaseCallbacks* callbacks_ptr, 301 WebIDBDatabaseCallbacks* callbacks_ptr,
272 int32 idb_database_id) { 302 int32 idb_database_id) {
273 ResetCursorPrefetchCaches(); 303 ResetCursorPrefetchCaches();
274 scoped_ptr<WebIDBDatabaseCallbacks> callbacks(callbacks_ptr); 304 scoped_ptr<WebIDBDatabaseCallbacks> callbacks(callbacks_ptr);
275 305
276 DCHECK(!pending_database_callbacks_.Lookup(idb_database_id)); 306 DCHECK(!pending_database_callbacks_.Lookup(idb_database_id));
277 pending_database_callbacks_.AddWithID(callbacks.release(), idb_database_id); 307 pending_database_callbacks_.AddWithID(callbacks.release(), idb_database_id);
278 Send(new IndexedDBHostMsg_DatabaseOpen(idb_database_id, CurrentWorkerId(), 308 Send(new IndexedDBHostMsg_DatabaseOpen(idb_database_id, CurrentWorkerId(),
279 idb_database_id)); 309 idb_database_id));
280 } 310 }
281 311
282 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion( 312 void IndexedDBDispatcher::RequestIDBDatabaseSetVersion(
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 } 800 }
771 801
772 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { 802 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) {
773 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; 803 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator;
774 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { 804 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) {
775 if (i->first == exception_cursor_id) 805 if (i->first == exception_cursor_id)
776 continue; 806 continue;
777 i->second->ResetPrefetchCache(); 807 i->second->ResetPrefetchCache();
778 } 808 }
779 } 809 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698