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/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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" | 10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 if (!transaction_dispatcher_host_.get()) { | 184 if (!transaction_dispatcher_host_.get()) { |
185 delete idb_transaction; | 185 delete idb_transaction; |
186 return 0; | 186 return 0; |
187 } | 187 } |
188 int32 id = transaction_dispatcher_host_->map_.Add(idb_transaction); | 188 int32 id = transaction_dispatcher_host_->map_.Add(idb_transaction); |
189 idb_transaction->setCallbacks(new IndexedDBTransactionCallbacks(this, id)); | 189 idb_transaction->setCallbacks(new IndexedDBTransactionCallbacks(this, id)); |
190 transaction_dispatcher_host_->transaction_url_map_[id] = url; | 190 transaction_dispatcher_host_->transaction_url_map_[id] = url; |
191 return id; | 191 return id; |
192 } | 192 } |
193 | 193 |
| 194 WebIDBCursor* IndexedDBDispatcherHost::GetCursorFromId(int32 cursor_id) { |
| 195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 196 return cursor_dispatcher_host_->map_.Lookup(cursor_id); |
| 197 } |
| 198 |
194 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( | 199 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( |
195 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) { | 200 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) { |
196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
197 FilePath base_path = webkit_context_->data_path(); | 202 FilePath base_path = webkit_context_->data_path(); |
198 FilePath indexed_db_path; | 203 FilePath indexed_db_path; |
199 if (!base_path.empty()) { | 204 if (!base_path.empty()) { |
200 indexed_db_path = base_path.Append( | 205 indexed_db_path = base_path.Append( |
201 IndexedDBContext::kIndexedDBDirectory); | 206 IndexedDBContext::kIndexedDBDirectory); |
202 } | 207 } |
203 | 208 |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 551 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
547 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 552 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
548 &map_, params.idb_index_id); | 553 &map_, params.idb_index_id); |
549 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 554 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
550 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); | 555 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); |
551 if (!idb_transaction || !idb_index) | 556 if (!idb_transaction || !idb_index) |
552 return; | 557 return; |
553 | 558 |
554 *ec = 0; | 559 *ec = 0; |
555 scoped_ptr<WebIDBCallbacks> callbacks( | 560 scoped_ptr<WebIDBCallbacks> callbacks( |
556 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id)); | 561 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id, -1)); |
557 idb_index->openObjectCursor( | 562 idb_index->openObjectCursor( |
558 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, | 563 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
559 params.upper_open), | 564 params.upper_open), |
560 params.direction, callbacks.release(), *idb_transaction, *ec); | 565 params.direction, callbacks.release(), *idb_transaction, *ec); |
561 } | 566 } |
562 | 567 |
563 void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenKeyCursor( | 568 void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenKeyCursor( |
564 const IndexedDBHostMsg_IndexOpenCursor_Params& params, | 569 const IndexedDBHostMsg_IndexOpenCursor_Params& params, |
565 WebKit::WebExceptionCode* ec) { | 570 WebKit::WebExceptionCode* ec) { |
566 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 571 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
567 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( | 572 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( |
568 &map_, params.idb_index_id); | 573 &map_, params.idb_index_id); |
569 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 574 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
570 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); | 575 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); |
571 if (!idb_transaction || !idb_index) | 576 if (!idb_transaction || !idb_index) |
572 return; | 577 return; |
573 | 578 |
574 *ec = 0; | 579 *ec = 0; |
575 scoped_ptr<WebIDBCallbacks> callbacks( | 580 scoped_ptr<WebIDBCallbacks> callbacks( |
576 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id)); | 581 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id, -1)); |
577 idb_index->openKeyCursor( | 582 idb_index->openKeyCursor( |
578 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, | 583 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
579 params.upper_open), | 584 params.upper_open), |
580 params.direction, callbacks.release(), *idb_transaction, *ec); | 585 params.direction, callbacks.release(), *idb_transaction, *ec); |
581 } | 586 } |
582 | 587 |
583 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject( | 588 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject( |
584 int idb_index_id, | 589 int idb_index_id, |
585 int32 response_id, | 590 int32 response_id, |
586 const IndexedDBKey& key, | 591 const IndexedDBKey& key, |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( | 842 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( |
838 &parent_->object_store_dispatcher_host_->map_, | 843 &parent_->object_store_dispatcher_host_->map_, |
839 params.idb_object_store_id); | 844 params.idb_object_store_id); |
840 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( | 845 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( |
841 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); | 846 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); |
842 if (!idb_transaction || !idb_object_store) | 847 if (!idb_transaction || !idb_object_store) |
843 return; | 848 return; |
844 | 849 |
845 *ec = 0; | 850 *ec = 0; |
846 scoped_ptr<WebIDBCallbacks> callbacks( | 851 scoped_ptr<WebIDBCallbacks> callbacks( |
847 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id)); | 852 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id, -1)); |
848 idb_object_store->openCursor( | 853 idb_object_store->openCursor( |
849 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, | 854 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, |
850 params.upper_open), | 855 params.upper_open), |
851 params.direction, callbacks.release(), *idb_transaction, *ec); | 856 params.direction, callbacks.release(), *idb_transaction, *ec); |
852 } | 857 } |
853 | 858 |
854 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDestroyed( | 859 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDestroyed( |
855 int32 object_id) { | 860 int32 object_id) { |
856 parent_->DestroyObject(&map_, object_id); | 861 parent_->DestroyObject(&map_, object_id); |
857 } | 862 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 int32 response_id, | 952 int32 response_id, |
948 const IndexedDBKey& key, | 953 const IndexedDBKey& key, |
949 WebKit::WebExceptionCode* ec) { | 954 WebKit::WebExceptionCode* ec) { |
950 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 955 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
951 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); | 956 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); |
952 if (!idb_cursor) | 957 if (!idb_cursor) |
953 return; | 958 return; |
954 | 959 |
955 *ec = 0; | 960 *ec = 0; |
956 idb_cursor->continueFunction( | 961 idb_cursor->continueFunction( |
957 key, new IndexedDBCallbacks<WebIDBCursor>(parent_, response_id), *ec); | 962 key, new IndexedDBCallbacks<WebIDBCursor>(parent_, response_id, |
| 963 cursor_id), *ec); |
958 } | 964 } |
959 | 965 |
960 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDelete( | 966 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDelete( |
961 int32 cursor_id, | 967 int32 cursor_id, |
962 int32 response_id, | 968 int32 response_id, |
963 WebKit::WebExceptionCode* ec) { | 969 WebKit::WebExceptionCode* ec) { |
964 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 970 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
965 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); | 971 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); |
966 if (!idb_cursor) | 972 if (!idb_cursor) |
967 return; | 973 return; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 } | 1073 } |
1068 idb_transaction->didCompleteTaskEvents(); | 1074 idb_transaction->didCompleteTaskEvents(); |
1069 } | 1075 } |
1070 | 1076 |
1071 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1077 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
1072 int32 object_id) { | 1078 int32 object_id) { |
1073 transaction_size_map_.erase(object_id); | 1079 transaction_size_map_.erase(object_id); |
1074 transaction_url_map_.erase(object_id); | 1080 transaction_url_map_.erase(object_id); |
1075 parent_->DestroyObject(&map_, object_id); | 1081 parent_->DestroyObject(&map_, object_id); |
1076 } | 1082 } |
OLD | NEW |