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

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

Issue 10272018: Move IndexedDBKey, IndexedDBKeyRange into content namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use "using content::*" aliasing for IDB/SSV types Created 8 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/common/indexed_db/proxy_webidbcursor_impl.h" 5 #include "content/common/indexed_db/proxy_webidbcursor_impl.h"
6 6
7 #include "content/common/child_thread.h" 7 #include "content/common/child_thread.h"
8 #include "content/common/indexed_db/indexed_db_messages.h" 8 #include "content/common/indexed_db/indexed_db_messages.h"
9 #include "content/common/indexed_db/indexed_db_dispatcher.h" 9 #include "content/common/indexed_db/indexed_db_dispatcher.h"
10 10
11 using content::IndexedDBKey;
12 using content::SerializedScriptValue;
11 using WebKit::WebExceptionCode; 13 using WebKit::WebExceptionCode;
12 using WebKit::WebIDBCallbacks; 14 using WebKit::WebIDBCallbacks;
13 using WebKit::WebIDBKey; 15 using WebKit::WebIDBKey;
14 using WebKit::WebSerializedScriptValue; 16 using WebKit::WebSerializedScriptValue;
15 17
16 RendererWebIDBCursorImpl::RendererWebIDBCursorImpl(int32 idb_cursor_id) 18 RendererWebIDBCursorImpl::RendererWebIDBCursorImpl(int32 idb_cursor_id)
17 : idb_cursor_id_(idb_cursor_id), 19 : idb_cursor_id_(idb_cursor_id),
18 continue_count_(0), 20 continue_count_(0),
19 used_prefetches_(0), 21 used_prefetches_(0),
20 pending_onsuccess_callbacks_(0), 22 pending_onsuccess_callbacks_(0),
(...skipping 30 matching lines...) Expand all
51 WebSerializedScriptValue RendererWebIDBCursorImpl::value() const { 53 WebSerializedScriptValue RendererWebIDBCursorImpl::value() const {
52 return value_; 54 return value_;
53 } 55 }
54 56
55 void RendererWebIDBCursorImpl::update(const WebSerializedScriptValue& value, 57 void RendererWebIDBCursorImpl::update(const WebSerializedScriptValue& value,
56 WebIDBCallbacks* callbacks, 58 WebIDBCallbacks* callbacks,
57 WebExceptionCode& ec) { 59 WebExceptionCode& ec) {
58 IndexedDBDispatcher* dispatcher = 60 IndexedDBDispatcher* dispatcher =
59 IndexedDBDispatcher::ThreadSpecificInstance(); 61 IndexedDBDispatcher::ThreadSpecificInstance();
60 dispatcher->RequestIDBCursorUpdate( 62 dispatcher->RequestIDBCursorUpdate(
61 content::SerializedScriptValue(value), callbacks, idb_cursor_id_, &ec); 63 SerializedScriptValue(value), callbacks, idb_cursor_id_, &ec);
62 } 64 }
63 65
64 void RendererWebIDBCursorImpl::advance(unsigned long count, 66 void RendererWebIDBCursorImpl::advance(unsigned long count,
65 WebIDBCallbacks* callbacks_ptr, 67 WebIDBCallbacks* callbacks_ptr,
66 WebExceptionCode& ec) { 68 WebExceptionCode& ec) {
67 IndexedDBDispatcher* dispatcher = 69 IndexedDBDispatcher* dispatcher =
68 IndexedDBDispatcher::ThreadSpecificInstance(); 70 IndexedDBDispatcher::ThreadSpecificInstance();
69 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); 71 scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
70 ResetPrefetchCache(); 72 ResetPrefetchCache();
71 dispatcher->RequestIDBCursorAdvance(count, callbacks.release(), 73 dispatcher->RequestIDBCursorAdvance(count, callbacks.release(),
(...skipping 28 matching lines...) Expand all
100 if (prefetch_amount_ > kMaxPrefetchAmount) 102 if (prefetch_amount_ > kMaxPrefetchAmount)
101 prefetch_amount_ = kMaxPrefetchAmount; 103 prefetch_amount_ = kMaxPrefetchAmount;
102 104
103 return; 105 return;
104 } 106 }
105 } else { 107 } else {
106 // Key argument supplied. We couldn't prefetch this. 108 // Key argument supplied. We couldn't prefetch this.
107 ResetPrefetchCache(); 109 ResetPrefetchCache();
108 } 110 }
109 111
110 dispatcher->RequestIDBCursorContinue(IndexedDBKey(key), callbacks.release(), 112 dispatcher->RequestIDBCursorContinue(IndexedDBKey(key),
113 callbacks.release(),
111 idb_cursor_id_, &ec); 114 idb_cursor_id_, &ec);
112 } 115 }
113 116
114 void RendererWebIDBCursorImpl::deleteFunction(WebIDBCallbacks* callbacks, 117 void RendererWebIDBCursorImpl::deleteFunction(WebIDBCallbacks* callbacks,
115 WebExceptionCode& ec) { 118 WebExceptionCode& ec) {
116 IndexedDBDispatcher* dispatcher = 119 IndexedDBDispatcher* dispatcher =
117 IndexedDBDispatcher::ThreadSpecificInstance(); 120 IndexedDBDispatcher::ThreadSpecificInstance();
118 dispatcher->RequestIDBCursorDelete(callbacks, idb_cursor_id_, &ec); 121 dispatcher->RequestIDBCursorDelete(callbacks, idb_cursor_id_, &ec);
119 } 122 }
120 123
121 void RendererWebIDBCursorImpl::postSuccessHandlerCallback() 124 void RendererWebIDBCursorImpl::postSuccessHandlerCallback()
122 { 125 {
123 pending_onsuccess_callbacks_--; 126 pending_onsuccess_callbacks_--;
124 127
125 // If the onsuccess callback called continue() on the cursor again, 128 // If the onsuccess callback called continue() on the cursor again,
126 // and that continue was served by the prefetch cache, then 129 // and that continue was served by the prefetch cache, then
127 // pending_onsuccess_callbacks_ would be incremented. 130 // pending_onsuccess_callbacks_ would be incremented.
128 // If not, it means the callback did something else, or nothing at all, 131 // If not, it means the callback did something else, or nothing at all,
129 // in which case we need to reset the cache. 132 // in which case we need to reset the cache.
130 133
131 if (pending_onsuccess_callbacks_ == 0) 134 if (pending_onsuccess_callbacks_ == 0)
132 ResetPrefetchCache(); 135 ResetPrefetchCache();
133 } 136 }
134 137
135 void RendererWebIDBCursorImpl::SetKeyAndValue( 138 void RendererWebIDBCursorImpl::SetKeyAndValue(
136 const IndexedDBKey& key, 139 const IndexedDBKey& key,
137 const IndexedDBKey& primary_key, 140 const IndexedDBKey& primary_key,
138 const content::SerializedScriptValue& value) { 141 const SerializedScriptValue& value) {
139 key_ = key; 142 key_ = key;
140 primary_key_ = primary_key; 143 primary_key_ = primary_key;
141 value_ = value; 144 value_ = value;
142 } 145 }
143 146
144 void RendererWebIDBCursorImpl::SetPrefetchData( 147 void RendererWebIDBCursorImpl::SetPrefetchData(
145 const std::vector<IndexedDBKey>& keys, 148 const std::vector<IndexedDBKey>& keys,
146 const std::vector<IndexedDBKey>& primary_keys, 149 const std::vector<IndexedDBKey>& primary_keys,
147 const std::vector<content::SerializedScriptValue>& values) { 150 const std::vector<SerializedScriptValue>& values) {
148 prefetch_keys_.assign(keys.begin(), keys.end()); 151 prefetch_keys_.assign(keys.begin(), keys.end());
149 prefetch_primary_keys_.assign(primary_keys.begin(), primary_keys.end()); 152 prefetch_primary_keys_.assign(primary_keys.begin(), primary_keys.end());
150 prefetch_values_.assign(values.begin(), values.end()); 153 prefetch_values_.assign(values.begin(), values.end());
151 154
152 used_prefetches_ = 0; 155 used_prefetches_ = 0;
153 pending_onsuccess_callbacks_ = 0; 156 pending_onsuccess_callbacks_ = 0;
154 } 157 }
155 158
156 void RendererWebIDBCursorImpl::CachedContinue( 159 void RendererWebIDBCursorImpl::CachedContinue(
157 WebKit::WebIDBCallbacks* callbacks) { 160 WebKit::WebIDBCallbacks* callbacks) {
(...skipping 27 matching lines...) Expand all
185 IndexedDBDispatcher::ThreadSpecificInstance(); 188 IndexedDBDispatcher::ThreadSpecificInstance();
186 dispatcher->RequestIDBCursorPrefetchReset(used_prefetches_, 189 dispatcher->RequestIDBCursorPrefetchReset(used_prefetches_,
187 prefetch_keys_.size(), 190 prefetch_keys_.size(),
188 idb_cursor_id_); 191 idb_cursor_id_);
189 prefetch_keys_.clear(); 192 prefetch_keys_.clear();
190 prefetch_primary_keys_.clear(); 193 prefetch_primary_keys_.clear();
191 prefetch_values_.clear(); 194 prefetch_values_.clear();
192 195
193 pending_onsuccess_callbacks_ = 0; 196 pending_onsuccess_callbacks_ = 0;
194 } 197 }
OLDNEW
« no previous file with comments | « content/common/indexed_db/proxy_webidbcursor_impl.h ('k') | content/common/indexed_db/proxy_webidbindex_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698