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

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

Issue 308103004: IndexedDB: Using a mock IndexedDBFactory for unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't use GoogleMock with std::pair types Created 6 years, 4 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_factory_impl.h" 5 #include "content/browser/indexed_db/indexed_db_factory_impl.h"
6 6
7 #include <utility>
7 #include <vector> 8 #include <vector>
8 9
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
11 #include "base/time/time.h" 12 #include "base/time/time.h"
12 #include "content/browser/indexed_db/indexed_db_backing_store.h" 13 #include "content/browser/indexed_db/indexed_db_backing_store.h"
13 #include "content/browser/indexed_db/indexed_db_context_impl.h" 14 #include "content/browser/indexed_db/indexed_db_context_impl.h"
14 #include "content/browser/indexed_db/indexed_db_database_error.h" 15 #include "content/browser/indexed_db/indexed_db_database_error.h"
15 #include "content/browser/indexed_db/indexed_db_tracing.h" 16 #include "content/browser/indexed_db/indexed_db_tracing.h"
16 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h" 17 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // Scope so that the implicit scoped_refptr<> is freed. 119 // Scope so that the implicit scoped_refptr<> is freed.
119 IndexedDBBackingStoreMap::const_iterator it = 120 IndexedDBBackingStoreMap::const_iterator it =
120 backing_store_map_.find(origin_url); 121 backing_store_map_.find(origin_url);
121 DCHECK(it != backing_store_map_.end()); 122 DCHECK(it != backing_store_map_.end());
122 ptr = it->second.get(); 123 ptr = it->second.get();
123 } 124 }
124 return ptr->HasOneRef(); 125 return ptr->HasOneRef();
125 } 126 }
126 127
127 void IndexedDBFactoryImpl::ForceClose(const GURL& origin_url) { 128 void IndexedDBFactoryImpl::ForceClose(const GURL& origin_url) {
128 std::pair<OriginDBMapIterator, OriginDBMapIterator> range = 129 OriginDBs range = GetOpenDatabasesForOrigin(origin_url);
129 GetOpenDatabasesForOrigin(origin_url);
130 130
131 while (range.first != range.second) { 131 while (range.first != range.second) {
132 IndexedDBDatabase* db = range.first->second; 132 IndexedDBDatabase* db = range.first->second;
133 ++range.first; 133 ++range.first;
134 db->ForceClose(); 134 db->ForceClose();
135 } 135 }
136 136
137 if (backing_store_map_.find(origin_url) != backing_store_map_.end()) 137 if (backing_store_map_.find(origin_url) != backing_store_map_.end())
138 ReleaseBackingStore(origin_url, true /* immediate */); 138 ReleaseBackingStore(origin_url, true /* immediate */);
139 } 139 }
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 488
489 std::pair<IndexedDBFactoryImpl::OriginDBMapIterator, 489 std::pair<IndexedDBFactoryImpl::OriginDBMapIterator,
490 IndexedDBFactoryImpl::OriginDBMapIterator> 490 IndexedDBFactoryImpl::OriginDBMapIterator>
491 IndexedDBFactoryImpl::GetOpenDatabasesForOrigin(const GURL& origin_url) const { 491 IndexedDBFactoryImpl::GetOpenDatabasesForOrigin(const GURL& origin_url) const {
492 return origin_dbs_.equal_range(origin_url); 492 return origin_dbs_.equal_range(origin_url);
493 } 493 }
494 494
495 size_t IndexedDBFactoryImpl::GetConnectionCount(const GURL& origin_url) const { 495 size_t IndexedDBFactoryImpl::GetConnectionCount(const GURL& origin_url) const {
496 size_t count(0); 496 size_t count(0);
497 497
498 std::pair<OriginDBMapIterator, OriginDBMapIterator> range = 498 OriginDBs range = GetOpenDatabasesForOrigin(origin_url);
499 GetOpenDatabasesForOrigin(origin_url);
500 for (OriginDBMapIterator it = range.first; it != range.second; ++it) 499 for (OriginDBMapIterator it = range.first; it != range.second; ++it)
501 count += it->second->ConnectionCount(); 500 count += it->second->ConnectionCount();
502 501
503 return count; 502 return count;
504 } 503 }
505 504
506 } // namespace content 505 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_factory_impl.h ('k') | content/browser/indexed_db/indexed_db_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698