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

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

Issue 240003010: The chromium-side backchannel plumbing for blobs in IDB. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged out Created 6 years, 7 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
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/webidbcursor_impl.h" 5 #include "content/child/indexed_db/webidbcursor_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "content/child/indexed_db/indexed_db_dispatcher.h" 9 #include "content/child/indexed_db/indexed_db_dispatcher.h"
10 #include "content/child/indexed_db/indexed_db_key_builders.h" 10 #include "content/child/indexed_db/indexed_db_key_builders.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // callback did something else, or nothing at all, in which case we need to 115 // callback did something else, or nothing at all, in which case we need to
116 // reset the cache. 116 // reset the cache.
117 117
118 if (pending_onsuccess_callbacks_ == 0) 118 if (pending_onsuccess_callbacks_ == 0)
119 ResetPrefetchCache(); 119 ResetPrefetchCache();
120 } 120 }
121 121
122 void WebIDBCursorImpl::SetPrefetchData( 122 void WebIDBCursorImpl::SetPrefetchData(
123 const std::vector<IndexedDBKey>& keys, 123 const std::vector<IndexedDBKey>& keys,
124 const std::vector<IndexedDBKey>& primary_keys, 124 const std::vector<IndexedDBKey>& primary_keys,
125 const std::vector<WebData>& values) { 125 const std::vector<WebData>& values,
126 const std::vector<blink::WebVector<blink::WebBlobInfo> >& blob_info) {
126 prefetch_keys_.assign(keys.begin(), keys.end()); 127 prefetch_keys_.assign(keys.begin(), keys.end());
127 prefetch_primary_keys_.assign(primary_keys.begin(), primary_keys.end()); 128 prefetch_primary_keys_.assign(primary_keys.begin(), primary_keys.end());
128 prefetch_values_.assign(values.begin(), values.end()); 129 prefetch_values_.assign(values.begin(), values.end());
130 prefetch_blob_info_.assign(blob_info.begin(), blob_info.end());
129 131
130 used_prefetches_ = 0; 132 used_prefetches_ = 0;
131 pending_onsuccess_callbacks_ = 0; 133 pending_onsuccess_callbacks_ = 0;
132 } 134 }
133 135
134 void WebIDBCursorImpl::CachedAdvance(unsigned long count, 136 void WebIDBCursorImpl::CachedAdvance(unsigned long count,
135 WebIDBCallbacks* callbacks) { 137 WebIDBCallbacks* callbacks) {
136 DCHECK_GE(prefetch_keys_.size(), count); 138 DCHECK_GE(prefetch_keys_.size(), count);
137 DCHECK_EQ(prefetch_primary_keys_.size(), prefetch_keys_.size()); 139 DCHECK_EQ(prefetch_primary_keys_.size(), prefetch_keys_.size());
138 DCHECK_EQ(prefetch_values_.size(), prefetch_keys_.size()); 140 DCHECK_EQ(prefetch_values_.size(), prefetch_keys_.size());
141 DCHECK_EQ(prefetch_blob_info_.size(), prefetch_keys_.size());
139 142
140 while (count > 1) { 143 while (count > 1) {
141 prefetch_keys_.pop_front(); 144 prefetch_keys_.pop_front();
142 prefetch_primary_keys_.pop_front(); 145 prefetch_primary_keys_.pop_front();
143 prefetch_values_.pop_front(); 146 prefetch_values_.pop_front();
147 prefetch_blob_info_.pop_front();
144 ++used_prefetches_; 148 ++used_prefetches_;
145 --count; 149 --count;
146 } 150 }
147 151
148 CachedContinue(callbacks); 152 CachedContinue(callbacks);
149 } 153 }
150 154
151 void WebIDBCursorImpl::CachedContinue(WebIDBCallbacks* callbacks) { 155 void WebIDBCursorImpl::CachedContinue(WebIDBCallbacks* callbacks) {
152 DCHECK_GT(prefetch_keys_.size(), 0ul); 156 DCHECK_GT(prefetch_keys_.size(), 0ul);
153 DCHECK_EQ(prefetch_primary_keys_.size(), prefetch_keys_.size()); 157 DCHECK_EQ(prefetch_primary_keys_.size(), prefetch_keys_.size());
154 DCHECK_EQ(prefetch_values_.size(), prefetch_keys_.size()); 158 DCHECK_EQ(prefetch_values_.size(), prefetch_keys_.size());
159 DCHECK_EQ(prefetch_blob_info_.size(), prefetch_keys_.size());
155 160
156 IndexedDBKey key = prefetch_keys_.front(); 161 IndexedDBKey key = prefetch_keys_.front();
157 IndexedDBKey primary_key = prefetch_primary_keys_.front(); 162 IndexedDBKey primary_key = prefetch_primary_keys_.front();
158 WebData value = prefetch_values_.front(); 163 WebData value = prefetch_values_.front();
164 blink::WebVector<blink::WebBlobInfo> blob_info = prefetch_blob_info_.front();
159 165
160 prefetch_keys_.pop_front(); 166 prefetch_keys_.pop_front();
161 prefetch_primary_keys_.pop_front(); 167 prefetch_primary_keys_.pop_front();
162 prefetch_values_.pop_front(); 168 prefetch_values_.pop_front();
169 prefetch_blob_info_.pop_front();
163 ++used_prefetches_; 170 ++used_prefetches_;
164 171
165 ++pending_onsuccess_callbacks_; 172 ++pending_onsuccess_callbacks_;
166 173
167 if (!continue_count_) { 174 if (!continue_count_) {
168 // The cache was invalidated by a call to ResetPrefetchCache() 175 // The cache was invalidated by a call to ResetPrefetchCache()
169 // after the RequestIDBCursorPrefetch() was made. Now that the 176 // after the RequestIDBCursorPrefetch() was made. Now that the
170 // initiating continue() call has been satisfied, discard 177 // initiating continue() call has been satisfied, discard
171 // the rest of the cache. 178 // the rest of the cache.
172 ResetPrefetchCache(); 179 ResetPrefetchCache();
173 } 180 }
174 181
175 callbacks->onSuccess(WebIDBKeyBuilder::Build(key), 182 callbacks->onSuccess(WebIDBKeyBuilder::Build(key),
176 WebIDBKeyBuilder::Build(primary_key), 183 WebIDBKeyBuilder::Build(primary_key),
177 value); 184 value,
185 blob_info);
178 } 186 }
179 187
180 void WebIDBCursorImpl::ResetPrefetchCache() { 188 void WebIDBCursorImpl::ResetPrefetchCache() {
181 continue_count_ = 0; 189 continue_count_ = 0;
182 prefetch_amount_ = kMinPrefetchAmount; 190 prefetch_amount_ = kMinPrefetchAmount;
183 191
184 if (!prefetch_keys_.size()) { 192 if (!prefetch_keys_.size()) {
185 // No prefetch cache, so no need to reset the cursor in the back-end. 193 // No prefetch cache, so no need to reset the cursor in the back-end.
186 return; 194 return;
187 } 195 }
188 196
189 IndexedDBDispatcher* dispatcher = 197 IndexedDBDispatcher* dispatcher =
190 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); 198 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get());
191 dispatcher->RequestIDBCursorPrefetchReset( 199 dispatcher->RequestIDBCursorPrefetchReset(
192 used_prefetches_, prefetch_keys_.size(), ipc_cursor_id_); 200 used_prefetches_, prefetch_keys_.size(), ipc_cursor_id_);
193 prefetch_keys_.clear(); 201 prefetch_keys_.clear();
194 prefetch_primary_keys_.clear(); 202 prefetch_primary_keys_.clear();
195 prefetch_values_.clear(); 203 prefetch_values_.clear();
204 prefetch_blob_info_.clear();
196 205
197 pending_onsuccess_callbacks_ = 0; 206 pending_onsuccess_callbacks_ = 0;
198 } 207 }
199 208
200 } // namespace content 209 } // namespace content
OLDNEW
« no previous file with comments | « content/child/indexed_db/webidbcursor_impl.h ('k') | content/child/indexed_db/webidbcursor_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698