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

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

Issue 501183003: Remove implicit conversions from scoped_refptr to T* in content/browser/indexed_db/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 leveldb::Status s; 186 leveldb::Status s;
187 // TODO(cmumford): Handle this error 187 // TODO(cmumford): Handle this error
188 scoped_refptr<IndexedDBBackingStore> backing_store = 188 scoped_refptr<IndexedDBBackingStore> backing_store =
189 OpenBackingStore(origin_url, 189 OpenBackingStore(origin_url,
190 data_directory, 190 data_directory,
191 request_context, 191 request_context,
192 &data_loss, 192 &data_loss,
193 &data_loss_message, 193 &data_loss_message,
194 &disk_full, 194 &disk_full,
195 &s); 195 &s);
196 if (!backing_store) { 196 if (!backing_store.get()) {
197 callbacks->OnError( 197 callbacks->OnError(
198 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError, 198 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError,
199 "Internal error opening backing store for " 199 "Internal error opening backing store for "
200 "indexedDB.webkitGetDatabaseNames.")); 200 "indexedDB.webkitGetDatabaseNames."));
201 return; 201 return;
202 } 202 }
203 203
204 std::vector<base::string16> names = backing_store->GetDatabaseNames(&s); 204 std::vector<base::string16> names = backing_store->GetDatabaseNames(&s);
205 if (!s.ok()) { 205 if (!s.ok()) {
206 DLOG(ERROR) << "Internal error getting database names"; 206 DLOG(ERROR) << "Internal error getting database names";
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 bool disk_full = false; 240 bool disk_full = false;
241 leveldb::Status s; 241 leveldb::Status s;
242 scoped_refptr<IndexedDBBackingStore> backing_store = 242 scoped_refptr<IndexedDBBackingStore> backing_store =
243 OpenBackingStore(origin_url, 243 OpenBackingStore(origin_url,
244 data_directory, 244 data_directory,
245 request_context, 245 request_context,
246 &data_loss, 246 &data_loss,
247 &data_loss_message, 247 &data_loss_message,
248 &disk_full, 248 &disk_full,
249 &s); 249 &s);
250 if (!backing_store) { 250 if (!backing_store.get()) {
251 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, 251 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
252 ASCIIToUTF16( 252 ASCIIToUTF16(
253 "Internal error opening backing store " 253 "Internal error opening backing store "
254 "for indexedDB.deleteDatabase.")); 254 "for indexedDB.deleteDatabase."));
255 callbacks->OnError(error); 255 callbacks->OnError(error);
256 if (s.IsCorruption()) { 256 if (s.IsCorruption()) {
257 HandleBackingStoreCorruption(origin_url, error); 257 HandleBackingStoreCorruption(origin_url, error);
258 } 258 }
259 return; 259 return;
260 } 260 }
261 261
262 scoped_refptr<IndexedDBDatabase> database = IndexedDBDatabase::Create( 262 scoped_refptr<IndexedDBDatabase> database = IndexedDBDatabase::Create(
263 name, backing_store, this, unique_identifier, &s); 263 name, backing_store.get(), this, unique_identifier, &s);
264 if (!database) { 264 if (!database.get()) {
265 IndexedDBDatabaseError error( 265 IndexedDBDatabaseError error(
266 blink::WebIDBDatabaseExceptionUnknownError, 266 blink::WebIDBDatabaseExceptionUnknownError,
267 ASCIIToUTF16( 267 ASCIIToUTF16(
268 "Internal error creating database backend for " 268 "Internal error creating database backend for "
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; 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));
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) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 if (!was_open) { 428 if (!was_open) {
429 leveldb::Status s; 429 leveldb::Status s;
430 scoped_refptr<IndexedDBBackingStore> backing_store = 430 scoped_refptr<IndexedDBBackingStore> backing_store =
431 OpenBackingStore(origin_url, 431 OpenBackingStore(origin_url,
432 data_directory, 432 data_directory,
433 request_context, 433 request_context,
434 &data_loss, 434 &data_loss,
435 &data_loss_message, 435 &data_loss_message,
436 &disk_full, 436 &disk_full,
437 &s); 437 &s);
438 if (!backing_store) { 438 if (!backing_store.get()) {
439 if (disk_full) { 439 if (disk_full) {
440 connection.callbacks->OnError( 440 connection.callbacks->OnError(
441 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionQuotaError, 441 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionQuotaError,
442 ASCIIToUTF16( 442 ASCIIToUTF16(
443 "Encountered full disk while opening " 443 "Encountered full disk while opening "
444 "backing store for indexedDB.open."))); 444 "backing store for indexedDB.open.")));
445 return; 445 return;
446 } 446 }
447 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, 447 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
448 ASCIIToUTF16( 448 ASCIIToUTF16(
449 "Internal error opening backing store" 449 "Internal error opening backing store"
450 " for indexedDB.open.")); 450 " for indexedDB.open."));
451 connection.callbacks->OnError(error); 451 connection.callbacks->OnError(error);
452 if (s.IsCorruption()) { 452 if (s.IsCorruption()) {
453 HandleBackingStoreCorruption(origin_url, error); 453 HandleBackingStoreCorruption(origin_url, error);
454 } 454 }
455 return; 455 return;
456 } 456 }
457 457
458 database = IndexedDBDatabase::Create( 458 database = IndexedDBDatabase::Create(
459 name, backing_store, this, unique_identifier, &s); 459 name, backing_store.get(), this, unique_identifier, &s);
460 if (!database) { 460 if (!database.get()) {
461 DLOG(ERROR) << "Unable to create the database"; 461 DLOG(ERROR) << "Unable to create the database";
462 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, 462 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
463 ASCIIToUTF16( 463 ASCIIToUTF16(
464 "Internal error creating " 464 "Internal error creating "
465 "database backend for " 465 "database backend for "
466 "indexedDB.open.")); 466 "indexedDB.open."));
467 connection.callbacks->OnError(error); 467 connection.callbacks->OnError(error);
468 if (leveldb_env::IsCorruption(s)) { 468 if (leveldb_env::IsCorruption(s)) {
469 backing_store = NULL; // Closes the LevelDB so that it can be deleted 469 backing_store = NULL; // Closes the LevelDB so that it can be deleted
470 HandleBackingStoreCorruption(origin_url, error); 470 HandleBackingStoreCorruption(origin_url, error);
471 } 471 }
472 return; 472 return;
473 } 473 }
474 } else { 474 } else {
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; 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));
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
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_dispatcher_host.cc ('k') | content/browser/indexed_db/indexed_db_factory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698