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