| 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/indexed_db_database.h" | 5 #include "content/browser/indexed_db/indexed_db_database.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/auto_reset.h" | 12 #include "base/auto_reset.h" |
| 13 #include "base/command_line.h" | |
| 14 #include "base/logging.h" | 13 #include "base/logging.h" |
| 15 #include "base/macros.h" | 14 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 17 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
| 18 #include "base/numerics/safe_conversions.h" | 17 #include "base/numerics/safe_conversions.h" |
| 19 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
| 20 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 22 #include "content/browser/indexed_db/indexed_db_blob_info.h" | 21 #include "content/browser/indexed_db/indexed_db_blob_info.h" |
| 23 #include "content/browser/indexed_db/indexed_db_class_factory.h" | 22 #include "content/browser/indexed_db/indexed_db_class_factory.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 IndexedDBDatabase::IndexedDBDatabase(const base::string16& name, | 375 IndexedDBDatabase::IndexedDBDatabase(const base::string16& name, |
| 377 IndexedDBBackingStore* backing_store, | 376 IndexedDBBackingStore* backing_store, |
| 378 IndexedDBFactory* factory, | 377 IndexedDBFactory* factory, |
| 379 const Identifier& unique_identifier) | 378 const Identifier& unique_identifier) |
| 380 : backing_store_(backing_store), | 379 : backing_store_(backing_store), |
| 381 metadata_(name, | 380 metadata_(name, |
| 382 kInvalidId, | 381 kInvalidId, |
| 383 IndexedDBDatabaseMetadata::NO_VERSION, | 382 IndexedDBDatabaseMetadata::NO_VERSION, |
| 384 kInvalidId), | 383 kInvalidId), |
| 385 identifier_(unique_identifier), | 384 identifier_(unique_identifier), |
| 386 factory_(factory), | 385 factory_(factory) { |
| 387 experimental_web_platform_features_enabled_( | |
| 388 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 389 switches::kEnableExperimentalWebPlatformFeatures)) { | |
| 390 DCHECK(factory != NULL); | 386 DCHECK(factory != NULL); |
| 391 } | 387 } |
| 392 | 388 |
| 393 void IndexedDBDatabase::AddObjectStore( | 389 void IndexedDBDatabase::AddObjectStore( |
| 394 const IndexedDBObjectStoreMetadata& object_store, | 390 const IndexedDBObjectStoreMetadata& object_store, |
| 395 int64_t new_max_object_store_id) { | 391 int64_t new_max_object_store_id) { |
| 396 DCHECK(metadata_.object_stores.find(object_store.id) == | 392 DCHECK(metadata_.object_stores.find(object_store.id) == |
| 397 metadata_.object_stores.end()); | 393 metadata_.object_stores.end()); |
| 398 if (new_max_object_store_id != IndexedDBObjectStoreMetadata::kInvalidId) { | 394 if (new_max_object_store_id != IndexedDBObjectStoreMetadata::kInvalidId) { |
| 399 DCHECK_LT(metadata_.max_object_store_id, new_max_object_store_id); | 395 DCHECK_LT(metadata_.max_object_store_id, new_max_object_store_id); |
| (...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 base::string16 error_string = | 1827 base::string16 error_string = |
| 1832 ASCIIToUTF16("Internal error deleting data in range"); | 1828 ASCIIToUTF16("Internal error deleting data in range"); |
| 1833 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 1829 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| 1834 error_string); | 1830 error_string); |
| 1835 transaction->Abort(error); | 1831 transaction->Abort(error); |
| 1836 if (s.IsCorruption()) { | 1832 if (s.IsCorruption()) { |
| 1837 factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); | 1833 factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
| 1838 } | 1834 } |
| 1839 return; | 1835 return; |
| 1840 } | 1836 } |
| 1841 if (experimental_web_platform_features_enabled_) { | 1837 callbacks->OnSuccess(); |
| 1842 callbacks->OnSuccess(base::checked_cast<int64_t>(delete_count)); | |
| 1843 } else { | |
| 1844 callbacks->OnSuccess(); | |
| 1845 } | |
| 1846 FilterObservation(transaction, object_store_id, blink::WebIDBDelete, | 1838 FilterObservation(transaction, object_store_id, blink::WebIDBDelete, |
| 1847 *key_range); | 1839 *key_range); |
| 1848 } | 1840 } |
| 1849 | 1841 |
| 1850 void IndexedDBDatabase::Clear(int64_t transaction_id, | 1842 void IndexedDBDatabase::Clear(int64_t transaction_id, |
| 1851 int64_t object_store_id, | 1843 int64_t object_store_id, |
| 1852 scoped_refptr<IndexedDBCallbacks> callbacks) { | 1844 scoped_refptr<IndexedDBCallbacks> callbacks) { |
| 1853 IDB_TRACE1("IndexedDBDatabase::Clear", "txn.id", transaction_id); | 1845 IDB_TRACE1("IndexedDBDatabase::Clear", "txn.id", transaction_id); |
| 1854 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 1846 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
| 1855 if (!transaction) | 1847 if (!transaction) |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2133 | 2125 |
| 2134 void IndexedDBDatabase::VersionChangeAbortOperation( | 2126 void IndexedDBDatabase::VersionChangeAbortOperation( |
| 2135 int64_t previous_version, | 2127 int64_t previous_version, |
| 2136 IndexedDBTransaction* transaction) { | 2128 IndexedDBTransaction* transaction) { |
| 2137 DCHECK(!transaction); | 2129 DCHECK(!transaction); |
| 2138 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); | 2130 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); |
| 2139 metadata_.version = previous_version; | 2131 metadata_.version = previous_version; |
| 2140 } | 2132 } |
| 2141 | 2133 |
| 2142 } // namespace content | 2134 } // namespace content |
| OLD | NEW |