| 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" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 using WebKit::WebExceptionCode; | 41 using WebKit::WebExceptionCode; |
| 42 using WebKit::WebIDBCallbacks; | 42 using WebKit::WebIDBCallbacks; |
| 43 using WebKit::WebIDBCursor; | 43 using WebKit::WebIDBCursor; |
| 44 using WebKit::WebIDBDatabase; | 44 using WebKit::WebIDBDatabase; |
| 45 using WebKit::WebIDBDatabaseError; | 45 using WebKit::WebIDBDatabaseError; |
| 46 using WebKit::WebIDBIndex; | 46 using WebKit::WebIDBIndex; |
| 47 using WebKit::WebIDBKey; | 47 using WebKit::WebIDBKey; |
| 48 using WebKit::WebIDBMetadata; | 48 using WebKit::WebIDBMetadata; |
| 49 using WebKit::WebIDBObjectStore; | 49 using WebKit::WebIDBObjectStore; |
| 50 using WebKit::WebSecurityOrigin; | 50 using WebKit::WebSecurityOrigin; |
| 51 using WebKit::WebSerializedScriptValue; | |
| 52 using WebKit::WebVector; | 51 using WebKit::WebVector; |
| 53 | 52 |
| 54 namespace content { | 53 namespace content { |
| 55 namespace { | 54 namespace { |
| 56 | 55 |
| 57 template <class T> | 56 template <class T> |
| 58 void DeleteOnWebKitThread(T* obj) { | 57 void DeleteOnWebKitThread(T* obj) { |
| 59 if (!BrowserThread::DeleteSoon(BrowserThread::WEBKIT_DEPRECATED, | 58 if (!BrowserThread::DeleteSoon(BrowserThread::WEBKIT_DEPRECATED, |
| 60 FROM_HERE, obj)) | 59 FROM_HERE, obj)) |
| 61 delete obj; | 60 delete obj; |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 origin, NULL, webkit_base::FilePathToWebString(indexed_db_path)); | 267 origin, NULL, webkit_base::FilePathToWebString(indexed_db_path)); |
| 269 } | 268 } |
| 270 | 269 |
| 271 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( | 270 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( |
| 272 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { | 271 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { |
| 273 base::FilePath indexed_db_path = indexed_db_context_->data_path(); | 272 base::FilePath indexed_db_path = indexed_db_context_->data_path(); |
| 274 | 273 |
| 275 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 276 Context()->GetIDBFactory()->deleteDatabase( | 275 Context()->GetIDBFactory()->deleteDatabase( |
| 277 params.name, | 276 params.name, |
| 278 new IndexedDBCallbacks<WebSerializedScriptValue>(this, | 277 new IndexedDBCallbacks<WebData>(this, |
| 279 params.ipc_thread_id, | 278 params.ipc_thread_id, |
| 280 params.ipc_response_id), | 279 params.ipc_response_id), |
| 281 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin), NULL, | 280 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin), NULL, |
| 282 webkit_base::FilePathToWebString(indexed_db_path)); | 281 webkit_base::FilePathToWebString(indexed_db_path)); |
| 283 } | 282 } |
| 284 | 283 |
| 285 void IndexedDBDispatcherHost::FinishTransaction( | 284 void IndexedDBDispatcherHost::FinishTransaction( |
| 286 int64 host_transaction_id, bool committed) { | 285 int64 host_transaction_id, bool committed) { |
| 287 if (committed) | 286 if (committed) |
| 288 Context()->TransactionComplete( | 287 Context()->TransactionComplete( |
| 289 database_dispatcher_host_->transaction_url_map_[host_transaction_id]); | 288 database_dispatcher_host_->transaction_url_map_[host_transaction_id]); |
| 290 database_dispatcher_host_->transaction_url_map_.erase(host_transaction_id); | 289 database_dispatcher_host_->transaction_url_map_.erase(host_transaction_id); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 | 459 |
| 461 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGet( | 460 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGet( |
| 462 const IndexedDBHostMsg_DatabaseGet_Params& params) { | 461 const IndexedDBHostMsg_DatabaseGet_Params& params) { |
| 463 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 462 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 464 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 463 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| 465 &map_, params.ipc_database_id); | 464 &map_, params.ipc_database_id); |
| 466 if (!database) | 465 if (!database) |
| 467 return; | 466 return; |
| 468 | 467 |
| 469 scoped_ptr<WebIDBCallbacks> callbacks( | 468 scoped_ptr<WebIDBCallbacks> callbacks( |
| 470 new IndexedDBCallbacks<WebSerializedScriptValue>( | 469 new IndexedDBCallbacks<WebData>( |
| 471 parent_, params.ipc_thread_id, | 470 parent_, params.ipc_thread_id, |
| 472 params.ipc_response_id)); | 471 params.ipc_response_id)); |
| 473 database->get(parent_->HostTransactionId(params.transaction_id), | 472 database->get(parent_->HostTransactionId(params.transaction_id), |
| 474 params.object_store_id, | 473 params.object_store_id, |
| 475 params.index_id, | 474 params.index_id, |
| 476 params.key_range, params.key_only, callbacks.release()); | 475 params.key_range, params.key_only, callbacks.release()); |
| 477 } | 476 } |
| 478 | 477 |
| 479 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( | 478 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( |
| 480 const IndexedDBHostMsg_DatabasePut_Params& params) { | 479 const IndexedDBHostMsg_DatabasePut_Params& params) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 | 562 |
| 564 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCount( | 563 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCount( |
| 565 const IndexedDBHostMsg_DatabaseCount_Params& params) { | 564 const IndexedDBHostMsg_DatabaseCount_Params& params) { |
| 566 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 565 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 567 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 566 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| 568 &map_, params.ipc_database_id); | 567 &map_, params.ipc_database_id); |
| 569 if (!database) | 568 if (!database) |
| 570 return; | 569 return; |
| 571 | 570 |
| 572 scoped_ptr<WebIDBCallbacks> callbacks( | 571 scoped_ptr<WebIDBCallbacks> callbacks( |
| 573 new IndexedDBCallbacks<WebSerializedScriptValue>( | 572 new IndexedDBCallbacks<WebData>( |
| 574 parent_, params.ipc_thread_id, | 573 parent_, params.ipc_thread_id, |
| 575 params.ipc_response_id)); | 574 params.ipc_response_id)); |
| 576 database->count( | 575 database->count( |
| 577 parent_->HostTransactionId(params.transaction_id), | 576 parent_->HostTransactionId(params.transaction_id), |
| 578 params.object_store_id, params.index_id, | 577 params.object_store_id, params.index_id, |
| 579 params.key_range, callbacks.release()); | 578 params.key_range, callbacks.release()); |
| 580 } | 579 } |
| 581 | 580 |
| 582 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteRange( | 581 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteRange( |
| 583 const IndexedDBHostMsg_DatabaseDeleteRange_Params& params) { | 582 const IndexedDBHostMsg_DatabaseDeleteRange_Params& params) { |
| 584 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 583 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 585 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 584 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| 586 &map_, params.ipc_database_id); | 585 &map_, params.ipc_database_id); |
| 587 if (!database) | 586 if (!database) |
| 588 return; | 587 return; |
| 589 | 588 |
| 590 scoped_ptr<WebIDBCallbacks> callbacks( | 589 scoped_ptr<WebIDBCallbacks> callbacks( |
| 591 new IndexedDBCallbacks<WebSerializedScriptValue>( | 590 new IndexedDBCallbacks<WebData>( |
| 592 parent_, params.ipc_thread_id, | 591 parent_, params.ipc_thread_id, |
| 593 params.ipc_response_id)); | 592 params.ipc_response_id)); |
| 594 database->deleteRange(parent_->HostTransactionId(params.transaction_id), | 593 database->deleteRange(parent_->HostTransactionId(params.transaction_id), |
| 595 params.object_store_id, | 594 params.object_store_id, |
| 596 params.key_range, callbacks.release()); | 595 params.key_range, callbacks.release()); |
| 597 } | 596 } |
| 598 | 597 |
| 599 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClear( | 598 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClear( |
| 600 int32 ipc_thread_id, | 599 int32 ipc_thread_id, |
| 601 int32 ipc_response_id, | 600 int32 ipc_response_id, |
| 602 int32 ipc_database_id, | 601 int32 ipc_database_id, |
| 603 int64 transaction_id, | 602 int64 transaction_id, |
| 604 int64 object_store_id) { | 603 int64 object_store_id) { |
| 605 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 604 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 606 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 605 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
| 607 &map_, ipc_database_id); | 606 &map_, ipc_database_id); |
| 608 if (!database) | 607 if (!database) |
| 609 return; | 608 return; |
| 610 | 609 |
| 611 scoped_ptr<WebIDBCallbacks> callbacks( | 610 scoped_ptr<WebIDBCallbacks> callbacks( |
| 612 new IndexedDBCallbacks<WebSerializedScriptValue>( | 611 new IndexedDBCallbacks<WebData>( |
| 613 parent_, ipc_thread_id, | 612 parent_, ipc_thread_id, |
| 614 ipc_response_id)); | 613 ipc_response_id)); |
| 615 | 614 |
| 616 database->clear(parent_->HostTransactionId(transaction_id), | 615 database->clear(parent_->HostTransactionId(transaction_id), |
| 617 object_store_id, callbacks.release()); | 616 object_store_id, callbacks.release()); |
| 618 } | 617 } |
| 619 | 618 |
| 620 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnAbort( | 619 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnAbort( |
| 621 int32 ipc_database_id, | 620 int32 ipc_database_id, |
| 622 int64 transaction_id) { | 621 int64 transaction_id) { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 int32 ipc_thread_id, | 798 int32 ipc_thread_id, |
| 800 int32 ipc_response_id) { | 799 int32 ipc_response_id) { |
| 801 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 800 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
| 802 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, | 801 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, |
| 803 ipc_cursor_id); | 802 ipc_cursor_id); |
| 804 if (!idb_cursor) | 803 if (!idb_cursor) |
| 805 return; | 804 return; |
| 806 | 805 |
| 807 WebKit::WebExceptionCode ec = 0; | 806 WebKit::WebExceptionCode ec = 0; |
| 808 idb_cursor->deleteFunction( | 807 idb_cursor->deleteFunction( |
| 809 new IndexedDBCallbacks<WebSerializedScriptValue>(parent_, ipc_thread_id, | 808 new IndexedDBCallbacks<WebData>(parent_, ipc_thread_id, |
| 810 ipc_response_id), ec); | 809 ipc_response_id), ec); |
| 811 DCHECK(!ec); | 810 DCHECK(!ec); |
| 812 } | 811 } |
| 813 | 812 |
| 814 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 813 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
| 815 int32 ipc_object_id) { | 814 int32 ipc_object_id) { |
| 816 parent_->DestroyObject(&map_, ipc_object_id); | 815 parent_->DestroyObject(&map_, ipc_object_id); |
| 817 } | 816 } |
| 818 | 817 |
| 819 } // namespace content | 818 } // namespace content |
| OLD | NEW |