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 <set> | 8 #include <set> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1582 } | 1582 } |
1583 metadata_.version = kNoStringVersion; | 1583 metadata_.version = kNoStringVersion; |
1584 metadata_.id = kInvalidId; | 1584 metadata_.id = kInvalidId; |
1585 metadata_.int_version = IndexedDBDatabaseMetadata::NO_INT_VERSION; | 1585 metadata_.int_version = IndexedDBDatabaseMetadata::NO_INT_VERSION; |
1586 metadata_.object_stores.clear(); | 1586 metadata_.object_stores.clear(); |
1587 callbacks->OnSuccess(); | 1587 callbacks->OnSuccess(); |
1588 if (factory_) | 1588 if (factory_) |
1589 factory_->DatabaseDeleted(identifier_); | 1589 factory_->DatabaseDeleted(identifier_); |
1590 } | 1590 } |
1591 | 1591 |
1592 void IndexedDBDatabase::ForceClose() { | |
1593 // IndexedDBConnection::ForceClose() may delete this database, so hold ref. | |
1594 scoped_refptr<IndexedDBDatabase> protect(this); | |
1595 ConnectionSet::const_iterator it = connections_.begin(); | |
1596 while (it != connections_.end()) { | |
1597 IndexedDBConnection* connection = *it++; | |
1598 connection->ForceClose(); | |
1599 } | |
jsbell
2014/01/09 18:09:11
Can you add a DCHECK that connections_ is empty()
cmumford
2014/01/09 18:46:09
Done.
| |
1600 } | |
1601 | |
1592 void IndexedDBDatabase::Close(IndexedDBConnection* connection, bool forced) { | 1602 void IndexedDBDatabase::Close(IndexedDBConnection* connection, bool forced) { |
1593 DCHECK(connections_.count(connection)); | 1603 DCHECK(connections_.count(connection)); |
1594 DCHECK(connection->IsConnected()); | 1604 DCHECK(connection->IsConnected()); |
1595 DCHECK(connection->database() == this); | 1605 DCHECK(connection->database() == this); |
1596 | 1606 |
1597 // Abort outstanding transactions from the closing connection. This | 1607 // Abort outstanding transactions from the closing connection. This |
1598 // can not happen if the close is requested by the connection itself | 1608 // can not happen if the close is requested by the connection itself |
1599 // as the front-end defers the close until all transactions are | 1609 // as the front-end defers the close until all transactions are |
1600 // complete, but can occur on process termination or forced close. | 1610 // complete, but can occur on process termination or forced close. |
1601 { | 1611 { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1660 const base::string16& previous_version, | 1670 const base::string16& previous_version, |
1661 int64 previous_int_version, | 1671 int64 previous_int_version, |
1662 IndexedDBTransaction* transaction) { | 1672 IndexedDBTransaction* transaction) { |
1663 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); | 1673 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); |
1664 DCHECK(!transaction); | 1674 DCHECK(!transaction); |
1665 metadata_.version = previous_version; | 1675 metadata_.version = previous_version; |
1666 metadata_.int_version = previous_int_version; | 1676 metadata_.int_version = previous_int_version; |
1667 } | 1677 } |
1668 | 1678 |
1669 } // namespace content | 1679 } // namespace content |
OLD | NEW |