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

Side by Side Diff: content/browser/indexed_db/webidbdatabase_impl.cc

Issue 16573003: Remove content/browser dependency on WebKit::WebIDBCallbacks and WebKit::WebIDBDatabaseCallbacks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix namespace issues Created 7 years, 6 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/browser/indexed_db/webidbdatabase_impl.h" 5 #include "content/browser/indexed_db/webidbdatabase_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "content/browser/indexed_db/indexed_db_callbacks_wrapper.h" 11 #include "content/browser/indexed_db/indexed_db_callbacks_wrapper.h"
12 #include "content/browser/indexed_db/indexed_db_cursor.h" 12 #include "content/browser/indexed_db/indexed_db_cursor.h"
13 #include "content/browser/indexed_db/indexed_db_database.h" 13 #include "content/browser/indexed_db/indexed_db_database.h"
14 #include "content/browser/indexed_db/indexed_db_metadata.h" 14 #include "content/browser/indexed_db/indexed_db_metadata.h"
15 #include "content/common/indexed_db/indexed_db_key_range.h" 15 #include "content/common/indexed_db/indexed_db_key_range.h"
16 #include "third_party/WebKit/public/platform/WebData.h" 16 #include "third_party/WebKit/public/platform/WebData.h"
17 #include "third_party/WebKit/public/platform/WebIDBCallbacks.h"
18 #include "third_party/WebKit/public/platform/WebIDBDatabaseCallbacks.h"
19 #include "third_party/WebKit/public/platform/WebIDBDatabaseError.h" 17 #include "third_party/WebKit/public/platform/WebIDBDatabaseError.h"
20 #include "third_party/WebKit/public/platform/WebIDBKey.h" 18 #include "third_party/WebKit/public/platform/WebIDBKey.h"
21 #include "third_party/WebKit/public/platform/WebIDBKeyRange.h" 19 #include "third_party/WebKit/public/platform/WebIDBKeyRange.h"
22 #include "third_party/WebKit/public/platform/WebIDBMetadata.h" 20 #include "third_party/WebKit/public/platform/WebIDBMetadata.h"
23 21
24 using WebKit::WebString; 22 using WebKit::WebString;
25 using WebKit::WebIDBKey; 23 using WebKit::WebIDBKey;
26 using WebKit::WebData; 24 using WebKit::WebData;
27 using WebKit::WebIDBKeyPath; 25 using WebKit::WebIDBKeyPath;
28 using WebKit::WebIDBKeyRange; 26 using WebKit::WebIDBKeyRange;
29 using WebKit::WebIDBDatabaseCallbacks;
30 using WebKit::WebIDBCallbacks;
31 using WebKit::WebVector; 27 using WebKit::WebVector;
32 using WebKit::WebIDBDatabaseError; 28 using WebKit::WebIDBDatabaseError;
33 29
34 namespace content { 30 namespace content {
35 31
36 WebIDBDatabaseImpl::WebIDBDatabaseImpl( 32 WebIDBDatabaseImpl::WebIDBDatabaseImpl(
37 scoped_refptr<IndexedDBDatabase> database_backend, 33 scoped_refptr<IndexedDBDatabase> database_backend,
38 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks) 34 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks)
39 : database_backend_(database_backend), 35 : database_backend_(database_backend),
40 database_callbacks_(database_callbacks) {} 36 database_callbacks_(database_callbacks) {}
(...skipping 12 matching lines...) Expand all
53 auto_increment); 49 auto_increment);
54 } 50 }
55 51
56 void WebIDBDatabaseImpl::deleteObjectStore(long long transaction_id, 52 void WebIDBDatabaseImpl::deleteObjectStore(long long transaction_id,
57 long long object_store_id) { 53 long long object_store_id) {
58 database_backend_->DeleteObjectStore(transaction_id, object_store_id); 54 database_backend_->DeleteObjectStore(transaction_id, object_store_id);
59 } 55 }
60 56
61 void WebIDBDatabaseImpl::createTransaction( 57 void WebIDBDatabaseImpl::createTransaction(
62 long long id, 58 long long id,
63 WebIDBDatabaseCallbacks* /*callbacks*/, 59 IndexedDBDatabaseCallbacks* /*callbacks*/,
64 const WebVector<long long>& object_store_ids, 60 const WebVector<long long>& object_store_ids,
65 unsigned short mode) { 61 unsigned short mode) {
66 if (!database_callbacks_) 62 if (!database_callbacks_)
67 return; 63 return;
68 std::vector<int64> object_store_id_list(object_store_ids.size()); 64 std::vector<int64> object_store_id_list(object_store_ids.size());
69 for (size_t i = 0; i < object_store_ids.size(); ++i) 65 for (size_t i = 0; i < object_store_ids.size(); ++i)
70 object_store_id_list[i] = object_store_ids[i]; 66 object_store_id_list[i] = object_store_ids[i];
71 database_backend_->CreateTransaction( 67 database_backend_->CreateTransaction(
72 id, database_callbacks_.get(), object_store_id_list, mode); 68 id, database_callbacks_.get(), object_store_id_list, mode);
73 } 69 }
(...skipping 30 matching lines...) Expand all
104 if (database_backend_) 100 if (database_backend_)
105 database_backend_->Commit(transaction_id); 101 database_backend_->Commit(transaction_id);
106 } 102 }
107 103
108 void WebIDBDatabaseImpl::openCursor(long long transaction_id, 104 void WebIDBDatabaseImpl::openCursor(long long transaction_id,
109 long long object_store_id, 105 long long object_store_id,
110 long long index_id, 106 long long index_id,
111 const WebIDBKeyRange& key_range, 107 const WebIDBKeyRange& key_range,
112 unsigned short direction, 108 unsigned short direction,
113 bool key_only, 109 bool key_only,
114 TaskType task_type, 110 WebKit::WebIDBDatabase::TaskType task_type,
115 WebIDBCallbacks* callbacks) { 111 IndexedDBCallbacksBase* callbacks) {
116 if (database_backend_) 112 if (database_backend_)
117 database_backend_->OpenCursor( 113 database_backend_->OpenCursor(
118 transaction_id, 114 transaction_id,
119 object_store_id, 115 object_store_id,
120 index_id, 116 index_id,
121 make_scoped_ptr(new IndexedDBKeyRange(key_range)), 117 make_scoped_ptr(new IndexedDBKeyRange(key_range)),
122 static_cast<indexed_db::CursorDirection>(direction), 118 static_cast<indexed_db::CursorDirection>(direction),
123 key_only, 119 key_only,
124 static_cast<IndexedDBDatabase::TaskType>(task_type), 120 static_cast<IndexedDBDatabase::TaskType>(task_type),
125 IndexedDBCallbacksWrapper::Create(callbacks)); 121 IndexedDBCallbacksWrapper::Create(callbacks));
126 } 122 }
127 123
128 void WebIDBDatabaseImpl::count(long long transaction_id, 124 void WebIDBDatabaseImpl::count(long long transaction_id,
129 long long object_store_id, 125 long long object_store_id,
130 long long index_id, 126 long long index_id,
131 const WebIDBKeyRange& key_range, 127 const WebIDBKeyRange& key_range,
132 WebIDBCallbacks* callbacks) { 128 IndexedDBCallbacksBase* callbacks) {
133 if (database_backend_) 129 if (database_backend_)
134 database_backend_->Count(transaction_id, 130 database_backend_->Count(transaction_id,
135 object_store_id, 131 object_store_id,
136 index_id, 132 index_id,
137 make_scoped_ptr(new IndexedDBKeyRange(key_range)), 133 make_scoped_ptr(new IndexedDBKeyRange(key_range)),
138 IndexedDBCallbacksWrapper::Create(callbacks)); 134 IndexedDBCallbacksWrapper::Create(callbacks));
139 } 135 }
140 136
141 void WebIDBDatabaseImpl::get(long long transaction_id, 137 void WebIDBDatabaseImpl::get(long long transaction_id,
142 long long object_store_id, 138 long long object_store_id,
143 long long index_id, 139 long long index_id,
144 const WebIDBKeyRange& key_range, 140 const WebIDBKeyRange& key_range,
145 bool key_only, 141 bool key_only,
146 WebIDBCallbacks* callbacks) { 142 IndexedDBCallbacksBase* callbacks) {
147 if (database_backend_) 143 if (database_backend_)
148 database_backend_->Get(transaction_id, 144 database_backend_->Get(transaction_id,
149 object_store_id, 145 object_store_id,
150 index_id, 146 index_id,
151 make_scoped_ptr(new IndexedDBKeyRange(key_range)), 147 make_scoped_ptr(new IndexedDBKeyRange(key_range)),
152 key_only, 148 key_only,
153 IndexedDBCallbacksWrapper::Create(callbacks)); 149 IndexedDBCallbacksWrapper::Create(callbacks));
154 } 150 }
155 151
156 void WebIDBDatabaseImpl::put(long long transaction_id, 152 void WebIDBDatabaseImpl::put(
157 long long object_store_id, 153 long long transaction_id,
158 const WebData& value, 154 long long object_store_id,
159 const WebIDBKey& key, 155 const WebData& value,
160 PutMode put_mode, 156 const WebIDBKey& key,
161 WebIDBCallbacks* callbacks, 157 WebKit::WebIDBDatabase::PutMode put_mode,
162 const WebVector<long long>& web_index_ids, 158 IndexedDBCallbacksBase* callbacks,
163 const WebVector<WebIndexKeys>& web_index_keys) { 159 const WebVector<long long>& web_index_ids,
160 const WebVector<WebKit::WebIDBDatabase::WebIndexKeys>& web_index_keys) {
164 if (!database_backend_) 161 if (!database_backend_)
165 return; 162 return;
166 163
167 DCHECK_EQ(web_index_ids.size(), web_index_keys.size()); 164 DCHECK_EQ(web_index_ids.size(), web_index_keys.size());
168 std::vector<int64> index_ids(web_index_ids.size()); 165 std::vector<int64> index_ids(web_index_ids.size());
169 std::vector<IndexedDBDatabase::IndexKeys> index_keys(web_index_keys.size()); 166 std::vector<IndexedDBDatabase::IndexKeys> index_keys(web_index_keys.size());
170 167
171 for (size_t i = 0; i < web_index_ids.size(); ++i) { 168 for (size_t i = 0; i < web_index_ids.size(); ++i) {
172 index_ids[i] = web_index_ids[i]; 169 index_ids[i] = web_index_ids[i];
173 IndexedDBKey::KeyArray index_key_list; 170 IndexedDBKey::KeyArray index_key_list;
(...skipping 11 matching lines...) Expand all
185 IndexedDBCallbacksWrapper::Create(callbacks), 182 IndexedDBCallbacksWrapper::Create(callbacks),
186 index_ids, 183 index_ids,
187 index_keys); 184 index_keys);
188 } 185 }
189 186
190 void WebIDBDatabaseImpl::setIndexKeys( 187 void WebIDBDatabaseImpl::setIndexKeys(
191 long long transaction_id, 188 long long transaction_id,
192 long long object_store_id, 189 long long object_store_id,
193 const WebIDBKey& primary_key, 190 const WebIDBKey& primary_key,
194 const WebVector<long long>& web_index_ids, 191 const WebVector<long long>& web_index_ids,
195 const WebVector<WebIndexKeys>& web_index_keys) { 192 const WebVector<WebKit::WebIDBDatabase::WebIndexKeys>& web_index_keys) {
196 if (!database_backend_) 193 if (!database_backend_)
197 return; 194 return;
198 195
199 DCHECK_EQ(web_index_ids.size(), web_index_keys.size()); 196 DCHECK_EQ(web_index_ids.size(), web_index_keys.size());
200 std::vector<int64> index_ids(web_index_ids.size()); 197 std::vector<int64> index_ids(web_index_ids.size());
201 std::vector<IndexedDBDatabase::IndexKeys> index_keys(web_index_keys.size()); 198 std::vector<IndexedDBDatabase::IndexKeys> index_keys(web_index_keys.size());
202 199
203 for (size_t i = 0; i < web_index_ids.size(); ++i) { 200 for (size_t i = 0; i < web_index_ids.size(); ++i) {
204 index_ids[i] = web_index_ids[i]; 201 index_ids[i] = web_index_ids[i];
205 IndexedDBKey::KeyArray index_key_list; 202 IndexedDBKey::KeyArray index_key_list;
(...skipping 19 matching lines...) Expand all
225 std::vector<int64> index_ids(web_index_ids.size()); 222 std::vector<int64> index_ids(web_index_ids.size());
226 for (size_t i = 0; i < web_index_ids.size(); ++i) 223 for (size_t i = 0; i < web_index_ids.size(); ++i)
227 index_ids[i] = web_index_ids[i]; 224 index_ids[i] = web_index_ids[i];
228 database_backend_->SetIndexesReady( 225 database_backend_->SetIndexesReady(
229 transaction_id, object_store_id, index_ids); 226 transaction_id, object_store_id, index_ids);
230 } 227 }
231 228
232 void WebIDBDatabaseImpl::deleteRange(long long transaction_id, 229 void WebIDBDatabaseImpl::deleteRange(long long transaction_id,
233 long long object_store_id, 230 long long object_store_id,
234 const WebIDBKeyRange& key_range, 231 const WebIDBKeyRange& key_range,
235 WebIDBCallbacks* callbacks) { 232 IndexedDBCallbacksBase* callbacks) {
236 if (database_backend_) 233 if (database_backend_)
237 database_backend_->DeleteRange( 234 database_backend_->DeleteRange(
238 transaction_id, 235 transaction_id,
239 object_store_id, 236 object_store_id,
240 make_scoped_ptr(new IndexedDBKeyRange(key_range)), 237 make_scoped_ptr(new IndexedDBKeyRange(key_range)),
241 IndexedDBCallbacksWrapper::Create(callbacks)); 238 IndexedDBCallbacksWrapper::Create(callbacks));
242 } 239 }
243 240
244 void WebIDBDatabaseImpl::clear(long long transaction_id, 241 void WebIDBDatabaseImpl::clear(long long transaction_id,
245 long long object_store_id, 242 long long object_store_id,
246 WebIDBCallbacks* callbacks) { 243 IndexedDBCallbacksBase* callbacks) {
247 if (database_backend_) 244 if (database_backend_)
248 database_backend_->Clear(transaction_id, 245 database_backend_->Clear(transaction_id,
249 object_store_id, 246 object_store_id,
250 IndexedDBCallbacksWrapper::Create(callbacks)); 247 IndexedDBCallbacksWrapper::Create(callbacks));
251 } 248 }
252 249
253 void WebIDBDatabaseImpl::createIndex(long long transaction_id, 250 void WebIDBDatabaseImpl::createIndex(long long transaction_id,
254 long long object_store_id, 251 long long object_store_id,
255 long long index_id, 252 long long index_id,
256 const WebString& name, 253 const WebString& name,
(...skipping 11 matching lines...) Expand all
268 } 265 }
269 266
270 void WebIDBDatabaseImpl::deleteIndex(long long transaction_id, 267 void WebIDBDatabaseImpl::deleteIndex(long long transaction_id,
271 long long object_store_id, 268 long long object_store_id,
272 long long index_id) { 269 long long index_id) {
273 if (database_backend_) 270 if (database_backend_)
274 database_backend_->DeleteIndex(transaction_id, object_store_id, index_id); 271 database_backend_->DeleteIndex(transaction_id, object_store_id, index_id);
275 } 272 }
276 273
277 } // namespace WebKit 274 } // namespace WebKit
OLDNEW
« no previous file with comments | « content/browser/indexed_db/webidbdatabase_impl.h ('k') | content/browser/indexed_db/webidbfactory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698