Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/browser/in_process_webkit/indexed_db_dispatcher_host.h" | 5 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/process.h" | 11 #include "base/process.h" |
| 12 #include "base/process_util.h" | 12 #include "base/process_util.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" | 14 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" |
| 15 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" | 15 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" |
| 16 #include "content/browser/in_process_webkit/indexed_db_database_callbacks.h" | 16 #include "content/browser/in_process_webkit/indexed_db_database_callbacks.h" |
| 17 #include "content/browser/renderer_host/render_message_filter.h" | 17 #include "content/browser/renderer_host/render_message_filter.h" |
| 18 #include "content/common/indexed_db/indexed_db_messages.h" | 18 #include "content/common/indexed_db/indexed_db_messages.h" |
| 19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/user_metrics.h" | 20 #include "content/public/browser/user_metrics.h" |
| 21 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
| 22 #include "content/public/common/result_codes.h" | 22 #include "content/public/common/result_codes.h" |
| 23 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
| 24 #include "third_party/WebKit/Source/Platform/chromium/public/WebData.h" | |
| 24 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" | 25 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" |
| 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMStringList.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMStringList.h" |
| 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" |
| 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" |
| 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbac ks.h" | 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseCallbac ks.h" |
| 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h " | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h " |
| 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseExcepti on.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseExcepti on.h" |
| 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" | 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" |
| 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBMetadata.h" | 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBMetadata.h" |
| 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 message, *msg_is_ok) | 336 message, *msg_is_ok) |
| 336 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, | 337 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, |
| 337 OnCreateObjectStore) | 338 OnCreateObjectStore) |
| 338 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, | 339 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, |
| 339 OnDeleteObjectStore) | 340 OnDeleteObjectStore) |
| 340 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction, | 341 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction, |
| 341 OnCreateTransaction) | 342 OnCreateTransaction) |
| 342 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) | 343 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) |
| 343 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) | 344 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) |
| 344 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet) | 345 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet) |
| 346 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePutOld, OnPutOld) | |
| 345 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPut) | 347 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPut) |
| 346 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexKeys, | 348 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexKeys, |
| 347 OnSetIndexKeys) | 349 OnSetIndexKeys) |
| 348 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexesReady, | 350 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexesReady, |
| 349 OnSetIndexesReady) | 351 OnSetIndexesReady) |
| 350 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpenCursor, OnOpenCursor) | 352 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpenCursor, OnOpenCursor) |
| 351 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCount, OnCount) | 353 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCount, OnCount) |
| 352 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteRange, OnDeleteRange) | 354 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteRange, OnDeleteRange) |
| 353 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClear, OnClear) | 355 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClear, OnClear) |
| 354 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateIndex, | 356 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateIndex, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 scoped_ptr<WebIDBCallbacks> callbacks( | 455 scoped_ptr<WebIDBCallbacks> callbacks( |
| 454 new IndexedDBCallbacks<WebSerializedScriptValue>( | 456 new IndexedDBCallbacks<WebSerializedScriptValue>( |
| 455 parent_, params.ipc_thread_id, | 457 parent_, params.ipc_thread_id, |
| 456 params.ipc_response_id)); | 458 params.ipc_response_id)); |
| 457 database->get(parent_->HostTransactionId(params.transaction_id), | 459 database->get(parent_->HostTransactionId(params.transaction_id), |
| 458 params.object_store_id, | 460 params.object_store_id, |
| 459 params.index_id, | 461 params.index_id, |
| 460 params.key_range, params.key_only, callbacks.release()); | 462 params.key_range, params.key_only, callbacks.release()); |
| 461 } | 463 } |
| 462 | 464 |
| 463 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( | 465 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPutOld( |
| 464 const IndexedDBHostMsg_DatabasePut_Params& params) { | 466 const IndexedDBHostMsg_DatabasePutOld_Params& params) { |
| 465 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 467 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 466 | 468 |
| 467 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 469 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| 468 &map_, params.ipc_database_id); | 470 &map_, params.ipc_database_id); |
| 469 if (!database) | 471 if (!database) |
| 470 return; | 472 return; |
| 471 scoped_ptr<WebIDBCallbacks> callbacks( | 473 scoped_ptr<WebIDBCallbacks> callbacks( |
| 472 new IndexedDBCallbacks<WebIDBKey>(parent_, params.ipc_thread_id, | 474 new IndexedDBCallbacks<WebIDBKey>(parent_, params.ipc_thread_id, |
| 473 params.ipc_response_id)); | 475 params.ipc_response_id)); |
| 474 | 476 |
| 475 WebVector<unsigned char> value(params.value); | 477 WebVector<unsigned char> value(params.value); |
| 476 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); | 478 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); |
| 477 database->put(host_transaction_id, | 479 database->put(host_transaction_id, |
| 478 params.object_store_id, | 480 params.object_store_id, |
| 479 &value, params.key, | 481 &value, params.key, |
| 480 params.put_mode, callbacks.release(), | 482 params.put_mode, callbacks.release(), |
| 481 params.index_ids, | 483 params.index_ids, |
| 482 params.index_keys); | 484 params.index_keys); |
| 483 WebIDBTransactionIDToSizeMap* map = | 485 WebIDBTransactionIDToSizeMap* map = |
| 484 &parent_->database_dispatcher_host_->transaction_size_map_; | 486 &parent_->database_dispatcher_host_->transaction_size_map_; |
| 485 // Size can't be big enough to overflow because it represents the | 487 // Size can't be big enough to overflow because it represents the |
| 486 // actual bytes passed through IPC. | 488 // actual bytes passed through IPC. |
| 487 (*map)[host_transaction_id] += params.value.size(); | 489 (*map)[host_transaction_id] += params.value.size(); |
| 488 } | 490 } |
| 489 | 491 |
| 492 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( | |
| 493 const IndexedDBHostMsg_DatabasePut_Params& params) { | |
| 494 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
| 495 | |
| 496 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | |
| 497 &map_, params.ipc_database_id); | |
| 498 if (!database) | |
| 499 return; | |
| 500 scoped_ptr<WebIDBCallbacks> callbacks( | |
| 501 new IndexedDBCallbacks<WebIDBKey>(parent_, params.ipc_thread_id, | |
| 502 params.ipc_response_id)); | |
| 503 | |
| 504 WebKit::WebData value(params.value); | |
|
jsbell
2013/02/07 00:06:07
In .cc files we typically add a "using" line near
| |
| 505 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); | |
| 506 database->put(host_transaction_id, | |
| 507 params.object_store_id, | |
| 508 value, params.key, | |
| 509 params.put_mode, callbacks.release(), | |
| 510 params.index_ids, | |
| 511 params.index_keys); | |
| 512 WebIDBTransactionIDToSizeMap* map = | |
| 513 &parent_->database_dispatcher_host_->transaction_size_map_; | |
| 514 // Size can't be big enough to overflow because it represents the | |
| 515 // actual bytes passed through IPC. | |
| 516 (*map)[host_transaction_id] += params.value.size(); | |
| 517 } | |
| 518 | |
| 490 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexKeys( | 519 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexKeys( |
| 491 const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params) { | 520 const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params) { |
| 492 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 521 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 493 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 522 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| 494 &map_, params.ipc_database_id); | 523 &map_, params.ipc_database_id); |
| 495 if (!database) | 524 if (!database) |
| 496 return; | 525 return; |
| 497 | 526 |
| 498 database->setIndexKeys(parent_->HostTransactionId(params.transaction_id), | 527 database->setIndexKeys(parent_->HostTransactionId(params.transaction_id), |
| 499 params.object_store_id, | 528 params.object_store_id, |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 785 ipc_response_id), ec); | 814 ipc_response_id), ec); |
| 786 DCHECK(!ec); | 815 DCHECK(!ec); |
| 787 } | 816 } |
| 788 | 817 |
| 789 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 818 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
| 790 int32 ipc_object_id) { | 819 int32 ipc_object_id) { |
| 791 parent_->DestroyObject(&map_, ipc_object_id); | 820 parent_->DestroyObject(&map_, ipc_object_id); |
| 792 } | 821 } |
| 793 | 822 |
| 794 } // namespace content | 823 } // namespace content |
| OLD | NEW |