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

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

Issue 17033004: Tell IDB frontend about data loss (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ToT Created 7 years, 6 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 | Annotate | Revision Log
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_backing_store.h" 5 #include "content/browser/indexed_db/indexed_db_backing_store.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MEMORY_FAILED, 414 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MEMORY_FAILED,
415 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_ATTEMPT_NON_ASCII, 415 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_ATTEMPT_NON_ASCII,
416 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_DISK_FULL, 416 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_DISK_FULL,
417 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_ORIGIN_TOO_LONG, 417 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_ORIGIN_TOO_LONG,
418 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, 418 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX,
419 }; 419 };
420 420
421 scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::Open( 421 scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::Open(
422 const string16& database_identifier, 422 const string16& database_identifier,
423 const base::FilePath& path_base, 423 const base::FilePath& path_base,
424 const string16& file_identifier) { 424 const string16& file_identifier,
425 WebKit::WebIDBCallbacks::DataLoss* data_loss) {
426 *data_loss = WebKit::WebIDBCallbacks::None;
425 DefaultLevelDBFactory leveldb_factory; 427 DefaultLevelDBFactory leveldb_factory;
426 return IndexedDBBackingStore::Open( 428 return IndexedDBBackingStore::Open(database_identifier,
427 database_identifier, path_base, file_identifier, &leveldb_factory); 429 path_base,
430 file_identifier,
431 data_loss,
432 &leveldb_factory);
428 } 433 }
429 434
430 scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::Open( 435 scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::Open(
431 const string16& database_identifier, 436 const string16& database_identifier,
432 const base::FilePath& path_base, 437 const base::FilePath& path_base,
433 const string16& file_identifier, 438 const string16& file_identifier,
439 WebKit::WebIDBCallbacks::DataLoss* data_loss,
434 LevelDBFactory* leveldb_factory) { 440 LevelDBFactory* leveldb_factory) {
435 IDB_TRACE("IndexedDBBackingStore::open"); 441 IDB_TRACE("IndexedDBBackingStore::open");
436 DCHECK(!path_base.empty()); 442 DCHECK(!path_base.empty());
443 *data_loss = WebKit::WebIDBCallbacks::None;
437 444
438 scoped_ptr<LevelDBComparator> comparator(new Comparator()); 445 scoped_ptr<LevelDBComparator> comparator(new Comparator());
439 scoped_ptr<LevelDBDatabase> db; 446 scoped_ptr<LevelDBDatabase> db;
440 447
441 if (!IsStringASCII(path_base.AsUTF8Unsafe())) { 448 if (!IsStringASCII(path_base.AsUTF8Unsafe())) {
442 base::Histogram::FactoryGet("WebCore.IndexedDB.BackingStore.OpenStatus", 449 base::Histogram::FactoryGet("WebCore.IndexedDB.BackingStore.OpenStatus",
443 1, 450 1,
444 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, 451 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX,
445 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, 452 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1,
446 base::HistogramBase::kUmaTargetedHistogramFlag) 453 base::HistogramBase::kUmaTargetedHistogramFlag)
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 base::Histogram::FactoryGet( 549 base::Histogram::FactoryGet(
543 "WebCore.IndexedDB.BackingStore.OpenStatus", 550 "WebCore.IndexedDB.BackingStore.OpenStatus",
544 1, 551 1,
545 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, 552 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX,
546 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, 553 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1,
547 base::HistogramBase::kUmaTargetedHistogramFlag) 554 base::HistogramBase::kUmaTargetedHistogramFlag)
548 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_DISK_FULL); 555 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_DISK_FULL);
549 return scoped_refptr<IndexedDBBackingStore>(); 556 return scoped_refptr<IndexedDBBackingStore>();
550 } else { 557 } else {
551 LOG(ERROR) << "IndexedDB backing store open failed, attempting cleanup"; 558 LOG(ERROR) << "IndexedDB backing store open failed, attempting cleanup";
559 *data_loss = WebKit::WebIDBCallbacks::Total;
552 bool success = leveldb_factory->DestroyLevelDB(file_path); 560 bool success = leveldb_factory->DestroyLevelDB(file_path);
553 if (!success) { 561 if (!success) {
554 LOG(ERROR) << "IndexedDB backing store cleanup failed"; 562 LOG(ERROR) << "IndexedDB backing store cleanup failed";
555 base::Histogram::FactoryGet( 563 base::Histogram::FactoryGet(
556 "WebCore.IndexedDB.BackingStore.OpenStatus", 564 "WebCore.IndexedDB.BackingStore.OpenStatus",
557 1, 565 1,
558 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, 566 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX,
559 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, 567 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1,
560 base::HistogramBase::kUmaTargetedHistogramFlag) 568 base::HistogramBase::kUmaTargetedHistogramFlag)
561 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_CLEANUP_DESTROY_FAILED); 569 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_CLEANUP_DESTROY_FAILED);
(...skipping 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after
2634 } 2642 }
2635 2643
2636 void IndexedDBBackingStore::Transaction::Rollback() { 2644 void IndexedDBBackingStore::Transaction::Rollback() {
2637 IDB_TRACE("IndexedDBBackingStore::Transaction::rollback"); 2645 IDB_TRACE("IndexedDBBackingStore::Transaction::rollback");
2638 DCHECK(transaction_.get()); 2646 DCHECK(transaction_.get());
2639 transaction_->Rollback(); 2647 transaction_->Rollback();
2640 transaction_ = NULL; 2648 transaction_ = NULL;
2641 } 2649 }
2642 2650
2643 } // namespace content 2651 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698