| OLD | NEW |
| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 IndexedDBKey primary_key = prefetch_primary_keys_.front(); | 154 IndexedDBKey primary_key = prefetch_primary_keys_.front(); |
| 155 WebData value = prefetch_values_.front(); | 155 WebData value = prefetch_values_.front(); |
| 156 | 156 |
| 157 prefetch_keys_.pop_front(); | 157 prefetch_keys_.pop_front(); |
| 158 prefetch_primary_keys_.pop_front(); | 158 prefetch_primary_keys_.pop_front(); |
| 159 prefetch_values_.pop_front(); | 159 prefetch_values_.pop_front(); |
| 160 ++used_prefetches_; | 160 ++used_prefetches_; |
| 161 | 161 |
| 162 ++pending_onsuccess_callbacks_; | 162 ++pending_onsuccess_callbacks_; |
| 163 | 163 |
| 164 if (!continue_count_) { | |
| 165 // The cache was invalidated by a call to ResetPrefetchCache() | |
| 166 // after the RequestIDBCursorPrefetch() was made. Now that the | |
| 167 // initiating continue() call has been satisfied, discard | |
| 168 // the rest of the cache. | |
| 169 ResetPrefetchCache(); | |
| 170 } | |
| 171 | |
| 172 callbacks->onSuccess(WebIDBKeyBuilder::Build(key), | 164 callbacks->onSuccess(WebIDBKeyBuilder::Build(key), |
| 173 WebIDBKeyBuilder::Build(primary_key), | 165 WebIDBKeyBuilder::Build(primary_key), |
| 174 value); | 166 value); |
| 175 } | 167 } |
| 176 | 168 |
| 177 void WebIDBCursorImpl::ResetPrefetchCache() { | 169 void WebIDBCursorImpl::ResetPrefetchCache() { |
| 178 continue_count_ = 0; | 170 continue_count_ = 0; |
| 179 prefetch_amount_ = kMinPrefetchAmount; | 171 prefetch_amount_ = kMinPrefetchAmount; |
| 180 | 172 |
| 181 if (!prefetch_keys_.size()) { | 173 if (!prefetch_keys_.size()) { |
| 182 // No prefetch cache, so no need to reset the cursor in the back-end. | 174 // No prefetch cache, so no need to reset the cursor in the back-end. |
| 183 return; | 175 return; |
| 184 } | 176 } |
| 185 | 177 |
| 186 IndexedDBDispatcher* dispatcher = | 178 IndexedDBDispatcher* dispatcher = |
| 187 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); | 179 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); |
| 188 dispatcher->RequestIDBCursorPrefetchReset( | 180 dispatcher->RequestIDBCursorPrefetchReset( |
| 189 used_prefetches_, prefetch_keys_.size(), ipc_cursor_id_); | 181 used_prefetches_, prefetch_keys_.size(), ipc_cursor_id_); |
| 190 prefetch_keys_.clear(); | 182 prefetch_keys_.clear(); |
| 191 prefetch_primary_keys_.clear(); | 183 prefetch_primary_keys_.clear(); |
| 192 prefetch_values_.clear(); | 184 prefetch_values_.clear(); |
| 193 | 185 |
| 194 pending_onsuccess_callbacks_ = 0; | 186 pending_onsuccess_callbacks_ = 0; |
| 195 } | 187 } |
| 196 | 188 |
| 197 } // namespace content | 189 } // namespace content |
| OLD | NEW |