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" |
34 #include "webkit/base/file_path_string_conversions.h" | 35 #include "webkit/base/file_path_string_conversions.h" |
35 #include "webkit/database/database_util.h" | 36 #include "webkit/database/database_util.h" |
36 | 37 |
37 using webkit_database::DatabaseUtil; | 38 using webkit_database::DatabaseUtil; |
38 using WebKit::WebDOMStringList; | 39 using WebKit::WebDOMStringList; |
| 40 using WebKit::WebData; |
39 using WebKit::WebExceptionCode; | 41 using WebKit::WebExceptionCode; |
40 using WebKit::WebIDBCallbacks; | 42 using WebKit::WebIDBCallbacks; |
41 using WebKit::WebIDBCursor; | 43 using WebKit::WebIDBCursor; |
42 using WebKit::WebIDBDatabase; | 44 using WebKit::WebIDBDatabase; |
43 using WebKit::WebIDBDatabaseError; | 45 using WebKit::WebIDBDatabaseError; |
44 using WebKit::WebIDBIndex; | 46 using WebKit::WebIDBIndex; |
45 using WebKit::WebIDBKey; | 47 using WebKit::WebIDBKey; |
46 using WebKit::WebIDBMetadata; | 48 using WebKit::WebIDBMetadata; |
47 using WebKit::WebIDBObjectStore; | 49 using WebKit::WebIDBObjectStore; |
48 using WebKit::WebSecurityOrigin; | 50 using WebKit::WebSecurityOrigin; |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 message, *msg_is_ok) | 341 message, *msg_is_ok) |
340 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, | 342 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, |
341 OnCreateObjectStore) | 343 OnCreateObjectStore) |
342 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, | 344 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, |
343 OnDeleteObjectStore) | 345 OnDeleteObjectStore) |
344 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction, | 346 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction, |
345 OnCreateTransaction) | 347 OnCreateTransaction) |
346 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) | 348 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) |
347 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) | 349 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) |
348 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet) | 350 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet) |
| 351 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePutOld, OnPutOld) |
349 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPut) | 352 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPut) |
350 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexKeys, | 353 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexKeys, |
351 OnSetIndexKeys) | 354 OnSetIndexKeys) |
352 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexesReady, | 355 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseSetIndexesReady, |
353 OnSetIndexesReady) | 356 OnSetIndexesReady) |
354 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpenCursor, OnOpenCursor) | 357 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseOpenCursor, OnOpenCursor) |
355 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCount, OnCount) | 358 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCount, OnCount) |
356 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteRange, OnDeleteRange) | 359 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteRange, OnDeleteRange) |
357 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClear, OnClear) | 360 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClear, OnClear) |
358 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateIndex, | 361 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateIndex, |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 scoped_ptr<WebIDBCallbacks> callbacks( | 460 scoped_ptr<WebIDBCallbacks> callbacks( |
458 new IndexedDBCallbacks<WebSerializedScriptValue>( | 461 new IndexedDBCallbacks<WebSerializedScriptValue>( |
459 parent_, params.ipc_thread_id, | 462 parent_, params.ipc_thread_id, |
460 params.ipc_response_id)); | 463 params.ipc_response_id)); |
461 database->get(parent_->HostTransactionId(params.transaction_id), | 464 database->get(parent_->HostTransactionId(params.transaction_id), |
462 params.object_store_id, | 465 params.object_store_id, |
463 params.index_id, | 466 params.index_id, |
464 params.key_range, params.key_only, callbacks.release()); | 467 params.key_range, params.key_only, callbacks.release()); |
465 } | 468 } |
466 | 469 |
467 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( | 470 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPutOld( |
468 const IndexedDBHostMsg_DatabasePut_Params& params) { | 471 const IndexedDBHostMsg_DatabasePutOld_Params& params) { |
469 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 472 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
470 | 473 |
471 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 474 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
472 &map_, params.ipc_database_id); | 475 &map_, params.ipc_database_id); |
473 if (!database) | 476 if (!database) |
474 return; | 477 return; |
475 scoped_ptr<WebIDBCallbacks> callbacks( | 478 scoped_ptr<WebIDBCallbacks> callbacks( |
476 new IndexedDBCallbacks<WebIDBKey>(parent_, params.ipc_thread_id, | 479 new IndexedDBCallbacks<WebIDBKey>(parent_, params.ipc_thread_id, |
477 params.ipc_response_id)); | 480 params.ipc_response_id)); |
478 if (params.index_ids.size() != params.index_keys.size()) { | 481 if (params.index_ids.size() != params.index_keys.size()) { |
(...skipping 11 matching lines...) Expand all Loading... |
490 params.put_mode, callbacks.release(), | 493 params.put_mode, callbacks.release(), |
491 params.index_ids, | 494 params.index_ids, |
492 params.index_keys); | 495 params.index_keys); |
493 TransactionIDToSizeMap* map = | 496 TransactionIDToSizeMap* map = |
494 &parent_->database_dispatcher_host_->transaction_size_map_; | 497 &parent_->database_dispatcher_host_->transaction_size_map_; |
495 // Size can't be big enough to overflow because it represents the | 498 // Size can't be big enough to overflow because it represents the |
496 // actual bytes passed through IPC. | 499 // actual bytes passed through IPC. |
497 (*map)[host_transaction_id] += params.value.size(); | 500 (*map)[host_transaction_id] += params.value.size(); |
498 } | 501 } |
499 | 502 |
| 503 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( |
| 504 const IndexedDBHostMsg_DatabasePut_Params& params) { |
| 505 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 506 |
| 507 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| 508 &map_, params.ipc_database_id); |
| 509 if (!database) |
| 510 return; |
| 511 scoped_ptr<WebIDBCallbacks> callbacks( |
| 512 new IndexedDBCallbacks<WebIDBKey>(parent_, params.ipc_thread_id, |
| 513 params.ipc_response_id)); |
| 514 // Be careful with empty vectors. |
| 515 WebData value; |
| 516 if (params.value.size()) |
| 517 value.assign(¶ms.value.front(), params.value.size()); |
| 518 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); |
| 519 database->put(host_transaction_id, |
| 520 params.object_store_id, |
| 521 value, params.key, |
| 522 params.put_mode, callbacks.release(), |
| 523 params.index_ids, |
| 524 params.index_keys); |
| 525 TransactionIDToSizeMap* map = |
| 526 &parent_->database_dispatcher_host_->transaction_size_map_; |
| 527 // Size can't be big enough to overflow because it represents the |
| 528 // actual bytes passed through IPC. |
| 529 (*map)[host_transaction_id] += params.value.size(); |
| 530 } |
| 531 |
500 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexKeys( | 532 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnSetIndexKeys( |
501 const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params) { | 533 const IndexedDBHostMsg_DatabaseSetIndexKeys_Params& params) { |
502 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 534 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
503 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 535 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
504 &map_, params.ipc_database_id); | 536 &map_, params.ipc_database_id); |
505 if (!database) | 537 if (!database) |
506 return; | 538 return; |
507 | 539 |
508 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); | 540 int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); |
509 if (params.index_ids.size() != params.index_keys.size()) { | 541 if (params.index_ids.size() != params.index_keys.size()) { |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 ipc_response_id), ec); | 834 ipc_response_id), ec); |
803 DCHECK(!ec); | 835 DCHECK(!ec); |
804 } | 836 } |
805 | 837 |
806 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 838 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
807 int32 ipc_object_id) { | 839 int32 ipc_object_id) { |
808 parent_->DestroyObject(&map_, ipc_object_id); | 840 parent_->DestroyObject(&map_, ipc_object_id); |
809 } | 841 } |
810 | 842 |
811 } // namespace content | 843 } // namespace content |
OLD | NEW |