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

Side by Side Diff: content/child/indexed_db/indexed_db_dispatcher.cc

Issue 128623003: IndexedDB: Don't reset cursor prefetches on non-transactional calls (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/child/indexed_db/indexed_db_dispatcher.h" 5 #include "content/child/indexed_db/indexed_db_dispatcher.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/threading/thread_local.h" 10 #include "base/threading/thread_local.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 ipc_cursor_id, used_prefetches, unused_prefetches)); 212 ipc_cursor_id, used_prefetches, unused_prefetches));
213 } 213 }
214 214
215 void IndexedDBDispatcher::RequestIDBFactoryOpen( 215 void IndexedDBDispatcher::RequestIDBFactoryOpen(
216 const base::string16& name, 216 const base::string16& name,
217 int64 version, 217 int64 version,
218 int64 transaction_id, 218 int64 transaction_id,
219 WebIDBCallbacks* callbacks_ptr, 219 WebIDBCallbacks* callbacks_ptr,
220 WebIDBDatabaseCallbacks* database_callbacks_ptr, 220 WebIDBDatabaseCallbacks* database_callbacks_ptr,
221 const std::string& database_identifier) { 221 const std::string& database_identifier) {
222 ResetCursorPrefetchCaches();
223 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 222 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
224 scoped_ptr<WebIDBDatabaseCallbacks> database_callbacks( 223 scoped_ptr<WebIDBDatabaseCallbacks> database_callbacks(
225 database_callbacks_ptr); 224 database_callbacks_ptr);
226 225
227 IndexedDBHostMsg_FactoryOpen_Params params; 226 IndexedDBHostMsg_FactoryOpen_Params params;
228 params.ipc_thread_id = CurrentWorkerId(); 227 params.ipc_thread_id = CurrentWorkerId();
229 params.ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); 228 params.ipc_callbacks_id = pending_callbacks_.Add(callbacks.release());
230 params.ipc_database_callbacks_id = 229 params.ipc_database_callbacks_id =
231 pending_database_callbacks_.Add(database_callbacks.release()); 230 pending_database_callbacks_.Add(database_callbacks.release());
232 params.database_identifier = database_identifier; 231 params.database_identifier = database_identifier;
233 params.name = name; 232 params.name = name;
234 params.transaction_id = transaction_id; 233 params.transaction_id = transaction_id;
235 params.version = version; 234 params.version = version;
236 Send(new IndexedDBHostMsg_FactoryOpen(params)); 235 Send(new IndexedDBHostMsg_FactoryOpen(params));
237 } 236 }
238 237
239 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames( 238 void IndexedDBDispatcher::RequestIDBFactoryGetDatabaseNames(
240 WebIDBCallbacks* callbacks_ptr, 239 WebIDBCallbacks* callbacks_ptr,
241 const std::string& database_identifier) { 240 const std::string& database_identifier) {
242 ResetCursorPrefetchCaches();
243 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 241 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
244 242
245 IndexedDBHostMsg_FactoryGetDatabaseNames_Params params; 243 IndexedDBHostMsg_FactoryGetDatabaseNames_Params params;
246 params.ipc_thread_id = CurrentWorkerId(); 244 params.ipc_thread_id = CurrentWorkerId();
247 params.ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); 245 params.ipc_callbacks_id = pending_callbacks_.Add(callbacks.release());
248 params.database_identifier = database_identifier; 246 params.database_identifier = database_identifier;
249 Send(new IndexedDBHostMsg_FactoryGetDatabaseNames(params)); 247 Send(new IndexedDBHostMsg_FactoryGetDatabaseNames(params));
250 } 248 }
251 249
252 void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase( 250 void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase(
253 const base::string16& name, 251 const base::string16& name,
254 WebIDBCallbacks* callbacks_ptr, 252 WebIDBCallbacks* callbacks_ptr,
255 const std::string& database_identifier) { 253 const std::string& database_identifier) {
256 ResetCursorPrefetchCaches();
257 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 254 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
258 255
259 IndexedDBHostMsg_FactoryDeleteDatabase_Params params; 256 IndexedDBHostMsg_FactoryDeleteDatabase_Params params;
260 params.ipc_thread_id = CurrentWorkerId(); 257 params.ipc_thread_id = CurrentWorkerId();
261 params.ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); 258 params.ipc_callbacks_id = pending_callbacks_.Add(callbacks.release());
262 params.database_identifier = database_identifier; 259 params.database_identifier = database_identifier;
263 params.name = name; 260 params.name = name;
264 Send(new IndexedDBHostMsg_FactoryDeleteDatabase(params)); 261 Send(new IndexedDBHostMsg_FactoryDeleteDatabase(params));
265 } 262 }
266 263
267 void IndexedDBDispatcher::RequestIDBDatabaseClose( 264 void IndexedDBDispatcher::RequestIDBDatabaseClose(
268 int32 ipc_database_id, 265 int32 ipc_database_id,
269 int32 ipc_database_callbacks_id) { 266 int32 ipc_database_callbacks_id) {
270 ResetCursorPrefetchCaches();
271 Send(new IndexedDBHostMsg_DatabaseClose(ipc_database_id)); 267 Send(new IndexedDBHostMsg_DatabaseClose(ipc_database_id));
272 // There won't be pending database callbacks if the transaction was aborted in 268 // There won't be pending database callbacks if the transaction was aborted in
273 // the initial upgradeneeded event handler. 269 // the initial upgradeneeded event handler.
274 if (pending_database_callbacks_.Lookup(ipc_database_callbacks_id)) 270 if (pending_database_callbacks_.Lookup(ipc_database_callbacks_id))
275 pending_database_callbacks_.Remove(ipc_database_callbacks_id); 271 pending_database_callbacks_.Remove(ipc_database_callbacks_id);
276 } 272 }
277 273
278 void IndexedDBDispatcher::RequestIDBDatabaseCreateTransaction( 274 void IndexedDBDispatcher::RequestIDBDatabaseCreateTransaction(
279 int32 ipc_database_id, 275 int32 ipc_database_id,
280 int64 transaction_id, 276 int64 transaction_id,
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 pending_database_callbacks_.Lookup(ipc_database_callbacks_id); 707 pending_database_callbacks_.Lookup(ipc_database_callbacks_id);
712 // callbacks would be NULL if a versionchange event is received after close 708 // callbacks would be NULL if a versionchange event is received after close
713 // has been called. 709 // has been called.
714 if (!callbacks) 710 if (!callbacks)
715 return; 711 return;
716 callbacks->onVersionChange(old_version, new_version); 712 callbacks->onVersionChange(old_version, new_version);
717 } 713 }
718 714
719 void IndexedDBDispatcher::ResetCursorPrefetchCaches( 715 void IndexedDBDispatcher::ResetCursorPrefetchCaches(
720 int32 ipc_exception_cursor_id) { 716 int32 ipc_exception_cursor_id) {
717 // TODO(jsbell): Only reset cursors from the same transaction.
721 typedef std::map<int32, WebIDBCursorImpl*>::iterator Iterator; 718 typedef std::map<int32, WebIDBCursorImpl*>::iterator Iterator;
722 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { 719 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) {
723 if (i->first == ipc_exception_cursor_id) 720 if (i->first == ipc_exception_cursor_id)
724 continue; 721 continue;
725 i->second->ResetPrefetchCache(); 722 i->second->ResetPrefetchCache();
726 } 723 }
727 } 724 }
728 725
729 } // namespace content 726 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698