| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 callbacks->OnSuccess(names); | 206 callbacks->OnSuccess(names); |
| 207 backing_store = NULL; | 207 backing_store = NULL; |
| 208 ReleaseBackingStore(origin, false /* immediate */); | 208 ReleaseBackingStore(origin, false /* immediate */); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void IndexedDBFactoryImpl::DeleteDatabase( | 211 void IndexedDBFactoryImpl::DeleteDatabase( |
| 212 const base::string16& name, | 212 const base::string16& name, |
| 213 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | 213 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
| 214 scoped_refptr<IndexedDBCallbacks> callbacks, | 214 scoped_refptr<IndexedDBCallbacks> callbacks, |
| 215 const Origin& origin, | 215 const Origin& origin, |
| 216 const base::FilePath& data_directory) { | 216 const base::FilePath& data_directory, |
| 217 bool force_close) { |
| 217 IDB_TRACE("IndexedDBFactoryImpl::DeleteDatabase"); | 218 IDB_TRACE("IndexedDBFactoryImpl::DeleteDatabase"); |
| 218 IndexedDBDatabase::Identifier unique_identifier(origin, name); | 219 IndexedDBDatabase::Identifier unique_identifier(origin, name); |
| 219 const auto& it = database_map_.find(unique_identifier); | 220 const auto& it = database_map_.find(unique_identifier); |
| 220 if (it != database_map_.end()) { | 221 if (it != database_map_.end()) { |
| 221 // If there are any connections to the database, directly delete the | 222 // If there are any connections to the database, directly delete the |
| 222 // database. | 223 // database. |
| 223 it->second->DeleteDatabase(callbacks); | 224 it->second->DeleteDatabase(callbacks, force_close); |
| 224 return; | 225 return; |
| 225 } | 226 } |
| 226 | 227 |
| 227 // TODO(dgrogan): Plumb data_loss back to script eventually? | 228 // TODO(dgrogan): Plumb data_loss back to script eventually? |
| 228 IndexedDBDataLossInfo data_loss_info; | 229 IndexedDBDataLossInfo data_loss_info; |
| 229 bool disk_full = false; | 230 bool disk_full = false; |
| 230 leveldb::Status s; | 231 leveldb::Status s; |
| 231 scoped_refptr<IndexedDBBackingStore> backing_store = | 232 scoped_refptr<IndexedDBBackingStore> backing_store = |
| 232 OpenBackingStore(origin, data_directory, request_context_getter, | 233 OpenBackingStore(origin, data_directory, request_context_getter, |
| 233 &data_loss_info, &disk_full, &s); | 234 &data_loss_info, &disk_full, &s); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 callbacks->OnError(error); | 276 callbacks->OnError(error); |
| 276 if (s.IsCorruption()) { | 277 if (s.IsCorruption()) { |
| 277 backing_store = NULL; | 278 backing_store = NULL; |
| 278 HandleBackingStoreCorruption(origin, error); | 279 HandleBackingStoreCorruption(origin, error); |
| 279 } | 280 } |
| 280 return; | 281 return; |
| 281 } | 282 } |
| 282 | 283 |
| 283 database_map_[unique_identifier] = database.get(); | 284 database_map_[unique_identifier] = database.get(); |
| 284 origin_dbs_.insert(std::make_pair(origin, database.get())); | 285 origin_dbs_.insert(std::make_pair(origin, database.get())); |
| 285 database->DeleteDatabase(callbacks); | 286 database->DeleteDatabase(callbacks, false /* force_close */); |
| 286 RemoveDatabaseFromMaps(unique_identifier); | 287 RemoveDatabaseFromMaps(unique_identifier); |
| 287 database = NULL; | 288 database = NULL; |
| 288 backing_store = NULL; | 289 backing_store = NULL; |
| 289 ReleaseBackingStore(origin, false /* immediate */); | 290 ReleaseBackingStore(origin, false /* immediate */); |
| 290 } | 291 } |
| 291 | 292 |
| 292 void IndexedDBFactoryImpl::DatabaseDeleted( | 293 void IndexedDBFactoryImpl::DatabaseDeleted( |
| 293 const IndexedDBDatabase::Identifier& identifier) { | 294 const IndexedDBDatabase::Identifier& identifier) { |
| 294 // NULL after ContextDestroyed() called, and in some unit tests. | 295 // NULL after ContextDestroyed() called, and in some unit tests. |
| 295 if (!context_) | 296 if (!context_) |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 size_t count(0); | 485 size_t count(0); |
| 485 | 486 |
| 486 OriginDBs range = GetOpenDatabasesForOrigin(origin); | 487 OriginDBs range = GetOpenDatabasesForOrigin(origin); |
| 487 for (OriginDBMapIterator it = range.first; it != range.second; ++it) | 488 for (OriginDBMapIterator it = range.first; it != range.second; ++it) |
| 488 count += it->second->ConnectionCount(); | 489 count += it->second->ConnectionCount(); |
| 489 | 490 |
| 490 return count; | 491 return count; |
| 491 } | 492 } |
| 492 | 493 |
| 493 } // namespace content | 494 } // namespace content |
| OLD | NEW |