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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 *max_object_store_id = 0; | 358 *max_object_store_id = 0; |
359 | 359 |
360 DCHECK_GE(*max_object_store_id, 0); | 360 DCHECK_GE(*max_object_store_id, 0); |
361 return true; | 361 return true; |
362 } | 362 } |
363 | 363 |
364 class DefaultLevelDBFactory : public LevelDBFactory { | 364 class DefaultLevelDBFactory : public LevelDBFactory { |
365 public: | 365 public: |
366 virtual scoped_ptr<LevelDBDatabase> OpenLevelDB( | 366 virtual scoped_ptr<LevelDBDatabase> OpenLevelDB( |
367 const base::FilePath& file_name, | 367 const base::FilePath& file_name, |
368 const LevelDBComparator* comparator) OVERRIDE { | 368 const LevelDBComparator* comparator, bool* is_disk_full) OVERRIDE { |
369 return LevelDBDatabase::Open(file_name, comparator); | 369 return LevelDBDatabase::Open(file_name, comparator, is_disk_full); |
370 } | 370 } |
371 virtual bool DestroyLevelDB(const base::FilePath& file_name) OVERRIDE { | 371 virtual bool DestroyLevelDB(const base::FilePath& file_name) OVERRIDE { |
372 return LevelDBDatabase::Destroy(file_name); | 372 return LevelDBDatabase::Destroy(file_name); |
373 } | 373 } |
374 }; | 374 }; |
375 | 375 |
376 IndexedDBBackingStore::IndexedDBBackingStore( | 376 IndexedDBBackingStore::IndexedDBBackingStore( |
377 const string16& identifier, | 377 const string16& identifier, |
378 scoped_ptr<LevelDBDatabase> db, | 378 scoped_ptr<LevelDBDatabase> db, |
379 scoped_ptr<LevelDBComparator> comparator) | 379 scoped_ptr<LevelDBComparator> comparator) |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 1, | 492 1, |
493 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | 493 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, |
494 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | 494 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, |
495 base::HistogramBase::kUmaTargetedHistogramFlag) | 495 base::HistogramBase::kUmaTargetedHistogramFlag) |
496 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_ORIGIN_TOO_LONG); | 496 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_ORIGIN_TOO_LONG); |
497 return scoped_refptr<IndexedDBBackingStore>(); | 497 return scoped_refptr<IndexedDBBackingStore>(); |
498 } | 498 } |
499 | 499 |
500 base::FilePath file_path = path_base.Append(identifier_path); | 500 base::FilePath file_path = path_base.Append(identifier_path); |
501 | 501 |
502 db = leveldb_factory->OpenLevelDB(file_path, comparator.get()); | 502 bool is_disk_full = false; |
| 503 db = leveldb_factory->OpenLevelDB(file_path, comparator.get(), &is_disk_full); |
503 | 504 |
504 if (db) { | 505 if (db) { |
505 bool known = false; | 506 bool known = false; |
506 bool ok = IsSchemaKnown(db.get(), &known); | 507 bool ok = IsSchemaKnown(db.get(), &known); |
507 if (!ok) { | 508 if (!ok) { |
508 LOG(ERROR) << "IndexedDB had IO error checking schema, treating it as " | 509 LOG(ERROR) << "IndexedDB had IO error checking schema, treating it as " |
509 "failure to open"; | 510 "failure to open"; |
510 base::Histogram::FactoryGet( | 511 base::Histogram::FactoryGet( |
511 "WebCore.IndexedDB.BackingStore.OpenStatus", | 512 "WebCore.IndexedDB.BackingStore.OpenStatus", |
512 1, | 513 1, |
(...skipping 16 matching lines...) Expand all Loading... |
529 } | 530 } |
530 } | 531 } |
531 | 532 |
532 if (db) { | 533 if (db) { |
533 base::Histogram::FactoryGet("WebCore.IndexedDB.BackingStore.OpenStatus", | 534 base::Histogram::FactoryGet("WebCore.IndexedDB.BackingStore.OpenStatus", |
534 1, | 535 1, |
535 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | 536 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, |
536 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | 537 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, |
537 base::HistogramBase::kUmaTargetedHistogramFlag) | 538 base::HistogramBase::kUmaTargetedHistogramFlag) |
538 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_SUCCESS); | 539 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_SUCCESS); |
| 540 } else if (is_disk_full) { |
| 541 LOG(ERROR) << "Unable to open backing store - disk is full."; |
| 542 base::Histogram::FactoryGet( |
| 543 "WebCore.IndexedDB.BackingStore.OpenStatus", |
| 544 1, |
| 545 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, |
| 546 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, |
| 547 base::HistogramBase::kUmaTargetedHistogramFlag) |
| 548 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_DISK_FULL); |
| 549 return scoped_refptr<IndexedDBBackingStore>(); |
539 } else { | 550 } else { |
540 LOG(ERROR) << "IndexedDB backing store open failed, attempting cleanup"; | 551 LOG(ERROR) << "IndexedDB backing store open failed, attempting cleanup"; |
541 bool success = leveldb_factory->DestroyLevelDB(file_path); | 552 bool success = leveldb_factory->DestroyLevelDB(file_path); |
542 if (!success) { | 553 if (!success) { |
543 LOG(ERROR) << "IndexedDB backing store cleanup failed"; | 554 LOG(ERROR) << "IndexedDB backing store cleanup failed"; |
544 base::Histogram::FactoryGet( | 555 base::Histogram::FactoryGet( |
545 "WebCore.IndexedDB.BackingStore.OpenStatus", | 556 "WebCore.IndexedDB.BackingStore.OpenStatus", |
546 1, | 557 1, |
547 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | 558 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, |
548 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | 559 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, |
(...skipping 2074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2623 } | 2634 } |
2624 | 2635 |
2625 void IndexedDBBackingStore::Transaction::Rollback() { | 2636 void IndexedDBBackingStore::Transaction::Rollback() { |
2626 IDB_TRACE("IndexedDBBackingStore::Transaction::rollback"); | 2637 IDB_TRACE("IndexedDBBackingStore::Transaction::rollback"); |
2627 DCHECK(transaction_); | 2638 DCHECK(transaction_); |
2628 transaction_->Rollback(); | 2639 transaction_->Rollback(); |
2629 transaction_ = NULL; | 2640 transaction_ = NULL; |
2630 } | 2641 } |
2631 | 2642 |
2632 } // namespace content | 2643 } // namespace content |
OLD | NEW |