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

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

Issue 8400061: IndexedDB: Recycle cursor objects when calling continue(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Callback renamed to onSuccessWithContinuation, and style fixes Created 9 years, 1 month 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 24 matching lines...) Expand all
35 } 35 }
36 36
37 IndexedDBDispatcher::~IndexedDBDispatcher() { 37 IndexedDBDispatcher::~IndexedDBDispatcher() {
38 } 38 }
39 39
40 bool IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) { 40 bool IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) {
41 bool handled = true; 41 bool handled = true;
42 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg) 42 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcher, msg)
43 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBCursor, 43 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBCursor,
44 OnSuccessOpenCursor) 44 OnSuccessOpenCursor)
45 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessCursorContinue,
46 OnSuccessCursorContinue)
45 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBDatabase, 47 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBDatabase,
46 OnSuccessIDBDatabase) 48 OnSuccessIDBDatabase)
47 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey, 49 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIndexedDBKey,
48 OnSuccessIndexedDBKey) 50 OnSuccessIndexedDBKey)
49 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBTransaction, 51 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessIDBTransaction,
50 OnSuccessIDBTransaction) 52 OnSuccessIDBTransaction)
51 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessStringList, 53 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessStringList,
52 OnSuccessStringList) 54 OnSuccessStringList)
53 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessSerializedScriptValue, 55 IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessSerializedScriptValue,
54 OnSuccessSerializedScriptValue) 56 OnSuccessSerializedScriptValue)
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 } 421 }
420 422
421 void IndexedDBDispatcher::OnSuccessSerializedScriptValue( 423 void IndexedDBDispatcher::OnSuccessSerializedScriptValue(
422 int32 response_id, const content::SerializedScriptValue& value) { 424 int32 response_id, const content::SerializedScriptValue& value) {
423 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 425 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
424 callbacks->onSuccess(value); 426 callbacks->onSuccess(value);
425 pending_callbacks_.Remove(response_id); 427 pending_callbacks_.Remove(response_id);
426 } 428 }
427 429
428 void IndexedDBDispatcher::OnSuccessOpenCursor(int32 repsonse_id, 430 void IndexedDBDispatcher::OnSuccessOpenCursor(int32 repsonse_id,
429 int32 object_id, const IndexedDBKey& key, const IndexedDBKey& primaryKey, 431 int32 object_id, const IndexedDBKey& key, const IndexedDBKey& primary_key,
430 const content::SerializedScriptValue& value) { 432 const content::SerializedScriptValue& value) {
431 WebIDBCallbacks* callbacks = 433 WebIDBCallbacks* callbacks =
432 pending_callbacks_.Lookup(repsonse_id); 434 pending_callbacks_.Lookup(repsonse_id);
433 callbacks->onSuccess(new RendererWebIDBCursorImpl(object_id, key, 435
434 primaryKey, value)); 436 RendererWebIDBCursorImpl* cursor = new RendererWebIDBCursorImpl(object_id);
437 cursors_[object_id] = cursor;
438 cursor->SetKeyAndValue(key, primary_key, value);
439 callbacks->onSuccess(cursor);
440
435 pending_callbacks_.Remove(repsonse_id); 441 pending_callbacks_.Remove(repsonse_id);
436 } 442 }
437 443
444 void IndexedDBDispatcher::OnSuccessCursorContinue(
445 int32 response_id,
446 int32 cursor_id,
447 const IndexedDBKey& key,
448 const IndexedDBKey& primary_key,
449 const content::SerializedScriptValue& value) {
450
michaeln 2011/11/03 18:10:04 nit: blank line not needed
hans 2011/11/04 10:09:44 Done.
451 RendererWebIDBCursorImpl* cursor = cursors_[cursor_id];
452 DCHECK(cursor);
453 cursor->SetKeyAndValue(key, primary_key, value);
454
455 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
456 callbacks->onSuccessWithContinuation();
457
458 pending_callbacks_.Remove(response_id);
459 }
460
438 void IndexedDBDispatcher::OnBlocked(int32 response_id) { 461 void IndexedDBDispatcher::OnBlocked(int32 response_id) {
439 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 462 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
440 callbacks->onBlocked(); 463 callbacks->onBlocked();
441 } 464 }
442 465
443 void IndexedDBDispatcher::OnError(int32 response_id, int code, 466 void IndexedDBDispatcher::OnError(int32 response_id, int code,
444 const string16& message) { 467 const string16& message) {
445 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 468 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
446 callbacks->onError(WebIDBDatabaseError(code, message)); 469 callbacks->onError(WebIDBDatabaseError(code, message));
447 pending_callbacks_.Remove(response_id); 470 pending_callbacks_.Remove(response_id);
(...skipping 15 matching lines...) Expand all
463 486
464 void IndexedDBDispatcher::OnVersionChange(int32 database_id, 487 void IndexedDBDispatcher::OnVersionChange(int32 database_id,
465 const string16& newVersion) { 488 const string16& newVersion) {
466 WebIDBDatabaseCallbacks* callbacks = 489 WebIDBDatabaseCallbacks* callbacks =
467 pending_database_callbacks_.Lookup(database_id); 490 pending_database_callbacks_.Lookup(database_id);
468 // callbacks would be NULL if a versionchange event is received after close 491 // callbacks would be NULL if a versionchange event is received after close
469 // has been called. 492 // has been called.
470 if (callbacks) 493 if (callbacks)
471 callbacks->onVersionChange(newVersion); 494 callbacks->onVersionChange(newVersion);
472 } 495 }
496
497 void IndexedDBDispatcher::CursorDestroyed(int32 cursor_id) {
michaeln 2011/11/03 18:10:04 please move this to a position in the .cc file tha
hans 2011/11/04 10:09:44 Done.
498 cursors_.erase(cursor_id);
499 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698