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 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1589 | 1589 |
1590 // We infer that the database didn't exist from its lack of either type of | 1590 // We infer that the database didn't exist from its lack of either type of |
1591 // version. | 1591 // version. |
1592 bool is_new_database = | 1592 bool is_new_database = |
1593 metadata_.version == kNoStringVersion && | 1593 metadata_.version == kNoStringVersion && |
1594 metadata_.int_version == IndexedDBDatabaseMetadata::NO_INT_VERSION; | 1594 metadata_.int_version == IndexedDBDatabaseMetadata::NO_INT_VERSION; |
1595 | 1595 |
1596 if (version == IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION) { | 1596 if (version == IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION) { |
1597 // For unit tests only - skip upgrade steps. Calling from script with | 1597 // For unit tests only - skip upgrade steps. Calling from script with |
1598 // DEFAULT_INT_VERSION throws exception. | 1598 // DEFAULT_INT_VERSION throws exception. |
1599 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 1599 // TODO(jsbell): DCHECK that not in unit tests. |
jsbell
2013/06/26 17:40:33
This DCHECK actually landed in parallel with the t
| |
1600 DCHECK(is_new_database); | 1600 DCHECK(is_new_database); |
1601 database_callbacks_set_.insert(database_callbacks); | 1601 database_callbacks_set_.insert(database_callbacks); |
1602 callbacks->OnSuccess(this, this->metadata()); | 1602 callbacks->OnSuccess(this, this->metadata()); |
1603 return; | 1603 return; |
1604 } | 1604 } |
1605 | 1605 |
1606 if (version == IndexedDBDatabaseMetadata::NO_INT_VERSION) { | 1606 if (version == IndexedDBDatabaseMetadata::NO_INT_VERSION) { |
1607 if (!is_new_database) { | 1607 if (!is_new_database) { |
1608 database_callbacks_set_.insert(database_callbacks); | 1608 database_callbacks_set_.insert(database_callbacks); |
1609 callbacks->OnSuccess(this, this->metadata()); | 1609 callbacks->OnSuccess(this, this->metadata()); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1799 ProcessPendingCalls(); | 1799 ProcessPendingCalls(); |
1800 | 1800 |
1801 // TODO(jsbell): Add a test for the pending_open_calls_ cases below. | 1801 // TODO(jsbell): Add a test for the pending_open_calls_ cases below. |
1802 if (!ConnectionCount() && !pending_open_calls_.size() && | 1802 if (!ConnectionCount() && !pending_open_calls_.size() && |
1803 !pending_delete_calls_.size()) { | 1803 !pending_delete_calls_.size()) { |
1804 DCHECK(transactions_.empty()); | 1804 DCHECK(transactions_.empty()); |
1805 | 1805 |
1806 backing_store_ = NULL; | 1806 backing_store_ = NULL; |
1807 | 1807 |
1808 // factory_ should only be null in unit tests. | 1808 // factory_ should only be null in unit tests. |
1809 DCHECK(factory_ || | 1809 // TODO(jsbell): DCHECK(factory_ || !in_unit_tests) - somehow. |
1810 !BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | |
jsbell
2013/06/26 17:40:33
Ditto.
| |
1811 if (factory_.get()) | 1810 if (factory_.get()) |
1812 factory_->RemoveIDBDatabaseBackend(identifier_); | 1811 factory_->RemoveIDBDatabaseBackend(identifier_); |
1813 } | 1812 } |
1814 } | 1813 } |
1815 | 1814 |
1816 void CreateObjectStoreAbortOperation::Perform( | 1815 void CreateObjectStoreAbortOperation::Perform( |
1817 IndexedDBTransaction* transaction) { | 1816 IndexedDBTransaction* transaction) { |
1818 IDB_TRACE("CreateObjectStoreAbortOperation"); | 1817 IDB_TRACE("CreateObjectStoreAbortOperation"); |
1819 DCHECK(!transaction); | 1818 DCHECK(!transaction); |
1820 database_->RemoveObjectStore(object_store_id_); | 1819 database_->RemoveObjectStore(object_store_id_); |
1821 } | 1820 } |
1822 | 1821 |
1823 void DeleteObjectStoreAbortOperation::Perform( | 1822 void DeleteObjectStoreAbortOperation::Perform( |
1824 IndexedDBTransaction* transaction) { | 1823 IndexedDBTransaction* transaction) { |
1825 IDB_TRACE("DeleteObjectStoreAbortOperation"); | 1824 IDB_TRACE("DeleteObjectStoreAbortOperation"); |
1826 DCHECK(!transaction); | 1825 DCHECK(!transaction); |
1827 database_->AddObjectStore(object_store_metadata_, | 1826 database_->AddObjectStore(object_store_metadata_, |
1828 IndexedDBObjectStoreMetadata::kInvalidId); | 1827 IndexedDBObjectStoreMetadata::kInvalidId); |
1829 } | 1828 } |
1830 | 1829 |
1831 void IndexedDBDatabase::VersionChangeAbortOperation::Perform( | 1830 void IndexedDBDatabase::VersionChangeAbortOperation::Perform( |
1832 IndexedDBTransaction* transaction) { | 1831 IndexedDBTransaction* transaction) { |
1833 IDB_TRACE("VersionChangeAbortOperation"); | 1832 IDB_TRACE("VersionChangeAbortOperation"); |
1834 DCHECK(!transaction); | 1833 DCHECK(!transaction); |
1835 database_->metadata_.version = previous_version_; | 1834 database_->metadata_.version = previous_version_; |
1836 database_->metadata_.int_version = previous_int_version_; | 1835 database_->metadata_.int_version = previous_int_version_; |
1837 } | 1836 } |
1838 | 1837 |
1839 } // namespace content | 1838 } // namespace content |
OLD | NEW |