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_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 Loading... |
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::DataLossNone; |
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::DataLossNone; |
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 base::Histogram::FactoryGet( | 548 base::Histogram::FactoryGet( |
542 "WebCore.IndexedDB.BackingStore.OpenStatus", | 549 "WebCore.IndexedDB.BackingStore.OpenStatus", |
543 1, | 550 1, |
544 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | 551 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, |
545 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | 552 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, |
546 base::HistogramBase::kUmaTargetedHistogramFlag) | 553 base::HistogramBase::kUmaTargetedHistogramFlag) |
547 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_DISK_FULL); | 554 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_DISK_FULL); |
548 return scoped_refptr<IndexedDBBackingStore>(); | 555 return scoped_refptr<IndexedDBBackingStore>(); |
549 } else { | 556 } else { |
550 LOG(ERROR) << "IndexedDB backing store open failed, attempting cleanup"; | 557 LOG(ERROR) << "IndexedDB backing store open failed, attempting cleanup"; |
| 558 *data_loss = WebKit::WebIDBCallbacks::DataLossTotal; |
551 bool success = leveldb_factory->DestroyLevelDB(file_path); | 559 bool success = leveldb_factory->DestroyLevelDB(file_path); |
552 if (!success) { | 560 if (!success) { |
553 LOG(ERROR) << "IndexedDB backing store cleanup failed"; | 561 LOG(ERROR) << "IndexedDB backing store cleanup failed"; |
554 base::Histogram::FactoryGet( | 562 base::Histogram::FactoryGet( |
555 "WebCore.IndexedDB.BackingStore.OpenStatus", | 563 "WebCore.IndexedDB.BackingStore.OpenStatus", |
556 1, | 564 1, |
557 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | 565 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, |
558 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | 566 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, |
559 base::HistogramBase::kUmaTargetedHistogramFlag) | 567 base::HistogramBase::kUmaTargetedHistogramFlag) |
560 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_CLEANUP_DESTROY_FAILED); | 568 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_CLEANUP_DESTROY_FAILED); |
(...skipping 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2633 } | 2641 } |
2634 | 2642 |
2635 void IndexedDBBackingStore::Transaction::Rollback() { | 2643 void IndexedDBBackingStore::Transaction::Rollback() { |
2636 IDB_TRACE("IndexedDBBackingStore::Transaction::Rollback"); | 2644 IDB_TRACE("IndexedDBBackingStore::Transaction::Rollback"); |
2637 DCHECK(transaction_.get()); | 2645 DCHECK(transaction_.get()); |
2638 transaction_->Rollback(); | 2646 transaction_->Rollback(); |
2639 transaction_ = NULL; | 2647 transaction_ = NULL; |
2640 } | 2648 } |
2641 | 2649 |
2642 } // namespace content | 2650 } // namespace content |
OLD | NEW |