OLD | NEW |
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.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_database_callbacks.h" | 14 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" |
15 #include "content/browser/indexed_db/indexed_db_database_error.h" | 15 #include "content/browser/indexed_db/indexed_db_database_error.h" |
16 #include "content/browser/indexed_db/indexed_db_metadata.h" | 16 #include "content/browser/indexed_db/indexed_db_metadata.h" |
17 #include "content/common/indexed_db/indexed_db_key_range.h" | 17 #include "content/common/indexed_db/indexed_db_key_range.h" |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 | 20 |
21 WebIDBDatabaseImpl::WebIDBDatabaseImpl( | 21 WebIDBDatabaseImpl::WebIDBDatabaseImpl( |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 const IndexedDBDatabaseError& error) { | 79 const IndexedDBDatabaseError& error) { |
80 if (database_backend_.get()) | 80 if (database_backend_.get()) |
81 database_backend_->Abort(transaction_id, error); | 81 database_backend_->Abort(transaction_id, error); |
82 } | 82 } |
83 | 83 |
84 void WebIDBDatabaseImpl::commit(long long transaction_id) { | 84 void WebIDBDatabaseImpl::commit(long long transaction_id) { |
85 if (database_backend_.get()) | 85 if (database_backend_.get()) |
86 database_backend_->Commit(transaction_id); | 86 database_backend_->Commit(transaction_id); |
87 } | 87 } |
88 | 88 |
89 void WebIDBDatabaseImpl::openCursor(long long transaction_id, | 89 void WebIDBDatabaseImpl::openCursor( |
90 long long object_store_id, | 90 long long transaction_id, |
91 long long index_id, | 91 long long object_store_id, |
92 const IndexedDBKeyRange& key_range, | 92 long long index_id, |
93 unsigned short direction, | 93 const IndexedDBKeyRange& key_range, |
94 bool key_only, | 94 unsigned short direction, |
95 WebKit::WebIDBDatabase::TaskType task_type, | 95 bool key_only, |
96 IndexedDBCallbacksBase* callbacks) { | 96 WebKit::WebIDBDatabase::TaskType task_type, |
| 97 scoped_refptr<IndexedDBCallbacks> callbacks) { |
97 if (database_backend_.get()) | 98 if (database_backend_.get()) |
98 database_backend_->OpenCursor( | 99 database_backend_->OpenCursor( |
99 transaction_id, | 100 transaction_id, |
100 object_store_id, | 101 object_store_id, |
101 index_id, | 102 index_id, |
102 make_scoped_ptr(new IndexedDBKeyRange(key_range)), | 103 make_scoped_ptr(new IndexedDBKeyRange(key_range)), |
103 static_cast<indexed_db::CursorDirection>(direction), | 104 static_cast<indexed_db::CursorDirection>(direction), |
104 key_only, | 105 key_only, |
105 static_cast<IndexedDBDatabase::TaskType>(task_type), | 106 static_cast<IndexedDBDatabase::TaskType>(task_type), |
106 IndexedDBCallbacksWrapper::Create(callbacks)); | 107 callbacks); |
107 } | 108 } |
108 | 109 |
109 void WebIDBDatabaseImpl::count(long long transaction_id, | 110 void WebIDBDatabaseImpl::count(long long transaction_id, |
110 long long object_store_id, | 111 long long object_store_id, |
111 long long index_id, | 112 long long index_id, |
112 const IndexedDBKeyRange& key_range, | 113 const IndexedDBKeyRange& key_range, |
113 IndexedDBCallbacksBase* callbacks) { | 114 scoped_refptr<IndexedDBCallbacks> callbacks) { |
114 if (database_backend_.get()) | 115 if (database_backend_.get()) |
115 database_backend_->Count(transaction_id, | 116 database_backend_->Count(transaction_id, |
116 object_store_id, | 117 object_store_id, |
117 index_id, | 118 index_id, |
118 make_scoped_ptr(new IndexedDBKeyRange(key_range)), | 119 make_scoped_ptr(new IndexedDBKeyRange(key_range)), |
119 IndexedDBCallbacksWrapper::Create(callbacks)); | 120 callbacks); |
120 } | 121 } |
121 | 122 |
122 void WebIDBDatabaseImpl::get(long long transaction_id, | 123 void WebIDBDatabaseImpl::get(long long transaction_id, |
123 long long object_store_id, | 124 long long object_store_id, |
124 long long index_id, | 125 long long index_id, |
125 const IndexedDBKeyRange& key_range, | 126 const IndexedDBKeyRange& key_range, |
126 bool key_only, | 127 bool key_only, |
127 IndexedDBCallbacksBase* callbacks) { | 128 scoped_refptr<IndexedDBCallbacks> callbacks) { |
128 if (database_backend_.get()) | 129 if (database_backend_.get()) |
129 database_backend_->Get(transaction_id, | 130 database_backend_->Get(transaction_id, |
130 object_store_id, | 131 object_store_id, |
131 index_id, | 132 index_id, |
132 make_scoped_ptr(new IndexedDBKeyRange(key_range)), | 133 make_scoped_ptr(new IndexedDBKeyRange(key_range)), |
133 key_only, | 134 key_only, |
134 IndexedDBCallbacksWrapper::Create(callbacks)); | 135 callbacks); |
135 } | 136 } |
136 | 137 |
137 void WebIDBDatabaseImpl::put(long long transaction_id, | 138 void WebIDBDatabaseImpl::put(long long transaction_id, |
138 long long object_store_id, | 139 long long object_store_id, |
139 std::vector<char>* value, | 140 std::vector<char>* value, |
140 const IndexedDBKey& key, | 141 const IndexedDBKey& key, |
141 WebKit::WebIDBDatabase::PutMode put_mode, | 142 WebKit::WebIDBDatabase::PutMode put_mode, |
142 IndexedDBCallbacksBase* callbacks, | 143 scoped_refptr<IndexedDBCallbacks> callbacks, |
143 const std::vector<int64>& index_ids, | 144 const std::vector<int64>& index_ids, |
144 const std::vector<IndexKeys>& index_keys) { | 145 const std::vector<IndexKeys>& index_keys) { |
145 if (!database_backend_.get()) | 146 if (!database_backend_.get()) |
146 return; | 147 return; |
147 | 148 |
148 DCHECK_EQ(index_ids.size(), index_keys.size()); | 149 DCHECK_EQ(index_ids.size(), index_keys.size()); |
149 | 150 |
150 database_backend_->Put(transaction_id, | 151 database_backend_->Put(transaction_id, |
151 object_store_id, | 152 object_store_id, |
152 value, | 153 value, |
153 make_scoped_ptr(new IndexedDBKey(key)), | 154 make_scoped_ptr(new IndexedDBKey(key)), |
154 static_cast<IndexedDBDatabase::PutMode>(put_mode), | 155 static_cast<IndexedDBDatabase::PutMode>(put_mode), |
155 IndexedDBCallbacksWrapper::Create(callbacks), | 156 callbacks, |
156 index_ids, | 157 index_ids, |
157 index_keys); | 158 index_keys); |
158 } | 159 } |
159 | 160 |
160 void WebIDBDatabaseImpl::setIndexKeys( | 161 void WebIDBDatabaseImpl::setIndexKeys( |
161 long long transaction_id, | 162 long long transaction_id, |
162 long long object_store_id, | 163 long long object_store_id, |
163 const IndexedDBKey& primary_key, | 164 const IndexedDBKey& primary_key, |
164 const std::vector<int64>& index_ids, | 165 const std::vector<int64>& index_ids, |
165 const std::vector<IndexKeys>& index_keys) { | 166 const std::vector<IndexKeys>& index_keys) { |
(...skipping 16 matching lines...) Expand all Loading... |
182 if (!database_backend_.get()) | 183 if (!database_backend_.get()) |
183 return; | 184 return; |
184 | 185 |
185 std::vector<int64> index_ids(web_index_ids.size()); | 186 std::vector<int64> index_ids(web_index_ids.size()); |
186 for (size_t i = 0; i < web_index_ids.size(); ++i) | 187 for (size_t i = 0; i < web_index_ids.size(); ++i) |
187 index_ids[i] = web_index_ids[i]; | 188 index_ids[i] = web_index_ids[i]; |
188 database_backend_->SetIndexesReady( | 189 database_backend_->SetIndexesReady( |
189 transaction_id, object_store_id, index_ids); | 190 transaction_id, object_store_id, index_ids); |
190 } | 191 } |
191 | 192 |
192 void WebIDBDatabaseImpl::deleteRange(long long transaction_id, | 193 void WebIDBDatabaseImpl::deleteRange( |
193 long long object_store_id, | 194 long long transaction_id, |
194 const IndexedDBKeyRange& key_range, | 195 long long object_store_id, |
195 IndexedDBCallbacksBase* callbacks) { | 196 const IndexedDBKeyRange& key_range, |
| 197 scoped_refptr<IndexedDBCallbacks> callbacks) { |
196 if (database_backend_.get()) | 198 if (database_backend_.get()) |
197 database_backend_->DeleteRange( | 199 database_backend_->DeleteRange( |
198 transaction_id, | 200 transaction_id, |
199 object_store_id, | 201 object_store_id, |
200 make_scoped_ptr(new IndexedDBKeyRange(key_range)), | 202 make_scoped_ptr(new IndexedDBKeyRange(key_range)), |
201 IndexedDBCallbacksWrapper::Create(callbacks)); | 203 callbacks); |
202 } | 204 } |
203 | 205 |
204 void WebIDBDatabaseImpl::clear(long long transaction_id, | 206 void WebIDBDatabaseImpl::clear(long long transaction_id, |
205 long long object_store_id, | 207 long long object_store_id, |
206 IndexedDBCallbacksBase* callbacks) { | 208 scoped_refptr<IndexedDBCallbacks> callbacks) { |
207 if (database_backend_.get()) | 209 if (database_backend_.get()) |
208 database_backend_->Clear(transaction_id, | 210 database_backend_->Clear(transaction_id, object_store_id, callbacks); |
209 object_store_id, | |
210 IndexedDBCallbacksWrapper::Create(callbacks)); | |
211 } | 211 } |
212 | 212 |
213 void WebIDBDatabaseImpl::createIndex(long long transaction_id, | 213 void WebIDBDatabaseImpl::createIndex(long long transaction_id, |
214 long long object_store_id, | 214 long long object_store_id, |
215 long long index_id, | 215 long long index_id, |
216 const string16& name, | 216 const string16& name, |
217 const IndexedDBKeyPath& key_path, | 217 const IndexedDBKeyPath& key_path, |
218 bool unique, | 218 bool unique, |
219 bool multi_entry) { | 219 bool multi_entry) { |
220 if (database_backend_.get()) | 220 if (database_backend_.get()) |
221 database_backend_->CreateIndex(transaction_id, | 221 database_backend_->CreateIndex(transaction_id, |
222 object_store_id, | 222 object_store_id, |
223 index_id, | 223 index_id, |
224 name, | 224 name, |
225 IndexedDBKeyPath(key_path), | 225 IndexedDBKeyPath(key_path), |
226 unique, | 226 unique, |
227 multi_entry); | 227 multi_entry); |
228 } | 228 } |
229 | 229 |
230 void WebIDBDatabaseImpl::deleteIndex(long long transaction_id, | 230 void WebIDBDatabaseImpl::deleteIndex(long long transaction_id, |
231 long long object_store_id, | 231 long long object_store_id, |
232 long long index_id) { | 232 long long index_id) { |
233 if (database_backend_.get()) | 233 if (database_backend_.get()) |
234 database_backend_->DeleteIndex(transaction_id, object_store_id, index_id); | 234 database_backend_->DeleteIndex(transaction_id, object_store_id, index_id); |
235 } | 235 } |
236 | 236 |
237 } // namespace WebKit | 237 } // namespace WebKit |
OLD | NEW |