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

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

Issue 18221003: Convert WebIDBDatabaseImpl to IndexedDBConnection (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review feedback 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
« no previous file with comments | « content/browser/indexed_db/webidbdatabase_impl.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/indexed_db/webidbdatabase_impl.h"
6
7 #include <vector>
8
9 #include "base/basictypes.h"
10 #include "base/logging.h"
11 #include "content/browser/indexed_db/indexed_db_callbacks.h"
12 #include "content/browser/indexed_db/indexed_db_cursor.h"
13 #include "content/browser/indexed_db/indexed_db_database_error.h"
14 #include "content/browser/indexed_db/indexed_db_metadata.h"
15 #include "content/common/indexed_db/indexed_db_key_range.h"
16
17 namespace content {
18
19 WebIDBDatabaseImpl::WebIDBDatabaseImpl(
20 scoped_refptr<IndexedDBDatabase> database_backend,
21 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks)
22 : database_backend_(database_backend),
23 database_callbacks_(database_callbacks) {}
24
25 WebIDBDatabaseImpl::~WebIDBDatabaseImpl() {}
26
27 void WebIDBDatabaseImpl::createObjectStore(long long transaction_id,
28 long long object_store_id,
29 const string16& name,
30 const IndexedDBKeyPath& key_path,
31 bool auto_increment) {
32 database_backend_->CreateObjectStore(transaction_id,
33 object_store_id,
34 name,
35 IndexedDBKeyPath(key_path),
36 auto_increment);
37 }
38
39 void WebIDBDatabaseImpl::deleteObjectStore(long long transaction_id,
40 long long object_store_id) {
41 database_backend_->DeleteObjectStore(transaction_id, object_store_id);
42 }
43
44 void WebIDBDatabaseImpl::createTransaction(
45 long long id,
46 const std::vector<int64>& object_store_ids,
47 unsigned short mode) {
48 if (!database_callbacks_.get())
49 return;
50 database_backend_->CreateTransaction(
51 id, database_callbacks_.get(), object_store_ids, mode);
52 }
53
54 void WebIDBDatabaseImpl::close() {
55 // Use the callbacks passed in to the constructor so that the backend in
56 // multi-process chromium knows which database connection is closing.
57 if (!database_callbacks_.get())
58 return;
59 database_backend_->Close(database_callbacks_);
60 database_callbacks_ = NULL;
61 }
62
63 void WebIDBDatabaseImpl::forceClose() {
64 if (!database_callbacks_.get())
65 return;
66 database_backend_->Close(database_callbacks_);
67 database_callbacks_->OnForcedClose();
68 database_callbacks_ = NULL;
69 }
70
71 void WebIDBDatabaseImpl::abort(long long transaction_id) {
72 if (database_backend_.get())
73 database_backend_->Abort(transaction_id);
74 }
75
76 void WebIDBDatabaseImpl::abort(long long transaction_id,
77 const IndexedDBDatabaseError& error) {
78 if (database_backend_.get())
79 database_backend_->Abort(transaction_id, error);
80 }
81
82 void WebIDBDatabaseImpl::commit(long long transaction_id) {
83 if (database_backend_.get())
84 database_backend_->Commit(transaction_id);
85 }
86
87 void WebIDBDatabaseImpl::openCursor(
88 long long transaction_id,
89 long long object_store_id,
90 long long index_id,
91 const IndexedDBKeyRange& key_range,
92 unsigned short direction,
93 bool key_only,
94 WebKit::WebIDBDatabase::TaskType task_type,
95 scoped_refptr<IndexedDBCallbacks> callbacks) {
96 if (database_backend_.get())
97 database_backend_->OpenCursor(
98 transaction_id,
99 object_store_id,
100 index_id,
101 make_scoped_ptr(new IndexedDBKeyRange(key_range)),
102 static_cast<indexed_db::CursorDirection>(direction),
103 key_only,
104 static_cast<IndexedDBDatabase::TaskType>(task_type),
105 callbacks);
106 }
107
108 void WebIDBDatabaseImpl::count(long long transaction_id,
109 long long object_store_id,
110 long long index_id,
111 const IndexedDBKeyRange& key_range,
112 scoped_refptr<IndexedDBCallbacks> callbacks) {
113 if (database_backend_.get())
114 database_backend_->Count(transaction_id,
115 object_store_id,
116 index_id,
117 make_scoped_ptr(new IndexedDBKeyRange(key_range)),
118 callbacks);
119 }
120
121 void WebIDBDatabaseImpl::get(long long transaction_id,
122 long long object_store_id,
123 long long index_id,
124 const IndexedDBKeyRange& key_range,
125 bool key_only,
126 scoped_refptr<IndexedDBCallbacks> callbacks) {
127 if (database_backend_.get())
128 database_backend_->Get(transaction_id,
129 object_store_id,
130 index_id,
131 make_scoped_ptr(new IndexedDBKeyRange(key_range)),
132 key_only,
133 callbacks);
134 }
135
136 void WebIDBDatabaseImpl::put(long long transaction_id,
137 long long object_store_id,
138 std::vector<char>* value,
139 const IndexedDBKey& key,
140 WebKit::WebIDBDatabase::PutMode put_mode,
141 scoped_refptr<IndexedDBCallbacks> callbacks,
142 const std::vector<int64>& index_ids,
143 const std::vector<IndexKeys>& index_keys) {
144 if (!database_backend_.get())
145 return;
146
147 DCHECK_EQ(index_ids.size(), index_keys.size());
148
149 database_backend_->Put(transaction_id,
150 object_store_id,
151 value,
152 make_scoped_ptr(new IndexedDBKey(key)),
153 static_cast<IndexedDBDatabase::PutMode>(put_mode),
154 callbacks,
155 index_ids,
156 index_keys);
157 }
158
159 void WebIDBDatabaseImpl::setIndexKeys(
160 long long transaction_id,
161 long long object_store_id,
162 const IndexedDBKey& primary_key,
163 const std::vector<int64>& index_ids,
164 const std::vector<IndexKeys>& index_keys) {
165 if (!database_backend_.get())
166 return;
167
168 DCHECK_EQ(index_ids.size(), index_keys.size());
169 database_backend_->SetIndexKeys(
170 transaction_id,
171 object_store_id,
172 make_scoped_ptr(new IndexedDBKey(primary_key)),
173 index_ids,
174 index_keys);
175 }
176
177 void WebIDBDatabaseImpl::setIndexesReady(
178 long long transaction_id,
179 long long object_store_id,
180 const std::vector<int64>& web_index_ids) {
181 if (!database_backend_.get())
182 return;
183
184 std::vector<int64> index_ids(web_index_ids.size());
185 for (size_t i = 0; i < web_index_ids.size(); ++i)
186 index_ids[i] = web_index_ids[i];
187 database_backend_->SetIndexesReady(
188 transaction_id, object_store_id, index_ids);
189 }
190
191 void WebIDBDatabaseImpl::deleteRange(
192 long long transaction_id,
193 long long object_store_id,
194 const IndexedDBKeyRange& key_range,
195 scoped_refptr<IndexedDBCallbacks> callbacks) {
196 if (database_backend_.get())
197 database_backend_->DeleteRange(
198 transaction_id,
199 object_store_id,
200 make_scoped_ptr(new IndexedDBKeyRange(key_range)),
201 callbacks);
202 }
203
204 void WebIDBDatabaseImpl::clear(long long transaction_id,
205 long long object_store_id,
206 scoped_refptr<IndexedDBCallbacks> callbacks) {
207 if (database_backend_.get())
208 database_backend_->Clear(transaction_id, object_store_id, callbacks);
209 }
210
211 void WebIDBDatabaseImpl::createIndex(long long transaction_id,
212 long long object_store_id,
213 long long index_id,
214 const string16& name,
215 const IndexedDBKeyPath& key_path,
216 bool unique,
217 bool multi_entry) {
218 if (database_backend_.get())
219 database_backend_->CreateIndex(transaction_id,
220 object_store_id,
221 index_id,
222 name,
223 IndexedDBKeyPath(key_path),
224 unique,
225 multi_entry);
226 }
227
228 void WebIDBDatabaseImpl::deleteIndex(long long transaction_id,
229 long long object_store_id,
230 long long index_id) {
231 if (database_backend_.get())
232 database_backend_->DeleteIndex(transaction_id, object_store_id, index_id);
233 }
234
235 } // namespace WebKit
OLDNEW
« no previous file with comments | « content/browser/indexed_db/webidbdatabase_impl.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698