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

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

Issue 18023022: Blob support for IDB [Chromium] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle the rest of Josh's feedback. Created 7 years 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/proxy_webidbcursor_impl.h" 5 #include "content/child/indexed_db/proxy_webidbcursor_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "content/child/thread_safe_sender.h" 9 #include "content/child/thread_safe_sender.h"
10 #include "content/child/indexed_db/indexed_db_dispatcher.h" 10 #include "content/child/indexed_db/indexed_db_dispatcher.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // If not, it means the callback did something else, or nothing at all, 111 // If not, it means the callback did something else, or nothing at all,
112 // in which case we need to reset the cache. 112 // in which case we need to reset the cache.
113 113
114 if (pending_onsuccess_callbacks_ == 0) 114 if (pending_onsuccess_callbacks_ == 0)
115 ResetPrefetchCache(); 115 ResetPrefetchCache();
116 } 116 }
117 117
118 void RendererWebIDBCursorImpl::SetPrefetchData( 118 void RendererWebIDBCursorImpl::SetPrefetchData(
119 const std::vector<IndexedDBKey>& keys, 119 const std::vector<IndexedDBKey>& keys,
120 const std::vector<IndexedDBKey>& primary_keys, 120 const std::vector<IndexedDBKey>& primary_keys,
121 const std::vector<WebData>& values) { 121 const std::vector<WebData>& values,
122 const std::vector<blink::WebVector<blink::WebBlobInfo> >& blob_info) {
122 prefetch_keys_.assign(keys.begin(), keys.end()); 123 prefetch_keys_.assign(keys.begin(), keys.end());
123 prefetch_primary_keys_.assign(primary_keys.begin(), primary_keys.end()); 124 prefetch_primary_keys_.assign(primary_keys.begin(), primary_keys.end());
124 prefetch_values_.assign(values.begin(), values.end()); 125 prefetch_values_.assign(values.begin(), values.end());
126 prefetch_blob_info_.assign(blob_info.begin(), blob_info.end());
125 127
126 used_prefetches_ = 0; 128 used_prefetches_ = 0;
127 pending_onsuccess_callbacks_ = 0; 129 pending_onsuccess_callbacks_ = 0;
128 } 130 }
129 131
130 void RendererWebIDBCursorImpl::CachedContinue(WebIDBCallbacks* callbacks) { 132 void RendererWebIDBCursorImpl::CachedContinue(WebIDBCallbacks* callbacks) {
131 DCHECK_GT(prefetch_keys_.size(), 0ul); 133 DCHECK_GT(prefetch_keys_.size(), 0ul);
132 DCHECK(prefetch_primary_keys_.size() == prefetch_keys_.size()); 134 DCHECK_EQ(prefetch_primary_keys_.size(), prefetch_keys_.size());
133 DCHECK(prefetch_values_.size() == prefetch_keys_.size()); 135 DCHECK_EQ(prefetch_values_.size(), prefetch_keys_.size());
136 DCHECK_EQ(prefetch_blob_info_.size(), prefetch_keys_.size());
134 137
135 IndexedDBKey key = prefetch_keys_.front(); 138 IndexedDBKey key = prefetch_keys_.front();
136 IndexedDBKey primary_key = prefetch_primary_keys_.front(); 139 IndexedDBKey primary_key = prefetch_primary_keys_.front();
137 // this could be a real problem.. we need 2 CachedContinues 140 // this could be a real problem.. we need 2 CachedContinues
138 WebData value = prefetch_values_.front(); 141 WebData value = prefetch_values_.front();
142 blink::WebVector<blink::WebBlobInfo> blob_info = prefetch_blob_info_.front();
139 143
140 prefetch_keys_.pop_front(); 144 prefetch_keys_.pop_front();
141 prefetch_primary_keys_.pop_front(); 145 prefetch_primary_keys_.pop_front();
142 prefetch_values_.pop_front(); 146 prefetch_values_.pop_front();
147 prefetch_blob_info_.pop_front();
143 used_prefetches_++; 148 used_prefetches_++;
144 149
145 pending_onsuccess_callbacks_++; 150 pending_onsuccess_callbacks_++;
146 151
147 callbacks->onSuccess(WebIDBKeyBuilder::Build(key), 152 callbacks->onSuccess(WebIDBKeyBuilder::Build(key),
148 WebIDBKeyBuilder::Build(primary_key), value); 153 WebIDBKeyBuilder::Build(primary_key),
154 value,
155 blob_info);
149 } 156 }
150 157
151 void RendererWebIDBCursorImpl::ResetPrefetchCache() { 158 void RendererWebIDBCursorImpl::ResetPrefetchCache() {
152 continue_count_ = 0; 159 continue_count_ = 0;
153 prefetch_amount_ = kMinPrefetchAmount; 160 prefetch_amount_ = kMinPrefetchAmount;
154 161
155 if (!prefetch_keys_.size()) { 162 if (!prefetch_keys_.size()) {
156 // No prefetch cache, so no need to reset the cursor in the back-end. 163 // No prefetch cache, so no need to reset the cursor in the back-end.
157 return; 164 return;
158 } 165 }
159 166
160 IndexedDBDispatcher* dispatcher = 167 IndexedDBDispatcher* dispatcher =
161 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); 168 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get());
162 dispatcher->RequestIDBCursorPrefetchReset( 169 dispatcher->RequestIDBCursorPrefetchReset(
163 used_prefetches_, prefetch_keys_.size(), ipc_cursor_id_); 170 used_prefetches_, prefetch_keys_.size(), ipc_cursor_id_);
164 prefetch_keys_.clear(); 171 prefetch_keys_.clear();
165 prefetch_primary_keys_.clear(); 172 prefetch_primary_keys_.clear();
166 prefetch_values_.clear(); 173 prefetch_values_.clear();
174 prefetch_blob_info_.clear();
167 175
168 pending_onsuccess_callbacks_ = 0; 176 pending_onsuccess_callbacks_ = 0;
169 } 177 }
170 178
171 } // namespace content 179 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698