Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: content/browser/in_process_webkit/indexed_db_dispatcher_host.cc

Issue 8400061: IndexedDB: Recycle cursor objects when calling continue(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Callback renamed to onSuccessWithContinuation, and style fixes Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 if (!transaction_dispatcher_host_.get()) { 183 if (!transaction_dispatcher_host_.get()) {
184 delete idb_transaction; 184 delete idb_transaction;
185 return 0; 185 return 0;
186 } 186 }
187 int32 id = transaction_dispatcher_host_->map_.Add(idb_transaction); 187 int32 id = transaction_dispatcher_host_->map_.Add(idb_transaction);
188 idb_transaction->setCallbacks(new IndexedDBTransactionCallbacks(this, id)); 188 idb_transaction->setCallbacks(new IndexedDBTransactionCallbacks(this, id));
189 transaction_dispatcher_host_->transaction_url_map_[id] = url; 189 transaction_dispatcher_host_->transaction_url_map_[id] = url;
190 return id; 190 return id;
191 } 191 }
192 192
193 WebIDBCursor* IndexedDBDispatcherHost::GetCursorFromId(int32 cursor_id) {
194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
195 return cursor_dispatcher_host_->map_.Lookup(cursor_id);
196 }
197
193 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( 198 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames(
194 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) { 199 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) {
195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 200 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
196 FilePath base_path = webkit_context_->data_path(); 201 FilePath base_path = webkit_context_->data_path();
197 FilePath indexed_db_path; 202 FilePath indexed_db_path;
198 if (!base_path.empty()) { 203 if (!base_path.empty()) {
199 indexed_db_path = base_path.Append( 204 indexed_db_path = base_path.Append(
200 IndexedDBContext::kIndexedDBDirectory); 205 IndexedDBContext::kIndexedDBDirectory);
201 } 206 }
202 207
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 550 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
546 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( 551 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess(
547 &map_, params.idb_index_id); 552 &map_, params.idb_index_id);
548 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( 553 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
549 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); 554 &parent_->transaction_dispatcher_host_->map_, params.transaction_id);
550 if (!idb_transaction || !idb_index) 555 if (!idb_transaction || !idb_index)
551 return; 556 return;
552 557
553 *ec = 0; 558 *ec = 0;
554 scoped_ptr<WebIDBCallbacks> callbacks( 559 scoped_ptr<WebIDBCallbacks> callbacks(
555 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id)); 560 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id, -1));
556 idb_index->openObjectCursor( 561 idb_index->openObjectCursor(
557 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, 562 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open,
558 params.upper_open), 563 params.upper_open),
559 params.direction, callbacks.release(), *idb_transaction, *ec); 564 params.direction, callbacks.release(), *idb_transaction, *ec);
560 } 565 }
561 566
562 void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenKeyCursor( 567 void IndexedDBDispatcherHost::IndexDispatcherHost::OnOpenKeyCursor(
563 const IndexedDBHostMsg_IndexOpenCursor_Params& params, 568 const IndexedDBHostMsg_IndexOpenCursor_Params& params,
564 WebKit::WebExceptionCode* ec) { 569 WebKit::WebExceptionCode* ec) {
565 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 570 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
566 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess( 571 WebIDBIndex* idb_index = parent_->GetOrTerminateProcess(
567 &map_, params.idb_index_id); 572 &map_, params.idb_index_id);
568 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( 573 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
569 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); 574 &parent_->transaction_dispatcher_host_->map_, params.transaction_id);
570 if (!idb_transaction || !idb_index) 575 if (!idb_transaction || !idb_index)
571 return; 576 return;
572 577
573 *ec = 0; 578 *ec = 0;
574 scoped_ptr<WebIDBCallbacks> callbacks( 579 scoped_ptr<WebIDBCallbacks> callbacks(
575 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id)); 580 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id, -1));
576 idb_index->openKeyCursor( 581 idb_index->openKeyCursor(
577 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, 582 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open,
578 params.upper_open), 583 params.upper_open),
579 params.direction, callbacks.release(), *idb_transaction, *ec); 584 params.direction, callbacks.release(), *idb_transaction, *ec);
580 } 585 }
581 586
582 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject( 587 void IndexedDBDispatcherHost::IndexDispatcherHost::OnGetObject(
583 int idb_index_id, 588 int idb_index_id,
584 int32 response_id, 589 int32 response_id,
585 const IndexedDBKey& key, 590 const IndexedDBKey& key,
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( 841 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess(
837 &parent_->object_store_dispatcher_host_->map_, 842 &parent_->object_store_dispatcher_host_->map_,
838 params.idb_object_store_id); 843 params.idb_object_store_id);
839 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( 844 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
840 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); 845 &parent_->transaction_dispatcher_host_->map_, params.transaction_id);
841 if (!idb_transaction || !idb_object_store) 846 if (!idb_transaction || !idb_object_store)
842 return; 847 return;
843 848
844 *ec = 0; 849 *ec = 0;
845 scoped_ptr<WebIDBCallbacks> callbacks( 850 scoped_ptr<WebIDBCallbacks> callbacks(
846 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id)); 851 new IndexedDBCallbacks<WebIDBCursor>(parent_, params.response_id, -1));
847 idb_object_store->openCursor( 852 idb_object_store->openCursor(
848 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open, 853 WebIDBKeyRange(params.lower_key, params.upper_key, params.lower_open,
849 params.upper_open), 854 params.upper_open),
850 params.direction, callbacks.release(), *idb_transaction, *ec); 855 params.direction, callbacks.release(), *idb_transaction, *ec);
851 } 856 }
852 857
853 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDestroyed( 858 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDestroyed(
854 int32 object_id) { 859 int32 object_id) {
855 parent_->DestroyObject(&map_, object_id); 860 parent_->DestroyObject(&map_, object_id);
856 } 861 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 int32 response_id, 951 int32 response_id,
947 const IndexedDBKey& key, 952 const IndexedDBKey& key,
948 WebKit::WebExceptionCode* ec) { 953 WebKit::WebExceptionCode* ec) {
949 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 954 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
950 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); 955 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id);
951 if (!idb_cursor) 956 if (!idb_cursor)
952 return; 957 return;
953 958
954 *ec = 0; 959 *ec = 0;
955 idb_cursor->continueFunction( 960 idb_cursor->continueFunction(
956 key, new IndexedDBCallbacks<WebIDBCursor>(parent_, response_id), *ec); 961 key, new IndexedDBCallbacks<WebIDBCursor>(parent_, response_id,
962 cursor_id), *ec);
957 } 963 }
958 964
959 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDelete( 965 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDelete(
960 int32 cursor_id, 966 int32 cursor_id,
961 int32 response_id, 967 int32 response_id,
962 WebKit::WebExceptionCode* ec) { 968 WebKit::WebExceptionCode* ec) {
963 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 969 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
964 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id); 970 WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, cursor_id);
965 if (!idb_cursor) 971 if (!idb_cursor)
966 return; 972 return;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 } 1072 }
1067 idb_transaction->didCompleteTaskEvents(); 1073 idb_transaction->didCompleteTaskEvents();
1068 } 1074 }
1069 1075
1070 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( 1076 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed(
1071 int32 object_id) { 1077 int32 object_id) {
1072 transaction_size_map_.erase(object_id); 1078 transaction_size_map_.erase(object_id);
1073 transaction_url_map_.erase(object_id); 1079 transaction_url_map_.erase(object_id);
1074 parent_->DestroyObject(&map_, object_id); 1080 parent_->DestroyObject(&map_, object_id);
1075 } 1081 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698