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

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

Issue 19752007: Use builders to convert between WebKit and content IDB types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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"
11 #include "content/child/indexed_db/indexed_db_key_builders.h"
11 #include "content/common/indexed_db/indexed_db_messages.h" 12 #include "content/common/indexed_db/indexed_db_messages.h"
12 13
13 using WebKit::WebData; 14 using WebKit::WebData;
14 using WebKit::WebIDBCallbacks; 15 using WebKit::WebIDBCallbacks;
15 using WebKit::WebIDBKey; 16 using WebKit::WebIDBKey;
16 17
17 namespace content { 18 namespace content {
18 19
19 RendererWebIDBCursorImpl::RendererWebIDBCursorImpl( 20 RendererWebIDBCursorImpl::RendererWebIDBCursorImpl(
20 int32 ipc_cursor_id, 21 int32 ipc_cursor_id,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 prefetch_amount_ = kMaxPrefetchAmount; 82 prefetch_amount_ = kMaxPrefetchAmount;
82 83
83 return; 84 return;
84 } 85 }
85 } else { 86 } else {
86 // Key argument supplied. We couldn't prefetch this. 87 // Key argument supplied. We couldn't prefetch this.
87 ResetPrefetchCache(); 88 ResetPrefetchCache();
88 } 89 }
89 90
90 dispatcher->RequestIDBCursorContinue( 91 dispatcher->RequestIDBCursorContinue(
91 IndexedDBKey(key), callbacks.release(), ipc_cursor_id_); 92 IndexedDBKeyBuilder::Build(key), callbacks.release(), ipc_cursor_id_);
92 } 93 }
93 94
94 void RendererWebIDBCursorImpl::postSuccessHandlerCallback() { 95 void RendererWebIDBCursorImpl::postSuccessHandlerCallback() {
95 pending_onsuccess_callbacks_--; 96 pending_onsuccess_callbacks_--;
96 97
97 // If the onsuccess callback called continue() on the cursor again, 98 // If the onsuccess callback called continue() on the cursor again,
98 // and that continue was served by the prefetch cache, then 99 // and that continue was served by the prefetch cache, then
99 // pending_onsuccess_callbacks_ would be incremented. 100 // pending_onsuccess_callbacks_ would be incremented.
100 // 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,
101 // in which case we need to reset the cache. 102 // in which case we need to reset the cache.
(...skipping 24 matching lines...) Expand all
126 // this could be a real problem.. we need 2 CachedContinues 127 // this could be a real problem.. we need 2 CachedContinues
127 WebData value = prefetch_values_.front(); 128 WebData value = prefetch_values_.front();
128 129
129 prefetch_keys_.pop_front(); 130 prefetch_keys_.pop_front();
130 prefetch_primary_keys_.pop_front(); 131 prefetch_primary_keys_.pop_front();
131 prefetch_values_.pop_front(); 132 prefetch_values_.pop_front();
132 used_prefetches_++; 133 used_prefetches_++;
133 134
134 pending_onsuccess_callbacks_++; 135 pending_onsuccess_callbacks_++;
135 136
136 callbacks->onSuccess(key, primary_key, value); 137 callbacks->onSuccess(WebIDBKeyBuilder::Build(key),
138 WebIDBKeyBuilder::Build(primary_key), value);
137 } 139 }
138 140
139 void RendererWebIDBCursorImpl::ResetPrefetchCache() { 141 void RendererWebIDBCursorImpl::ResetPrefetchCache() {
140 continue_count_ = 0; 142 continue_count_ = 0;
141 prefetch_amount_ = kMinPrefetchAmount; 143 prefetch_amount_ = kMinPrefetchAmount;
142 144
143 if (!prefetch_keys_.size()) { 145 if (!prefetch_keys_.size()) {
144 // No prefetch cache, so no need to reset the cursor in the back-end. 146 // No prefetch cache, so no need to reset the cursor in the back-end.
145 return; 147 return;
146 } 148 }
147 149
148 IndexedDBDispatcher* dispatcher = 150 IndexedDBDispatcher* dispatcher =
149 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); 151 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get());
150 dispatcher->RequestIDBCursorPrefetchReset( 152 dispatcher->RequestIDBCursorPrefetchReset(
151 used_prefetches_, prefetch_keys_.size(), ipc_cursor_id_); 153 used_prefetches_, prefetch_keys_.size(), ipc_cursor_id_);
152 prefetch_keys_.clear(); 154 prefetch_keys_.clear();
153 prefetch_primary_keys_.clear(); 155 prefetch_primary_keys_.clear();
154 prefetch_values_.clear(); 156 prefetch_values_.clear();
155 157
156 pending_onsuccess_callbacks_ = 0; 158 pending_onsuccess_callbacks_ = 0;
157 } 159 }
158 160
159 } // namespace content 161 } // namespace content
OLDNEW
« no previous file with comments | « content/child/indexed_db/indexed_db_key_builders.cc ('k') | content/child/indexed_db/proxy_webidbcursor_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698