| OLD | NEW |
| 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 Loading... |
| 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 if (*ec) | 374 if (*ec) |
| 373 pending_callbacks_.Remove(params.response_id); | 375 pending_callbacks_.Remove(params.response_id); |
| 374 } | 376 } |
| 375 | 377 |
| 376 void IndexedDBDispatcher::RegisterWebIDBTransactionCallbacks( | 378 void IndexedDBDispatcher::RegisterWebIDBTransactionCallbacks( |
| 377 WebIDBTransactionCallbacks* callbacks, | 379 WebIDBTransactionCallbacks* callbacks, |
| 378 int32 id) { | 380 int32 id) { |
| 379 pending_transaction_callbacks_.AddWithID(callbacks, id); | 381 pending_transaction_callbacks_.AddWithID(callbacks, id); |
| 380 } | 382 } |
| 381 | 383 |
| 384 void IndexedDBDispatcher::CursorDestroyed(int32 cursor_id) { |
| 385 cursors_.erase(cursor_id); |
| 386 } |
| 387 |
| 382 int32 IndexedDBDispatcher::TransactionId( | 388 int32 IndexedDBDispatcher::TransactionId( |
| 383 const WebIDBTransaction& transaction) { | 389 const WebIDBTransaction& transaction) { |
| 384 const RendererWebIDBTransactionImpl* impl = | 390 const RendererWebIDBTransactionImpl* impl = |
| 385 static_cast<const RendererWebIDBTransactionImpl*>(&transaction); | 391 static_cast<const RendererWebIDBTransactionImpl*>(&transaction); |
| 386 return impl->id(); | 392 return impl->id(); |
| 387 } | 393 } |
| 388 | 394 |
| 389 void IndexedDBDispatcher::OnSuccessIDBDatabase(int32 response_id, | 395 void IndexedDBDispatcher::OnSuccessIDBDatabase(int32 response_id, |
| 390 int32 object_id) { | 396 int32 object_id) { |
| 391 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 397 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 419 } | 425 } |
| 420 | 426 |
| 421 void IndexedDBDispatcher::OnSuccessSerializedScriptValue( | 427 void IndexedDBDispatcher::OnSuccessSerializedScriptValue( |
| 422 int32 response_id, const content::SerializedScriptValue& value) { | 428 int32 response_id, const content::SerializedScriptValue& value) { |
| 423 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 429 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
| 424 callbacks->onSuccess(value); | 430 callbacks->onSuccess(value); |
| 425 pending_callbacks_.Remove(response_id); | 431 pending_callbacks_.Remove(response_id); |
| 426 } | 432 } |
| 427 | 433 |
| 428 void IndexedDBDispatcher::OnSuccessOpenCursor(int32 repsonse_id, | 434 void IndexedDBDispatcher::OnSuccessOpenCursor(int32 repsonse_id, |
| 429 int32 object_id, const IndexedDBKey& key, const IndexedDBKey& primaryKey, | 435 int32 object_id, const IndexedDBKey& key, const IndexedDBKey& primary_key, |
| 430 const content::SerializedScriptValue& value) { | 436 const content::SerializedScriptValue& value) { |
| 431 WebIDBCallbacks* callbacks = | 437 WebIDBCallbacks* callbacks = |
| 432 pending_callbacks_.Lookup(repsonse_id); | 438 pending_callbacks_.Lookup(repsonse_id); |
| 433 callbacks->onSuccess(new RendererWebIDBCursorImpl(object_id, key, | 439 |
| 434 primaryKey, value)); | 440 RendererWebIDBCursorImpl* cursor = new RendererWebIDBCursorImpl(object_id); |
| 441 cursors_[object_id] = cursor; |
| 442 cursor->SetKeyAndValue(key, primary_key, value); |
| 443 callbacks->onSuccess(cursor); |
| 444 |
| 435 pending_callbacks_.Remove(repsonse_id); | 445 pending_callbacks_.Remove(repsonse_id); |
| 436 } | 446 } |
| 437 | 447 |
| 448 void IndexedDBDispatcher::OnSuccessCursorContinue( |
| 449 int32 response_id, |
| 450 int32 cursor_id, |
| 451 const IndexedDBKey& key, |
| 452 const IndexedDBKey& primary_key, |
| 453 const content::SerializedScriptValue& value) { |
| 454 RendererWebIDBCursorImpl* cursor = cursors_[cursor_id]; |
| 455 DCHECK(cursor); |
| 456 cursor->SetKeyAndValue(key, primary_key, value); |
| 457 |
| 458 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
| 459 callbacks->onSuccessWithContinuation(); |
| 460 |
| 461 pending_callbacks_.Remove(response_id); |
| 462 } |
| 463 |
| 438 void IndexedDBDispatcher::OnBlocked(int32 response_id) { | 464 void IndexedDBDispatcher::OnBlocked(int32 response_id) { |
| 439 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 465 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
| 440 callbacks->onBlocked(); | 466 callbacks->onBlocked(); |
| 441 } | 467 } |
| 442 | 468 |
| 443 void IndexedDBDispatcher::OnError(int32 response_id, int code, | 469 void IndexedDBDispatcher::OnError(int32 response_id, int code, |
| 444 const string16& message) { | 470 const string16& message) { |
| 445 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); | 471 WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); |
| 446 callbacks->onError(WebIDBDatabaseError(code, message)); | 472 callbacks->onError(WebIDBDatabaseError(code, message)); |
| 447 pending_callbacks_.Remove(response_id); | 473 pending_callbacks_.Remove(response_id); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 463 | 489 |
| 464 void IndexedDBDispatcher::OnVersionChange(int32 database_id, | 490 void IndexedDBDispatcher::OnVersionChange(int32 database_id, |
| 465 const string16& newVersion) { | 491 const string16& newVersion) { |
| 466 WebIDBDatabaseCallbacks* callbacks = | 492 WebIDBDatabaseCallbacks* callbacks = |
| 467 pending_database_callbacks_.Lookup(database_id); | 493 pending_database_callbacks_.Lookup(database_id); |
| 468 // callbacks would be NULL if a versionchange event is received after close | 494 // callbacks would be NULL if a versionchange event is received after close |
| 469 // has been called. | 495 // has been called. |
| 470 if (callbacks) | 496 if (callbacks) |
| 471 callbacks->onVersionChange(newVersion); | 497 callbacks->onVersionChange(newVersion); |
| 472 } | 498 } |
| OLD | NEW |