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

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: Merge fixes [builds, untested] Created 7 years, 3 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/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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // If not, it means the callback did something else, or nothing at all, 101 // If not, it means the callback did something else, or nothing at all,
102 // in which case we need to reset the cache. 102 // in which case we need to reset the cache.
103 103
104 if (pending_onsuccess_callbacks_ == 0) 104 if (pending_onsuccess_callbacks_ == 0)
105 ResetPrefetchCache(); 105 ResetPrefetchCache();
106 } 106 }
107 107
108 void RendererWebIDBCursorImpl::SetPrefetchData( 108 void RendererWebIDBCursorImpl::SetPrefetchData(
109 const std::vector<IndexedDBKey>& keys, 109 const std::vector<IndexedDBKey>& keys,
110 const std::vector<IndexedDBKey>& primary_keys, 110 const std::vector<IndexedDBKey>& primary_keys,
111 const std::vector<WebData>& values) { 111 const std::vector<WebData>& values,
112 const std::vector<WebKit::WebVector<WebKit::WebBlobInfo> >& blob_info) {
112 prefetch_keys_.assign(keys.begin(), keys.end()); 113 prefetch_keys_.assign(keys.begin(), keys.end());
113 prefetch_primary_keys_.assign(primary_keys.begin(), primary_keys.end()); 114 prefetch_primary_keys_.assign(primary_keys.begin(), primary_keys.end());
114 prefetch_values_.assign(values.begin(), values.end()); 115 prefetch_values_.assign(values.begin(), values.end());
116 prefetch_blob_info_.assign(blob_info.begin(), blob_info.end());
115 117
116 used_prefetches_ = 0; 118 used_prefetches_ = 0;
117 pending_onsuccess_callbacks_ = 0; 119 pending_onsuccess_callbacks_ = 0;
118 } 120 }
119 121
120 void RendererWebIDBCursorImpl::CachedContinue(WebIDBCallbacks* callbacks) { 122 void RendererWebIDBCursorImpl::CachedContinue(WebIDBCallbacks* callbacks) {
121 DCHECK_GT(prefetch_keys_.size(), 0ul); 123 DCHECK_GT(prefetch_keys_.size(), 0ul);
122 DCHECK(prefetch_primary_keys_.size() == prefetch_keys_.size()); 124 DCHECK(prefetch_primary_keys_.size() == prefetch_keys_.size());
123 DCHECK(prefetch_values_.size() == prefetch_keys_.size()); 125 DCHECK(prefetch_values_.size() == prefetch_keys_.size());
126 DCHECK(prefetch_blob_info_.size() == prefetch_keys_.size());
124 127
125 IndexedDBKey key = prefetch_keys_.front(); 128 IndexedDBKey key = prefetch_keys_.front();
126 IndexedDBKey primary_key = prefetch_primary_keys_.front(); 129 IndexedDBKey primary_key = prefetch_primary_keys_.front();
127 // this could be a real problem.. we need 2 CachedContinues 130 // this could be a real problem.. we need 2 CachedContinues
128 WebData value = prefetch_values_.front(); 131 WebData value = prefetch_values_.front();
132 WebKit::WebVector<WebKit::WebBlobInfo> blob_info =
133 prefetch_blob_info_.front();
129 134
130 prefetch_keys_.pop_front(); 135 prefetch_keys_.pop_front();
131 prefetch_primary_keys_.pop_front(); 136 prefetch_primary_keys_.pop_front();
132 prefetch_values_.pop_front(); 137 prefetch_values_.pop_front();
138 prefetch_blob_info_.pop_front();
133 used_prefetches_++; 139 used_prefetches_++;
134 140
135 pending_onsuccess_callbacks_++; 141 pending_onsuccess_callbacks_++;
136 142
137 callbacks->onSuccess(WebIDBKeyBuilder::Build(key), 143 callbacks->onSuccess(WebIDBKeyBuilder::Build(key),
138 WebIDBKeyBuilder::Build(primary_key), value); 144 WebIDBKeyBuilder::Build(primary_key), value, blob_info);
139 } 145 }
140 146
141 void RendererWebIDBCursorImpl::ResetPrefetchCache() { 147 void RendererWebIDBCursorImpl::ResetPrefetchCache() {
142 continue_count_ = 0; 148 continue_count_ = 0;
143 prefetch_amount_ = kMinPrefetchAmount; 149 prefetch_amount_ = kMinPrefetchAmount;
144 150
145 if (!prefetch_keys_.size()) { 151 if (!prefetch_keys_.size()) {
146 // No prefetch cache, so no need to reset the cursor in the back-end. 152 // No prefetch cache, so no need to reset the cursor in the back-end.
147 return; 153 return;
148 } 154 }
149 155
150 IndexedDBDispatcher* dispatcher = 156 IndexedDBDispatcher* dispatcher =
151 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); 157 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get());
152 dispatcher->RequestIDBCursorPrefetchReset( 158 dispatcher->RequestIDBCursorPrefetchReset(
153 used_prefetches_, prefetch_keys_.size(), ipc_cursor_id_); 159 used_prefetches_, prefetch_keys_.size(), ipc_cursor_id_);
154 prefetch_keys_.clear(); 160 prefetch_keys_.clear();
155 prefetch_primary_keys_.clear(); 161 prefetch_primary_keys_.clear();
156 prefetch_values_.clear(); 162 prefetch_values_.clear();
163 prefetch_blob_info_.clear();
157 164
158 pending_onsuccess_callbacks_ = 0; 165 pending_onsuccess_callbacks_ = 0;
159 } 166 }
160 167
161 } // namespace content 168 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698