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

Unified Diff: content/browser/indexed_db/indexed_db_factory.cc

Issue 134693005: Revert of IndexedDBFactory now ForceCloses databases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/indexed_db/indexed_db_factory.h ('k') | content/browser/indexed_db/indexed_db_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/indexed_db/indexed_db_factory.cc
diff --git a/content/browser/indexed_db/indexed_db_factory.cc b/content/browser/indexed_db/indexed_db_factory.cc
index 55403314ecb4e6a91f177c2cde407a2c3a5731db..8cf50425866d245bc449142ed477c6e7d57e548b 100644
--- a/content/browser/indexed_db/indexed_db_factory.cc
+++ b/content/browser/indexed_db/indexed_db_factory.cc
@@ -25,31 +25,13 @@
IndexedDBFactory::~IndexedDBFactory() {}
-void IndexedDBFactory::RemoveDatabaseFromMaps(
- const IndexedDBDatabase::Identifier& identifier) {
- IndexedDBDatabaseMap::iterator it = database_map_.find(identifier);
- DCHECK(it != database_map_.end());
- IndexedDBDatabase* database = it->second;
- database_map_.erase(it);
-
- std::pair<OriginDBMap::iterator, OriginDBMap::iterator> range =
- origin_dbs_.equal_range(database->identifier().first);
- DCHECK(range.first != range.second);
- for (OriginDBMap::iterator it2 = range.first; it2 != range.second; ++it2) {
- if (it2->second == database) {
- origin_dbs_.erase(it2);
- break;
- }
- }
-}
-
void IndexedDBFactory::ReleaseDatabase(
const IndexedDBDatabase::Identifier& identifier,
bool forcedClose) {
-
- DCHECK(!database_map_.find(identifier)->second->backing_store());
-
- RemoveDatabaseFromMaps(identifier);
+ IndexedDBDatabaseMap::iterator it = database_map_.find(identifier);
+ DCHECK(it != database_map_.end());
+ DCHECK(!it->second->backing_store());
+ database_map_.erase(it);
// No grace period on a forced-close, as the initiator is
// assuming the backing store will be released once all
@@ -110,15 +92,6 @@
}
void IndexedDBFactory::ForceClose(const GURL& origin_url) {
- std::pair<OriginDBMapIterator, OriginDBMapIterator> range =
- GetOpenDatabasesForOrigin(origin_url);
-
- while (range.first != range.second) {
- IndexedDBDatabase* db = range.first->second;
- ++range.first;
- db->ForceClose();
- }
-
if (backing_store_map_.find(origin_url) != backing_store_map_.end())
ReleaseBackingStore(origin_url, true /* immediate */);
}
@@ -210,9 +183,8 @@
}
database_map_[unique_identifier] = database;
- origin_dbs_.insert(std::make_pair(origin_url, database));
database->DeleteDatabase(callbacks);
- RemoveDatabaseFromMaps(unique_identifier);
+ database_map_.erase(unique_identifier);
database = NULL;
backing_store = NULL;
ReleaseBackingStore(origin_url, false /* immediate */);
@@ -352,27 +324,20 @@
database->OpenConnection(
callbacks, database_callbacks, transaction_id, version);
- if (!was_open && database->ConnectionCount() > 0) {
+ if (!was_open && database->ConnectionCount() > 0)
database_map_[unique_identifier] = database;
- origin_dbs_.insert(std::make_pair(origin_url, database));
- }
-}
-
-std::pair<IndexedDBFactory::OriginDBMapIterator,
- IndexedDBFactory::OriginDBMapIterator>
-IndexedDBFactory::GetOpenDatabasesForOrigin(const GURL& origin_url) const {
- return origin_dbs_.equal_range(origin_url);
-}
-
-size_t IndexedDBFactory::GetConnectionCount(const GURL& origin_url) const {
- size_t count(0);
-
- std::pair<OriginDBMapIterator, OriginDBMapIterator> range =
- GetOpenDatabasesForOrigin(origin_url);
- for (OriginDBMapIterator it = range.first; it != range.second; ++it)
- count += it->second->ConnectionCount();
-
- return count;
+}
+
+std::vector<IndexedDBDatabase*> IndexedDBFactory::GetOpenDatabasesForOrigin(
+ const GURL& origin_url) const {
+ std::vector<IndexedDBDatabase*> result;
+ for (IndexedDBDatabaseMap::const_iterator it = database_map_.begin();
+ it != database_map_.end();
+ ++it) {
+ if (it->first.first == origin_url)
+ result.push_back(it->second);
+ }
+ return result;
}
} // namespace content
« no previous file with comments | « content/browser/indexed_db/indexed_db_factory.h ('k') | content/browser/indexed_db/indexed_db_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698