| 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_factory_impl.h" | 5 #include "content/browser/indexed_db/indexed_db_factory_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 "indexedDB.deleteDatabase.")); | 269 "indexedDB.deleteDatabase.")); |
| 270 callbacks->OnError(error); | 270 callbacks->OnError(error); |
| 271 if (leveldb_env::IsCorruption(s)) { | 271 if (leveldb_env::IsCorruption(s)) { |
| 272 backing_store = NULL; | 272 backing_store = NULL; |
| 273 HandleBackingStoreCorruption(origin_url, error); | 273 HandleBackingStoreCorruption(origin_url, error); |
| 274 } | 274 } |
| 275 return; | 275 return; |
| 276 } | 276 } |
| 277 | 277 |
| 278 database_map_[unique_identifier] = database.get(); | 278 database_map_[unique_identifier] = database.get(); |
| 279 origin_dbs_.insert(std::make_pair(origin_url, database)); | 279 origin_dbs_.insert(std::make_pair(origin_url, database.get())); |
| 280 database->DeleteDatabase(callbacks); | 280 database->DeleteDatabase(callbacks); |
| 281 RemoveDatabaseFromMaps(unique_identifier); | 281 RemoveDatabaseFromMaps(unique_identifier); |
| 282 database = NULL; | 282 database = NULL; |
| 283 backing_store = NULL; | 283 backing_store = NULL; |
| 284 ReleaseBackingStore(origin_url, false /* immediate */); | 284 ReleaseBackingStore(origin_url, false /* immediate */); |
| 285 } | 285 } |
| 286 | 286 |
| 287 void IndexedDBFactoryImpl::DatabaseDeleted( | 287 void IndexedDBFactoryImpl::DatabaseDeleted( |
| 288 const IndexedDBDatabase::Identifier& identifier) { | 288 const IndexedDBDatabase::Identifier& identifier) { |
| 289 // NULL after ContextDestroyed() called, and in some unit tests. | 289 // NULL after ContextDestroyed() called, and in some unit tests. |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 database = it->second; | 475 database = it->second; |
| 476 } | 476 } |
| 477 | 477 |
| 478 if (data_loss != blink::WebIDBDataLossNone) | 478 if (data_loss != blink::WebIDBDataLossNone) |
| 479 connection.callbacks->OnDataLoss(data_loss, data_loss_message); | 479 connection.callbacks->OnDataLoss(data_loss, data_loss_message); |
| 480 | 480 |
| 481 database->OpenConnection(connection); | 481 database->OpenConnection(connection); |
| 482 | 482 |
| 483 if (!was_open && database->ConnectionCount() > 0) { | 483 if (!was_open && database->ConnectionCount() > 0) { |
| 484 database_map_[unique_identifier] = database.get(); | 484 database_map_[unique_identifier] = database.get(); |
| 485 origin_dbs_.insert(std::make_pair(origin_url, database)); | 485 origin_dbs_.insert(std::make_pair(origin_url, database.get())); |
| 486 } | 486 } |
| 487 } | 487 } |
| 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 OriginDBs range = GetOpenDatabasesForOrigin(origin_url); | 498 OriginDBs range = GetOpenDatabasesForOrigin(origin_url); |
| 499 for (OriginDBMapIterator it = range.first; it != range.second; ++it) | 499 for (OriginDBMapIterator it = range.first; it != range.second; ++it) |
| 500 count += it->second->ConnectionCount(); | 500 count += it->second->ConnectionCount(); |
| 501 | 501 |
| 502 return count; | 502 return count; |
| 503 } | 503 } |
| 504 | 504 |
| 505 } // namespace content | 505 } // namespace content |
| OLD | NEW |