| 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_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_database_error.h" |
| 14 #include "content/browser/indexed_db/indexed_db_metadata.h" | 15 #include "content/browser/indexed_db/indexed_db_metadata.h" |
| 15 #include "content/common/indexed_db/indexed_db_key_range.h" | 16 #include "content/common/indexed_db/indexed_db_key_range.h" |
| 16 #include "third_party/WebKit/public/platform/WebIDBDatabaseError.h" | |
| 17 #include "third_party/WebKit/public/platform/WebString.h" | |
| 18 | |
| 19 using WebKit::WebString; | |
| 20 using WebKit::WebIDBDatabaseError; | |
| 21 | 17 |
| 22 namespace content { | 18 namespace content { |
| 23 | 19 |
| 24 WebIDBDatabaseImpl::WebIDBDatabaseImpl( | 20 WebIDBDatabaseImpl::WebIDBDatabaseImpl( |
| 25 scoped_refptr<IndexedDBDatabase> database_backend, | 21 scoped_refptr<IndexedDBDatabase> database_backend, |
| 26 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks) | 22 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks) |
| 27 : database_backend_(database_backend), | 23 : database_backend_(database_backend), |
| 28 database_callbacks_(database_callbacks) {} | 24 database_callbacks_(database_callbacks) {} |
| 29 | 25 |
| 30 WebIDBDatabaseImpl::~WebIDBDatabaseImpl() {} | 26 WebIDBDatabaseImpl::~WebIDBDatabaseImpl() {} |
| 31 | 27 |
| 32 void WebIDBDatabaseImpl::createObjectStore(long long transaction_id, | 28 void WebIDBDatabaseImpl::createObjectStore(long long transaction_id, |
| 33 long long object_store_id, | 29 long long object_store_id, |
| 34 const WebString& name, | 30 const string16& name, |
| 35 const IndexedDBKeyPath& key_path, | 31 const IndexedDBKeyPath& key_path, |
| 36 bool auto_increment) { | 32 bool auto_increment) { |
| 37 database_backend_->CreateObjectStore(transaction_id, | 33 database_backend_->CreateObjectStore(transaction_id, |
| 38 object_store_id, | 34 object_store_id, |
| 39 name, | 35 name, |
| 40 IndexedDBKeyPath(key_path), | 36 IndexedDBKeyPath(key_path), |
| 41 auto_increment); | 37 auto_increment); |
| 42 } | 38 } |
| 43 | 39 |
| 44 void WebIDBDatabaseImpl::deleteObjectStore(long long transaction_id, | 40 void WebIDBDatabaseImpl::deleteObjectStore(long long transaction_id, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 73 database_callbacks_->OnForcedClose(); | 69 database_callbacks_->OnForcedClose(); |
| 74 database_callbacks_ = NULL; | 70 database_callbacks_ = NULL; |
| 75 } | 71 } |
| 76 | 72 |
| 77 void WebIDBDatabaseImpl::abort(long long transaction_id) { | 73 void WebIDBDatabaseImpl::abort(long long transaction_id) { |
| 78 if (database_backend_.get()) | 74 if (database_backend_.get()) |
| 79 database_backend_->Abort(transaction_id); | 75 database_backend_->Abort(transaction_id); |
| 80 } | 76 } |
| 81 | 77 |
| 82 void WebIDBDatabaseImpl::abort(long long transaction_id, | 78 void WebIDBDatabaseImpl::abort(long long transaction_id, |
| 83 const WebIDBDatabaseError& error) { | 79 const IndexedDBDatabaseError& error) { |
| 84 if (database_backend_.get()) | 80 if (database_backend_.get()) |
| 85 database_backend_->Abort(transaction_id, IndexedDBDatabaseError(error)); | 81 database_backend_->Abort(transaction_id, error); |
| 86 } | 82 } |
| 87 | 83 |
| 88 void WebIDBDatabaseImpl::commit(long long transaction_id) { | 84 void WebIDBDatabaseImpl::commit(long long transaction_id) { |
| 89 if (database_backend_.get()) | 85 if (database_backend_.get()) |
| 90 database_backend_->Commit(transaction_id); | 86 database_backend_->Commit(transaction_id); |
| 91 } | 87 } |
| 92 | 88 |
| 93 void WebIDBDatabaseImpl::openCursor(long long transaction_id, | 89 void WebIDBDatabaseImpl::openCursor(long long transaction_id, |
| 94 long long object_store_id, | 90 long long object_store_id, |
| 95 long long index_id, | 91 long long index_id, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 IndexedDBCallbacksBase* callbacks) { | 206 IndexedDBCallbacksBase* callbacks) { |
| 211 if (database_backend_.get()) | 207 if (database_backend_.get()) |
| 212 database_backend_->Clear(transaction_id, | 208 database_backend_->Clear(transaction_id, |
| 213 object_store_id, | 209 object_store_id, |
| 214 IndexedDBCallbacksWrapper::Create(callbacks)); | 210 IndexedDBCallbacksWrapper::Create(callbacks)); |
| 215 } | 211 } |
| 216 | 212 |
| 217 void WebIDBDatabaseImpl::createIndex(long long transaction_id, | 213 void WebIDBDatabaseImpl::createIndex(long long transaction_id, |
| 218 long long object_store_id, | 214 long long object_store_id, |
| 219 long long index_id, | 215 long long index_id, |
| 220 const WebString& name, | 216 const string16& name, |
| 221 const IndexedDBKeyPath& key_path, | 217 const IndexedDBKeyPath& key_path, |
| 222 bool unique, | 218 bool unique, |
| 223 bool multi_entry) { | 219 bool multi_entry) { |
| 224 if (database_backend_.get()) | 220 if (database_backend_.get()) |
| 225 database_backend_->CreateIndex(transaction_id, | 221 database_backend_->CreateIndex(transaction_id, |
| 226 object_store_id, | 222 object_store_id, |
| 227 index_id, | 223 index_id, |
| 228 name, | 224 name, |
| 229 IndexedDBKeyPath(key_path), | 225 IndexedDBKeyPath(key_path), |
| 230 unique, | 226 unique, |
| 231 multi_entry); | 227 multi_entry); |
| 232 } | 228 } |
| 233 | 229 |
| 234 void WebIDBDatabaseImpl::deleteIndex(long long transaction_id, | 230 void WebIDBDatabaseImpl::deleteIndex(long long transaction_id, |
| 235 long long object_store_id, | 231 long long object_store_id, |
| 236 long long index_id) { | 232 long long index_id) { |
| 237 if (database_backend_.get()) | 233 if (database_backend_.get()) |
| 238 database_backend_->DeleteIndex(transaction_id, object_store_id, index_id); | 234 database_backend_->DeleteIndex(transaction_id, object_store_id, index_id); |
| 239 } | 235 } |
| 240 | 236 |
| 241 } // namespace WebKit | 237 } // namespace WebKit |
| OLD | NEW |