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

Side by Side Diff: content/common/indexed_db/proxy_webidbcursor_impl.cc

Issue 9691021: IndexedDB: Fix prefetching; cache was always being bypassed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix memory leak Created 8 years, 9 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 (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/common/indexed_db/proxy_webidbcursor_impl.h" 5 #include "content/common/indexed_db/proxy_webidbcursor_impl.h"
6 6
7 #include "content/common/child_thread.h" 7 #include "content/common/child_thread.h"
8 #include "content/common/indexed_db/indexed_db_messages.h" 8 #include "content/common/indexed_db/indexed_db_messages.h"
9 #include "content/common/indexed_db/indexed_db_dispatcher.h" 9 #include "content/common/indexed_db/indexed_db_dispatcher.h"
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 void RendererWebIDBCursorImpl::update(const WebSerializedScriptValue& value, 55 void RendererWebIDBCursorImpl::update(const WebSerializedScriptValue& value,
56 WebIDBCallbacks* callbacks, 56 WebIDBCallbacks* callbacks,
57 WebExceptionCode& ec) { 57 WebExceptionCode& ec) {
58 IndexedDBDispatcher* dispatcher = 58 IndexedDBDispatcher* dispatcher =
59 IndexedDBDispatcher::ThreadSpecificInstance(); 59 IndexedDBDispatcher::ThreadSpecificInstance();
60 dispatcher->RequestIDBCursorUpdate( 60 dispatcher->RequestIDBCursorUpdate(
61 content::SerializedScriptValue(value), callbacks, idb_cursor_id_, &ec); 61 content::SerializedScriptValue(value), callbacks, idb_cursor_id_, &ec);
62 } 62 }
63 63
64 void RendererWebIDBCursorImpl::continueFunction(const WebIDBKey& key, 64 void RendererWebIDBCursorImpl::continueFunction(const WebIDBKey& key,
65 WebIDBCallbacks* callbacks, 65 WebIDBCallbacks* callbacks_ptr,
66 WebExceptionCode& ec) { 66 WebExceptionCode& ec) {
67 IndexedDBDispatcher* dispatcher = 67 IndexedDBDispatcher* dispatcher =
68 IndexedDBDispatcher::ThreadSpecificInstance(); 68 IndexedDBDispatcher::ThreadSpecificInstance();
69 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
michaeln 2012/03/17 02:44:46 lgtm
69 70
70 if (key.type() == WebIDBKey::InvalidType) { 71 if (key.type() == WebIDBKey::NullType) {
71 // No key, so this would qualify for a prefetch. 72 // No key, so this would qualify for a prefetch.
72 ++continue_count_; 73 ++continue_count_;
73 74
74 if (!prefetch_keys_.empty()) { 75 if (!prefetch_keys_.empty()) {
75 // We have a prefetch cache, so serve the result from that. 76 // We have a prefetch cache, so serve the result from that.
76 CachedContinue(callbacks); 77 CachedContinue(callbacks.get());
77 return; 78 return;
78 } 79 }
79 80
80 if (continue_count_ > kPrefetchContinueThreshold) { 81 if (continue_count_ > kPrefetchContinueThreshold) {
81 // Request pre-fetch. 82 // Request pre-fetch.
82 dispatcher->RequestIDBCursorPrefetch(prefetch_amount_, callbacks, 83 dispatcher->RequestIDBCursorPrefetch(prefetch_amount_,
84 callbacks.release(),
83 idb_cursor_id_, &ec); 85 idb_cursor_id_, &ec);
84 86
85 // Increase prefetch_amount_ exponentially. 87 // Increase prefetch_amount_ exponentially.
86 prefetch_amount_ *= 2; 88 prefetch_amount_ *= 2;
87 if (prefetch_amount_ > kMaxPrefetchAmount) 89 if (prefetch_amount_ > kMaxPrefetchAmount)
88 prefetch_amount_ = kMaxPrefetchAmount; 90 prefetch_amount_ = kMaxPrefetchAmount;
89 91
90 return; 92 return;
91 } 93 }
92 } else { 94 } else {
93 // Key argument supplied. We couldn't prefetch this. 95 // Key argument supplied. We couldn't prefetch this.
94 ResetPrefetchCache(); 96 ResetPrefetchCache();
95 } 97 }
96 98
97 dispatcher->RequestIDBCursorContinue(IndexedDBKey(key), callbacks, 99 dispatcher->RequestIDBCursorContinue(IndexedDBKey(key), callbacks.release(),
98 idb_cursor_id_, &ec); 100 idb_cursor_id_, &ec);
99 } 101 }
100 102
101 void RendererWebIDBCursorImpl::deleteFunction(WebIDBCallbacks* callbacks, 103 void RendererWebIDBCursorImpl::deleteFunction(WebIDBCallbacks* callbacks,
102 WebExceptionCode& ec) { 104 WebExceptionCode& ec) {
103 IndexedDBDispatcher* dispatcher = 105 IndexedDBDispatcher* dispatcher =
104 IndexedDBDispatcher::ThreadSpecificInstance(); 106 IndexedDBDispatcher::ThreadSpecificInstance();
105 dispatcher->RequestIDBCursorDelete(callbacks, idb_cursor_id_, &ec); 107 dispatcher->RequestIDBCursorDelete(callbacks, idb_cursor_id_, &ec);
106 } 108 }
107 109
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 IndexedDBDispatcher::ThreadSpecificInstance(); 174 IndexedDBDispatcher::ThreadSpecificInstance();
173 dispatcher->RequestIDBCursorPrefetchReset(used_prefetches_, 175 dispatcher->RequestIDBCursorPrefetchReset(used_prefetches_,
174 prefetch_keys_.size(), 176 prefetch_keys_.size(),
175 idb_cursor_id_); 177 idb_cursor_id_);
176 prefetch_keys_.clear(); 178 prefetch_keys_.clear();
177 prefetch_primary_keys_.clear(); 179 prefetch_primary_keys_.clear();
178 prefetch_values_.clear(); 180 prefetch_values_.clear();
179 181
180 pending_onsuccess_callbacks_ = 0; 182 pending_onsuccess_callbacks_ = 0;
181 } 183 }
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