| 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 <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 return NULL; | 143 return NULL; |
| 144 } | 144 } |
| 145 | 145 |
| 146 IndexedDBDatabase::IndexedDBDatabase(const base::string16& name, | 146 IndexedDBDatabase::IndexedDBDatabase(const base::string16& name, |
| 147 IndexedDBBackingStore* backing_store, | 147 IndexedDBBackingStore* backing_store, |
| 148 IndexedDBFactory* factory, | 148 IndexedDBFactory* factory, |
| 149 const Identifier& unique_identifier) | 149 const Identifier& unique_identifier) |
| 150 : backing_store_(backing_store), | 150 : backing_store_(backing_store), |
| 151 metadata_(name, | 151 metadata_(name, |
| 152 kInvalidId, | 152 kInvalidId, |
| 153 IndexedDBDatabaseMetadata::NO_INT_VERSION, | 153 IndexedDBDatabaseMetadata::NO_VERSION, |
| 154 kInvalidId), | 154 kInvalidId), |
| 155 identifier_(unique_identifier), | 155 identifier_(unique_identifier), |
| 156 factory_(factory) { | 156 factory_(factory) { |
| 157 DCHECK(factory != NULL); | 157 DCHECK(factory != NULL); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void IndexedDBDatabase::AddObjectStore( | 160 void IndexedDBDatabase::AddObjectStore( |
| 161 const IndexedDBObjectStoreMetadata& object_store, | 161 const IndexedDBObjectStoreMetadata& object_store, |
| 162 int64_t new_max_object_store_id) { | 162 int64_t new_max_object_store_id) { |
| 163 DCHECK(metadata_.object_stores.find(object_store.id) == | 163 DCHECK(metadata_.object_stores.find(object_store.id) == |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 metadata_.name, &metadata_, &success); | 209 metadata_.name, &metadata_, &success); |
| 210 DCHECK(success == (metadata_.id != kInvalidId)) << "success = " << success | 210 DCHECK(success == (metadata_.id != kInvalidId)) << "success = " << success |
| 211 << " id = " << metadata_.id; | 211 << " id = " << metadata_.id; |
| 212 if (!s.ok()) | 212 if (!s.ok()) |
| 213 return s; | 213 return s; |
| 214 if (success) | 214 if (success) |
| 215 return backing_store_->GetObjectStores(metadata_.id, | 215 return backing_store_->GetObjectStores(metadata_.id, |
| 216 &metadata_.object_stores); | 216 &metadata_.object_stores); |
| 217 | 217 |
| 218 return backing_store_->CreateIDBDatabaseMetaData( | 218 return backing_store_->CreateIDBDatabaseMetaData( |
| 219 metadata_.name, metadata_.int_version, &metadata_.id); | 219 metadata_.name, metadata_.version, &metadata_.id); |
| 220 } | 220 } |
| 221 | 221 |
| 222 IndexedDBDatabase::~IndexedDBDatabase() { | 222 IndexedDBDatabase::~IndexedDBDatabase() { |
| 223 DCHECK(transactions_.empty()); | 223 DCHECK(transactions_.empty()); |
| 224 DCHECK(pending_open_calls_.empty()); | 224 DCHECK(pending_open_calls_.empty()); |
| 225 DCHECK(pending_delete_calls_.empty()); | 225 DCHECK(pending_delete_calls_.empty()); |
| 226 } | 226 } |
| 227 | 227 |
| 228 size_t IndexedDBDatabase::GetMaxMessageSizeInBytes() const { | 228 size_t IndexedDBDatabase::GetMaxMessageSizeInBytes() const { |
| 229 return kMaxIDBMessageSizeInBytes; | 229 return kMaxIDBMessageSizeInBytes; |
| (...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1509 object_store_metadata)); | 1509 object_store_metadata)); |
| 1510 } | 1510 } |
| 1511 | 1511 |
| 1512 void IndexedDBDatabase::VersionChangeOperation( | 1512 void IndexedDBDatabase::VersionChangeOperation( |
| 1513 int64_t version, | 1513 int64_t version, |
| 1514 scoped_refptr<IndexedDBCallbacks> callbacks, | 1514 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 1515 scoped_ptr<IndexedDBConnection> connection, | 1515 scoped_ptr<IndexedDBConnection> connection, |
| 1516 IndexedDBTransaction* transaction) { | 1516 IndexedDBTransaction* transaction) { |
| 1517 IDB_TRACE1( | 1517 IDB_TRACE1( |
| 1518 "IndexedDBDatabase::VersionChangeOperation", "txn.id", transaction->id()); | 1518 "IndexedDBDatabase::VersionChangeOperation", "txn.id", transaction->id()); |
| 1519 int64_t old_version = metadata_.int_version; | 1519 int64_t old_version = metadata_.version; |
| 1520 DCHECK_GT(version, old_version); | 1520 DCHECK_GT(version, old_version); |
| 1521 | 1521 |
| 1522 if (!backing_store_->UpdateIDBDatabaseIntVersion( | 1522 if (!backing_store_->UpdateIDBDatabaseIntVersion( |
| 1523 transaction->BackingStoreTransaction(), id(), version)) { | 1523 transaction->BackingStoreTransaction(), id(), version)) { |
| 1524 IndexedDBDatabaseError error( | 1524 IndexedDBDatabaseError error( |
| 1525 blink::WebIDBDatabaseExceptionUnknownError, | 1525 blink::WebIDBDatabaseExceptionUnknownError, |
| 1526 ASCIIToUTF16( | 1526 ASCIIToUTF16( |
| 1527 "Internal error writing data to stable storage when " | 1527 "Internal error writing data to stable storage when " |
| 1528 "updating version.")); | 1528 "updating version.")); |
| 1529 callbacks->OnError(error); | 1529 callbacks->OnError(error); |
| 1530 transaction->Abort(error); | 1530 transaction->Abort(error); |
| 1531 return; | 1531 return; |
| 1532 } | 1532 } |
| 1533 | 1533 |
| 1534 transaction->ScheduleAbortTask( | 1534 transaction->ScheduleAbortTask( |
| 1535 base::Bind(&IndexedDBDatabase::VersionChangeAbortOperation, | 1535 base::Bind(&IndexedDBDatabase::VersionChangeAbortOperation, this, |
| 1536 this, | 1536 metadata_.version)); |
| 1537 metadata_.int_version)); | 1537 metadata_.version = version; |
| 1538 metadata_.int_version = version; | |
| 1539 | 1538 |
| 1540 DCHECK(!pending_second_half_open_); | 1539 DCHECK(!pending_second_half_open_); |
| 1541 pending_second_half_open_.reset( | 1540 pending_second_half_open_.reset( |
| 1542 new PendingSuccessCall(callbacks, connection.get(), version)); | 1541 new PendingSuccessCall(callbacks, connection.get(), version)); |
| 1543 callbacks->OnUpgradeNeeded(old_version, std::move(connection), metadata()); | 1542 callbacks->OnUpgradeNeeded(old_version, std::move(connection), metadata()); |
| 1544 } | 1543 } |
| 1545 | 1544 |
| 1546 void IndexedDBDatabase::TransactionFinished(IndexedDBTransaction* transaction, | 1545 void IndexedDBDatabase::TransactionFinished(IndexedDBTransaction* transaction, |
| 1547 bool committed) { | 1546 bool committed) { |
| 1548 IDB_TRACE1("IndexedDBTransaction::TransactionFinished", "txn.id", id()); | 1547 IDB_TRACE1("IndexedDBTransaction::TransactionFinished", "txn.id", id()); |
| 1549 DCHECK(transactions_.find(transaction->id()) != transactions_.end()); | 1548 DCHECK(transactions_.find(transaction->id()) != transactions_.end()); |
| 1550 DCHECK_EQ(transactions_[transaction->id()], transaction); | 1549 DCHECK_EQ(transactions_[transaction->id()], transaction); |
| 1551 transactions_.erase(transaction->id()); | 1550 transactions_.erase(transaction->id()); |
| 1552 | 1551 |
| 1553 if (transaction->mode() == blink::WebIDBTransactionModeVersionChange) { | 1552 if (transaction->mode() == blink::WebIDBTransactionModeVersionChange) { |
| 1554 if (pending_second_half_open_) { | 1553 if (pending_second_half_open_) { |
| 1555 if (committed) { | 1554 if (committed) { |
| 1556 DCHECK_EQ(pending_second_half_open_->version(), metadata_.int_version); | 1555 DCHECK_EQ(pending_second_half_open_->version(), metadata_.version); |
| 1557 DCHECK(metadata_.id != kInvalidId); | 1556 DCHECK(metadata_.id != kInvalidId); |
| 1558 | 1557 |
| 1559 // Connection was already minted for OnUpgradeNeeded callback. | 1558 // Connection was already minted for OnUpgradeNeeded callback. |
| 1560 scoped_ptr<IndexedDBConnection> connection; | 1559 scoped_ptr<IndexedDBConnection> connection; |
| 1561 pending_second_half_open_->callbacks()->OnSuccess(std::move(connection), | 1560 pending_second_half_open_->callbacks()->OnSuccess(std::move(connection), |
| 1562 this->metadata()); | 1561 this->metadata()); |
| 1563 } else { | 1562 } else { |
| 1564 pending_second_half_open_->callbacks()->OnError( | 1563 pending_second_half_open_->callbacks()->OnError( |
| 1565 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionAbortError, | 1564 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionAbortError, |
| 1566 "Version change transaction was aborted in " | 1565 "Version change transaction was aborted in " |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1602 return pending_second_half_open_ ? 1 : 0; | 1601 return pending_second_half_open_ ? 1 : 0; |
| 1603 } | 1602 } |
| 1604 | 1603 |
| 1605 size_t IndexedDBDatabase::PendingDeleteCount() const { | 1604 size_t IndexedDBDatabase::PendingDeleteCount() const { |
| 1606 return pending_delete_calls_.size(); | 1605 return pending_delete_calls_.size(); |
| 1607 } | 1606 } |
| 1608 | 1607 |
| 1609 void IndexedDBDatabase::ProcessPendingCalls() { | 1608 void IndexedDBDatabase::ProcessPendingCalls() { |
| 1610 if (pending_run_version_change_transaction_call_ && ConnectionCount() == 1) { | 1609 if (pending_run_version_change_transaction_call_ && ConnectionCount() == 1) { |
| 1611 DCHECK(pending_run_version_change_transaction_call_->version() > | 1610 DCHECK(pending_run_version_change_transaction_call_->version() > |
| 1612 metadata_.int_version); | 1611 metadata_.version); |
| 1613 scoped_ptr<PendingUpgradeCall> pending_call = | 1612 scoped_ptr<PendingUpgradeCall> pending_call = |
| 1614 std::move(pending_run_version_change_transaction_call_); | 1613 std::move(pending_run_version_change_transaction_call_); |
| 1615 RunVersionChangeTransactionFinal(pending_call->callbacks(), | 1614 RunVersionChangeTransactionFinal(pending_call->callbacks(), |
| 1616 pending_call->ReleaseConnection(), | 1615 pending_call->ReleaseConnection(), |
| 1617 pending_call->transaction_id(), | 1616 pending_call->transaction_id(), |
| 1618 pending_call->version()); | 1617 pending_call->version()); |
| 1619 DCHECK_EQ(1u, ConnectionCount()); | 1618 DCHECK_EQ(1u, ConnectionCount()); |
| 1620 // Fall through would be a no-op, since transaction must complete | 1619 // Fall through would be a no-op, since transaction must complete |
| 1621 // asynchronously. | 1620 // asynchronously. |
| 1622 DCHECK(IsDeleteDatabaseBlocked()); | 1621 DCHECK(IsDeleteDatabaseBlocked()); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1695 // so there'd better not be any. | 1694 // so there'd better not be any. |
| 1696 DCHECK_NE(blink::WebIDBDataLossTotal, connection.callbacks->data_loss()); | 1695 DCHECK_NE(blink::WebIDBDataLossTotal, connection.callbacks->data_loss()); |
| 1697 pending_open_calls_.push_back(connection); | 1696 pending_open_calls_.push_back(connection); |
| 1698 return; | 1697 return; |
| 1699 } | 1698 } |
| 1700 | 1699 |
| 1701 if (metadata_.id == kInvalidId) { | 1700 if (metadata_.id == kInvalidId) { |
| 1702 // The database was deleted then immediately re-opened; OpenInternal() | 1701 // The database was deleted then immediately re-opened; OpenInternal() |
| 1703 // recreates it in the backing store. | 1702 // recreates it in the backing store. |
| 1704 if (OpenInternal().ok()) { | 1703 if (OpenInternal().ok()) { |
| 1705 DCHECK_EQ(IndexedDBDatabaseMetadata::NO_INT_VERSION, | 1704 DCHECK_EQ(IndexedDBDatabaseMetadata::NO_VERSION, metadata_.version); |
| 1706 metadata_.int_version); | |
| 1707 } else { | 1705 } else { |
| 1708 base::string16 message; | 1706 base::string16 message; |
| 1709 if (connection.version == IndexedDBDatabaseMetadata::NO_INT_VERSION) { | 1707 if (connection.version == IndexedDBDatabaseMetadata::NO_VERSION) { |
| 1710 message = ASCIIToUTF16( | 1708 message = ASCIIToUTF16( |
| 1711 "Internal error opening database with no version specified."); | 1709 "Internal error opening database with no version specified."); |
| 1712 } else { | 1710 } else { |
| 1713 message = | 1711 message = |
| 1714 ASCIIToUTF16("Internal error opening database with version ") + | 1712 ASCIIToUTF16("Internal error opening database with version ") + |
| 1715 Int64ToString16(connection.version); | 1713 Int64ToString16(connection.version); |
| 1716 } | 1714 } |
| 1717 connection.callbacks->OnError(IndexedDBDatabaseError( | 1715 connection.callbacks->OnError(IndexedDBDatabaseError( |
| 1718 blink::WebIDBDatabaseExceptionUnknownError, message)); | 1716 blink::WebIDBDatabaseExceptionUnknownError, message)); |
| 1719 return; | 1717 return; |
| 1720 } | 1718 } |
| 1721 } | 1719 } |
| 1722 | 1720 |
| 1723 // We infer that the database didn't exist from its lack of either type of | 1721 // We infer that the database didn't exist from its lack of either type of |
| 1724 // version. | 1722 // version. |
| 1725 bool is_new_database = | 1723 bool is_new_database = |
| 1726 metadata_.int_version == IndexedDBDatabaseMetadata::NO_INT_VERSION; | 1724 metadata_.version == IndexedDBDatabaseMetadata::NO_VERSION; |
| 1727 | 1725 |
| 1728 if (connection.version == IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION) { | 1726 if (connection.version == IndexedDBDatabaseMetadata::DEFAULT_VERSION) { |
| 1729 // For unit tests only - skip upgrade steps. Calling from script with | 1727 // For unit tests only - skip upgrade steps. Calling from script with |
| 1730 // DEFAULT_INT_VERSION throws exception. | 1728 // DEFAULT_VERSION throws exception. |
| 1731 // TODO(jsbell): DCHECK that not in unit tests. | 1729 // TODO(jsbell): DCHECK that not in unit tests. |
| 1732 DCHECK(is_new_database); | 1730 DCHECK(is_new_database); |
| 1733 connection.callbacks->OnSuccess( | 1731 connection.callbacks->OnSuccess( |
| 1734 CreateConnection(connection.database_callbacks, | 1732 CreateConnection(connection.database_callbacks, |
| 1735 connection.child_process_id), | 1733 connection.child_process_id), |
| 1736 this->metadata()); | 1734 this->metadata()); |
| 1737 return; | 1735 return; |
| 1738 } | 1736 } |
| 1739 | 1737 |
| 1740 // We may need to change the version. | 1738 // We may need to change the version. |
| 1741 int64_t local_version = connection.version; | 1739 int64_t local_version = connection.version; |
| 1742 if (local_version == IndexedDBDatabaseMetadata::NO_INT_VERSION) { | 1740 if (local_version == IndexedDBDatabaseMetadata::NO_VERSION) { |
| 1743 if (!is_new_database) { | 1741 if (!is_new_database) { |
| 1744 connection.callbacks->OnSuccess( | 1742 connection.callbacks->OnSuccess( |
| 1745 CreateConnection(connection.database_callbacks, | 1743 CreateConnection(connection.database_callbacks, |
| 1746 connection.child_process_id), | 1744 connection.child_process_id), |
| 1747 this->metadata()); | 1745 this->metadata()); |
| 1748 return; | 1746 return; |
| 1749 } | 1747 } |
| 1750 // Spec says: If no version is specified and no database exists, set | 1748 // Spec says: If no version is specified and no database exists, set |
| 1751 // database version to 1. | 1749 // database version to 1. |
| 1752 local_version = 1; | 1750 local_version = 1; |
| 1753 } | 1751 } |
| 1754 | 1752 |
| 1755 if (local_version > metadata_.int_version) { | 1753 if (local_version > metadata_.version) { |
| 1756 RunVersionChangeTransaction(connection.callbacks, | 1754 RunVersionChangeTransaction(connection.callbacks, |
| 1757 CreateConnection(connection.database_callbacks, | 1755 CreateConnection(connection.database_callbacks, |
| 1758 connection.child_process_id), | 1756 connection.child_process_id), |
| 1759 connection.transaction_id, | 1757 connection.transaction_id, |
| 1760 local_version); | 1758 local_version); |
| 1761 return; | 1759 return; |
| 1762 } | 1760 } |
| 1763 if (local_version < metadata_.int_version) { | 1761 if (local_version < metadata_.version) { |
| 1764 connection.callbacks->OnError(IndexedDBDatabaseError( | 1762 connection.callbacks->OnError(IndexedDBDatabaseError( |
| 1765 blink::WebIDBDatabaseExceptionVersionError, | 1763 blink::WebIDBDatabaseExceptionVersionError, |
| 1766 ASCIIToUTF16("The requested version (") + | 1764 ASCIIToUTF16("The requested version (") + |
| 1767 Int64ToString16(local_version) + | 1765 Int64ToString16(local_version) + |
| 1768 ASCIIToUTF16(") is less than the existing version (") + | 1766 ASCIIToUTF16(") is less than the existing version (") + |
| 1769 Int64ToString16(metadata_.int_version) + ASCIIToUTF16(")."))); | 1767 Int64ToString16(metadata_.version) + ASCIIToUTF16(")."))); |
| 1770 return; | 1768 return; |
| 1771 } | 1769 } |
| 1772 DCHECK_EQ(local_version, metadata_.int_version); | 1770 DCHECK_EQ(local_version, metadata_.version); |
| 1773 connection.callbacks->OnSuccess( | 1771 connection.callbacks->OnSuccess( |
| 1774 CreateConnection(connection.database_callbacks, | 1772 CreateConnection(connection.database_callbacks, |
| 1775 connection.child_process_id), | 1773 connection.child_process_id), |
| 1776 this->metadata()); | 1774 this->metadata()); |
| 1777 } | 1775 } |
| 1778 | 1776 |
| 1779 void IndexedDBDatabase::RunVersionChangeTransaction( | 1777 void IndexedDBDatabase::RunVersionChangeTransaction( |
| 1780 scoped_refptr<IndexedDBCallbacks> callbacks, | 1778 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 1781 scoped_ptr<IndexedDBConnection> connection, | 1779 scoped_ptr<IndexedDBConnection> connection, |
| 1782 int64_t transaction_id, | 1780 int64_t transaction_id, |
| 1783 int64_t requested_version) { | 1781 int64_t requested_version) { |
| 1784 DCHECK(callbacks.get()); | 1782 DCHECK(callbacks.get()); |
| 1785 DCHECK(connections_.count(connection.get())); | 1783 DCHECK(connections_.count(connection.get())); |
| 1786 if (ConnectionCount() > 1) { | 1784 if (ConnectionCount() > 1) { |
| 1787 DCHECK_NE(blink::WebIDBDataLossTotal, callbacks->data_loss()); | 1785 DCHECK_NE(blink::WebIDBDataLossTotal, callbacks->data_loss()); |
| 1788 // Front end ensures the event is not fired at connections that have | 1786 // Front end ensures the event is not fired at connections that have |
| 1789 // close_pending set. | 1787 // close_pending set. |
| 1790 for (const auto* iter : connections_) { | 1788 for (const auto* iter : connections_) { |
| 1791 if (iter != connection.get()) { | 1789 if (iter != connection.get()) { |
| 1792 iter->callbacks()->OnVersionChange(metadata_.int_version, | 1790 iter->callbacks()->OnVersionChange(metadata_.version, |
| 1793 requested_version); | 1791 requested_version); |
| 1794 } | 1792 } |
| 1795 } | 1793 } |
| 1796 // OnBlocked will be fired at the request when one of the other | 1794 // OnBlocked will be fired at the request when one of the other |
| 1797 // connections acks that the OnVersionChange was ignored. | 1795 // connections acks that the OnVersionChange was ignored. |
| 1798 | 1796 |
| 1799 DCHECK(!pending_run_version_change_transaction_call_); | 1797 DCHECK(!pending_run_version_change_transaction_call_); |
| 1800 pending_run_version_change_transaction_call_.reset(new PendingUpgradeCall( | 1798 pending_run_version_change_transaction_call_.reset(new PendingUpgradeCall( |
| 1801 callbacks, std::move(connection), transaction_id, requested_version)); | 1799 callbacks, std::move(connection), transaction_id, requested_version)); |
| 1802 return; | 1800 return; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1826 } | 1824 } |
| 1827 | 1825 |
| 1828 void IndexedDBDatabase::DeleteDatabase( | 1826 void IndexedDBDatabase::DeleteDatabase( |
| 1829 scoped_refptr<IndexedDBCallbacks> callbacks) { | 1827 scoped_refptr<IndexedDBCallbacks> callbacks) { |
| 1830 | 1828 |
| 1831 if (IsDeleteDatabaseBlocked()) { | 1829 if (IsDeleteDatabaseBlocked()) { |
| 1832 for (const auto* connection : connections_) { | 1830 for (const auto* connection : connections_) { |
| 1833 // Front end ensures the event is not fired at connections that have | 1831 // Front end ensures the event is not fired at connections that have |
| 1834 // close_pending set. | 1832 // close_pending set. |
| 1835 connection->callbacks()->OnVersionChange( | 1833 connection->callbacks()->OnVersionChange( |
| 1836 metadata_.int_version, IndexedDBDatabaseMetadata::NO_INT_VERSION); | 1834 metadata_.version, IndexedDBDatabaseMetadata::NO_VERSION); |
| 1837 } | 1835 } |
| 1838 // OnBlocked will be fired at the request when one of the other | 1836 // OnBlocked will be fired at the request when one of the other |
| 1839 // connections acks that the OnVersionChange was ignored. | 1837 // connections acks that the OnVersionChange was ignored. |
| 1840 | 1838 |
| 1841 pending_delete_calls_.push_back(new PendingDeleteCall(callbacks)); | 1839 pending_delete_calls_.push_back(new PendingDeleteCall(callbacks)); |
| 1842 return; | 1840 return; |
| 1843 } | 1841 } |
| 1844 DeleteDatabaseFinal(callbacks); | 1842 DeleteDatabaseFinal(callbacks); |
| 1845 } | 1843 } |
| 1846 | 1844 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1857 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 1855 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
| 1858 "Internal error deleting database."); | 1856 "Internal error deleting database."); |
| 1859 callbacks->OnError(error); | 1857 callbacks->OnError(error); |
| 1860 if (s.IsCorruption()) { | 1858 if (s.IsCorruption()) { |
| 1861 GURL origin_url = backing_store_->origin_url(); | 1859 GURL origin_url = backing_store_->origin_url(); |
| 1862 backing_store_ = NULL; | 1860 backing_store_ = NULL; |
| 1863 factory_->HandleBackingStoreCorruption(origin_url, error); | 1861 factory_->HandleBackingStoreCorruption(origin_url, error); |
| 1864 } | 1862 } |
| 1865 return; | 1863 return; |
| 1866 } | 1864 } |
| 1867 int64_t old_version = metadata_.int_version; | 1865 int64_t old_version = metadata_.version; |
| 1868 metadata_.id = kInvalidId; | 1866 metadata_.id = kInvalidId; |
| 1869 metadata_.int_version = IndexedDBDatabaseMetadata::NO_INT_VERSION; | 1867 metadata_.version = IndexedDBDatabaseMetadata::NO_VERSION; |
| 1870 metadata_.object_stores.clear(); | 1868 metadata_.object_stores.clear(); |
| 1871 callbacks->OnSuccess(old_version); | 1869 callbacks->OnSuccess(old_version); |
| 1872 factory_->DatabaseDeleted(identifier_); | 1870 factory_->DatabaseDeleted(identifier_); |
| 1873 } | 1871 } |
| 1874 | 1872 |
| 1875 void IndexedDBDatabase::ForceClose() { | 1873 void IndexedDBDatabase::ForceClose() { |
| 1876 // IndexedDBConnection::ForceClose() may delete this database, so hold ref. | 1874 // IndexedDBConnection::ForceClose() may delete this database, so hold ref. |
| 1877 scoped_refptr<IndexedDBDatabase> protect(this); | 1875 scoped_refptr<IndexedDBDatabase> protect(this); |
| 1878 ConnectionSet::const_iterator it = connections_.begin(); | 1876 ConnectionSet::const_iterator it = connections_.begin(); |
| 1879 while (it != connections_.end()) { | 1877 while (it != connections_.end()) { |
| 1880 IndexedDBConnection* connection = *it++; | 1878 IndexedDBConnection* connection = *it++; |
| 1881 connection->ForceClose(); | 1879 connection->ForceClose(); |
| 1882 } | 1880 } |
| 1883 DCHECK(connections_.empty()); | 1881 DCHECK(connections_.empty()); |
| 1884 } | 1882 } |
| 1885 | 1883 |
| 1886 void IndexedDBDatabase::VersionChangeIgnored() { | 1884 void IndexedDBDatabase::VersionChangeIgnored() { |
| 1887 if (pending_run_version_change_transaction_call_) | 1885 if (pending_run_version_change_transaction_call_) |
| 1888 pending_run_version_change_transaction_call_->callbacks()->OnBlocked( | 1886 pending_run_version_change_transaction_call_->callbacks()->OnBlocked( |
| 1889 metadata_.int_version); | 1887 metadata_.version); |
| 1890 | 1888 |
| 1891 for (const auto& pending_delete_call : pending_delete_calls_) | 1889 for (const auto& pending_delete_call : pending_delete_calls_) |
| 1892 pending_delete_call->callbacks()->OnBlocked(metadata_.int_version); | 1890 pending_delete_call->callbacks()->OnBlocked(metadata_.version); |
| 1893 } | 1891 } |
| 1894 | 1892 |
| 1895 | 1893 |
| 1896 void IndexedDBDatabase::Close(IndexedDBConnection* connection, bool forced) { | 1894 void IndexedDBDatabase::Close(IndexedDBConnection* connection, bool forced) { |
| 1897 DCHECK(connections_.count(connection)); | 1895 DCHECK(connections_.count(connection)); |
| 1898 DCHECK(connection->IsConnected()); | 1896 DCHECK(connection->IsConnected()); |
| 1899 DCHECK(connection->database() == this); | 1897 DCHECK(connection->database() == this); |
| 1900 | 1898 |
| 1901 IDB_TRACE("IndexedDBDatabase::Close"); | 1899 IDB_TRACE("IndexedDBDatabase::Close"); |
| 1902 | 1900 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1949 void IndexedDBDatabase::DeleteObjectStoreAbortOperation( | 1947 void IndexedDBDatabase::DeleteObjectStoreAbortOperation( |
| 1950 const IndexedDBObjectStoreMetadata& object_store_metadata, | 1948 const IndexedDBObjectStoreMetadata& object_store_metadata, |
| 1951 IndexedDBTransaction* transaction) { | 1949 IndexedDBTransaction* transaction) { |
| 1952 DCHECK(!transaction); | 1950 DCHECK(!transaction); |
| 1953 IDB_TRACE("IndexedDBDatabase::DeleteObjectStoreAbortOperation"); | 1951 IDB_TRACE("IndexedDBDatabase::DeleteObjectStoreAbortOperation"); |
| 1954 AddObjectStore(object_store_metadata, | 1952 AddObjectStore(object_store_metadata, |
| 1955 IndexedDBObjectStoreMetadata::kInvalidId); | 1953 IndexedDBObjectStoreMetadata::kInvalidId); |
| 1956 } | 1954 } |
| 1957 | 1955 |
| 1958 void IndexedDBDatabase::VersionChangeAbortOperation( | 1956 void IndexedDBDatabase::VersionChangeAbortOperation( |
| 1959 int64_t previous_int_version, | 1957 int64_t previous_version, |
| 1960 IndexedDBTransaction* transaction) { | 1958 IndexedDBTransaction* transaction) { |
| 1961 DCHECK(!transaction); | 1959 DCHECK(!transaction); |
| 1962 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); | 1960 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); |
| 1963 metadata_.int_version = previous_int_version; | 1961 metadata_.version = previous_version; |
| 1964 } | 1962 } |
| 1965 | 1963 |
| 1966 } // namespace content | 1964 } // namespace content |
| OLD | NEW |