| Index: trunk/src/content/browser/indexed_db/indexed_db_factory.cc
|
| ===================================================================
|
| --- trunk/src/content/browser/indexed_db/indexed_db_factory.cc (revision 244272)
|
| +++ trunk/src/content/browser/indexed_db/indexed_db_factory.cc (working copy)
|
| @@ -25,32 +25,14 @@
|
|
|
| IndexedDBFactory::~IndexedDBFactory() {}
|
|
|
| -void IndexedDBFactory::RemoveDatabaseFromMaps(
|
| - const IndexedDBDatabase::Identifier& identifier) {
|
| +void IndexedDBFactory::ReleaseDatabase(
|
| + const IndexedDBDatabase::Identifier& identifier,
|
| + bool forcedClose) {
|
| IndexedDBDatabaseMap::iterator it = database_map_.find(identifier);
|
| DCHECK(it != database_map_.end());
|
| - IndexedDBDatabase* database = it->second;
|
| + DCHECK(!it->second->backing_store());
|
| 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);
|
| -
|
| // No grace period on a forced-close, as the initiator is
|
| // assuming the backing store will be released once all
|
| // connections are closed.
|
| @@ -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);
|
| +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;
|
| }
|
|
|
| -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;
|
| -}
|
| -
|
| } // namespace content
|
|
|