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

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: Settle on one name for the live blob journal. 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(prefetch_primary_keys_.size() == prefetch_keys_.size());
133 DCHECK(prefetch_values_.size() == prefetch_keys_.size()); 135 DCHECK(prefetch_values_.size() == prefetch_keys_.size());
136 DCHECK(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 =
143 prefetch_blob_info_.front();
139 144
140 prefetch_keys_.pop_front(); 145 prefetch_keys_.pop_front();
141 prefetch_primary_keys_.pop_front(); 146 prefetch_primary_keys_.pop_front();
142 prefetch_values_.pop_front(); 147 prefetch_values_.pop_front();
148 prefetch_blob_info_.pop_front();
143 used_prefetches_++; 149 used_prefetches_++;
144 150
145 pending_onsuccess_callbacks_++; 151 pending_onsuccess_callbacks_++;
146 152
147 callbacks->onSuccess(WebIDBKeyBuilder::Build(key), 153 callbacks->onSuccess(WebIDBKeyBuilder::Build(key),
148 WebIDBKeyBuilder::Build(primary_key), value); 154 WebIDBKeyBuilder::Build(primary_key), value, blob_info);
149 } 155 }
150 156
151 void RendererWebIDBCursorImpl::ResetPrefetchCache() { 157 void RendererWebIDBCursorImpl::ResetPrefetchCache() {
152 continue_count_ = 0; 158 continue_count_ = 0;
153 prefetch_amount_ = kMinPrefetchAmount; 159 prefetch_amount_ = kMinPrefetchAmount;
154 160
155 if (!prefetch_keys_.size()) { 161 if (!prefetch_keys_.size()) {
156 // No prefetch cache, so no need to reset the cursor in the back-end. 162 // No prefetch cache, so no need to reset the cursor in the back-end.
157 return; 163 return;
158 } 164 }
159 165
160 IndexedDBDispatcher* dispatcher = 166 IndexedDBDispatcher* dispatcher =
161 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); 167 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get());
162 dispatcher->RequestIDBCursorPrefetchReset( 168 dispatcher->RequestIDBCursorPrefetchReset(
163 used_prefetches_, prefetch_keys_.size(), ipc_cursor_id_); 169 used_prefetches_, prefetch_keys_.size(), ipc_cursor_id_);
164 prefetch_keys_.clear(); 170 prefetch_keys_.clear();
165 prefetch_primary_keys_.clear(); 171 prefetch_primary_keys_.clear();
166 prefetch_values_.clear(); 172 prefetch_values_.clear();
173 prefetch_blob_info_.clear();
167 174
168 pending_onsuccess_callbacks_ = 0; 175 pending_onsuccess_callbacks_ = 0;
169 } 176 }
170 177
171 } // namespace content 178 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698