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

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

Issue 2642943002: Allow closing IndexedDB database before deleting (Closed)
Patch Set: Fixed compilation errors in tests Created 3 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 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 <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
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 (force_close) {
222 // database. 223 it->second->ForceClose();
cmumford 2017/01/19 20:47:16 Any reason why we can't pass force_close into Dele
eostroukhov 2017/01/20 18:43:18 Did that, also added a test.
223 it->second->DeleteDatabase(callbacks); 224 } else {
224 return; 225 // If there are any connections to the database, directly delete the
226 // database.
227 it->second->DeleteDatabase(callbacks);
228 return;
229 }
225 } 230 }
226 231
227 // TODO(dgrogan): Plumb data_loss back to script eventually? 232 // TODO(dgrogan): Plumb data_loss back to script eventually?
228 IndexedDBDataLossInfo data_loss_info; 233 IndexedDBDataLossInfo data_loss_info;
229 bool disk_full = false; 234 bool disk_full = false;
230 leveldb::Status s; 235 leveldb::Status s;
231 scoped_refptr<IndexedDBBackingStore> backing_store = 236 scoped_refptr<IndexedDBBackingStore> backing_store =
232 OpenBackingStore(origin, data_directory, request_context_getter, 237 OpenBackingStore(origin, data_directory, request_context_getter,
233 &data_loss_info, &disk_full, &s); 238 &data_loss_info, &disk_full, &s);
234 if (!backing_store.get()) { 239 if (!backing_store.get()) {
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 size_t count(0); 489 size_t count(0);
485 490
486 OriginDBs range = GetOpenDatabasesForOrigin(origin); 491 OriginDBs range = GetOpenDatabasesForOrigin(origin);
487 for (OriginDBMapIterator it = range.first; it != range.second; ++it) 492 for (OriginDBMapIterator it = range.first; it != range.second; ++it)
488 count += it->second->ConnectionCount(); 493 count += it->second->ConnectionCount();
489 494
490 return count; 495 return count;
491 } 496 }
492 497
493 } // namespace content 498 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698