Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: content/browser/indexed_db/indexed_db_database.cc

Issue 93873017: IndexedDBFactory now ForceCloses databases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added multimap for more efficient origin->db mapping. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // The database is also released when the last connection is closed. Because
1594 // of this we make a copy of this db's connections as this object *will* be
1595 // deleted before this function returns.
jsbell 2014/01/03 00:34:25 A more common pattern is to take a self-reference
cmumford 2014/01/03 21:34:01 Yes, a much better approach. I'll do that.
1596 ConnectionSet conns(connections_);
1597 for (ConnectionSet::iterator it = conns.begin(); it != conns.end(); ++it)
1598 (*it)->ForceClose();
1599 // This object has now been deleted!
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698