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

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: New version 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 int32 response_id, const std::vector<string16>& value) { 413 int32 response_id, const std::vector<string16>& value) {
412 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 414 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
413 WebDOMStringList string_list; 415 WebDOMStringList string_list;
414 for (std::vector<string16>::const_iterator it = value.begin(); 416 for (std::vector<string16>::const_iterator it = value.begin();
415 it != value.end(); ++it) 417 it != value.end(); ++it)
416 string_list.append(*it); 418 string_list.append(*it);
417 callbacks->onSuccess(string_list); 419 callbacks->onSuccess(string_list);
418 pending_callbacks_.Remove(response_id); 420 pending_callbacks_.Remove(response_id);
419 } 421 }
420 422
421 void IndexedDBDispatcher::OnSuccessSerializedScriptValue( 423 void IndexedDBDispatcher::OnSuccessSerializedScriptValue(
michaeln 2011/10/31 18:58:25 When the cursor hits the end, what should it's key
hans 2011/11/01 14:57:45 That's a good question. The spec only says that th
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
451 RendererWebIDBCursorImpl* cursor = cursors_[cursor_id];
michaeln 2011/10/31 18:58:25 DCHECK(cursor)
hans 2011/11/01 14:57:45 Done.
452 cursor->setKeyAndValue(key, primary_key, value);
453
454 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
455 callbacks->onSuccessCursorContinue();
456
457 pending_callbacks_.Remove(response_id);
458 }
459
438 void IndexedDBDispatcher::OnBlocked(int32 response_id) { 460 void IndexedDBDispatcher::OnBlocked(int32 response_id) {
439 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 461 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
440 callbacks->onBlocked(); 462 callbacks->onBlocked();
441 } 463 }
442 464
443 void IndexedDBDispatcher::OnError(int32 response_id, int code, 465 void IndexedDBDispatcher::OnError(int32 response_id, int code,
444 const string16& message) { 466 const string16& message) {
445 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); 467 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
446 callbacks->onError(WebIDBDatabaseError(code, message)); 468 callbacks->onError(WebIDBDatabaseError(code, message));
447 pending_callbacks_.Remove(response_id); 469 pending_callbacks_.Remove(response_id);
(...skipping 15 matching lines...) Expand all
463 485
464 void IndexedDBDispatcher::OnVersionChange(int32 database_id, 486 void IndexedDBDispatcher::OnVersionChange(int32 database_id,
465 const string16& newVersion) { 487 const string16& newVersion) {
466 WebIDBDatabaseCallbacks* callbacks = 488 WebIDBDatabaseCallbacks* callbacks =
467 pending_database_callbacks_.Lookup(database_id); 489 pending_database_callbacks_.Lookup(database_id);
468 // callbacks would be NULL if a versionchange event is received after close 490 // callbacks would be NULL if a versionchange event is received after close
469 // has been called. 491 // has been called.
470 if (callbacks) 492 if (callbacks)
471 callbacks->onVersionChange(newVersion); 493 callbacks->onVersionChange(newVersion);
472 } 494 }
495
496 void IndexedDBDispatcher::CursorDestroyed(int32 cursor_id) {
497 cursors_.erase(cursor_id);
498 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698