Chromium Code Reviews| 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 "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 : primary_key_(primary_key), version_(version) { | 377 : primary_key_(primary_key), version_(version) { |
| 378 DCHECK(!primary_key.empty()); | 378 DCHECK(!primary_key.empty()); |
| 379 } | 379 } |
| 380 IndexedDBBackingStore::RecordIdentifier::RecordIdentifier() | 380 IndexedDBBackingStore::RecordIdentifier::RecordIdentifier() |
| 381 : primary_key_(), version_(-1) {} | 381 : primary_key_(), version_(-1) {} |
| 382 IndexedDBBackingStore::RecordIdentifier::~RecordIdentifier() {} | 382 IndexedDBBackingStore::RecordIdentifier::~RecordIdentifier() {} |
| 383 | 383 |
| 384 IndexedDBBackingStore::Cursor::CursorOptions::CursorOptions() {} | 384 IndexedDBBackingStore::Cursor::CursorOptions::CursorOptions() {} |
| 385 IndexedDBBackingStore::Cursor::CursorOptions::~CursorOptions() {} | 385 IndexedDBBackingStore::Cursor::CursorOptions::~CursorOptions() {} |
| 386 | 386 |
| 387 enum IndexedDBLevelDBBackingStoreOpenResult { | 387 enum IndexedDBBackingStoreOpenResult { |
| 388 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MEMORY_SUCCESS, | 388 INDEXED_DB_BACKING_STORE_OPEN_MEMORY_SUCCESS, |
| 389 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_SUCCESS, | 389 INDEXED_DB_BACKING_STORE_OPEN_SUCCESS, |
| 390 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_FAILED_DIRECTORY, | 390 INDEXED_DB_BACKING_STORE_OPEN_FAILED_DIRECTORY, |
| 391 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_FAILED_UNKNOWN_SCHEMA, | 391 INDEXED_DB_BACKING_STORE_OPEN_FAILED_UNKNOWN_SCHEMA, |
| 392 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_CLEANUP_DESTROY_FAILED, | 392 INDEXED_DB_BACKING_STORE_OPEN_CLEANUP_DESTROY_FAILED, |
| 393 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_CLEANUP_REOPEN_FAILED, | 393 INDEXED_DB_BACKING_STORE_OPEN_CLEANUP_REOPEN_FAILED, |
| 394 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_CLEANUP_REOPEN_SUCCESS, | 394 INDEXED_DB_BACKING_STORE_OPEN_CLEANUP_REOPEN_SUCCESS, |
| 395 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_FAILED_IO_ERROR_CHECKING_SCHEMA, | 395 INDEXED_DB_BACKING_STORE_OPEN_FAILED_IO_ERROR_CHECKING_SCHEMA, |
| 396 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_FAILED_UNKNOWN_ERR, | 396 INDEXED_DB_BACKING_STORE_OPEN_FAILED_UNKNOWN_ERR, |
| 397 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MEMORY_FAILED, | 397 INDEXED_DB_BACKING_STORE_OPEN_MEMORY_FAILED, |
| 398 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_ATTEMPT_NON_ASCII, | 398 INDEXED_DB_BACKING_STORE_OPEN_ATTEMPT_NON_ASCII, |
| 399 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_DISK_FULL, | 399 INDEXED_DB_BACKING_STORE_OPEN_DISK_FULL, |
| 400 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_ORIGIN_TOO_LONG, | 400 INDEXED_DB_BACKING_STORE_OPEN_ORIGIN_TOO_LONG, |
| 401 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_NO_RECOVERY, | 401 INDEXED_DB_BACKING_STORE_OPEN_NO_RECOVERY, |
| 402 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | 402 INDEXED_DB_BACKING_STORE_OPEN_MAX, |
| 403 }; | 403 }; |
| 404 | 404 |
| 405 // TODO(dgrogan): Move to leveldb_env. | 405 // TODO(dgrogan): Move to leveldb_env. |
| 406 bool RecoveryCouldBeFruitful(leveldb::Status status) { | 406 bool RecoveryCouldBeFruitful(leveldb::Status status) { |
| 407 leveldb_env::MethodID method; | 407 leveldb_env::MethodID method; |
| 408 int error = -1; | 408 int error = -1; |
| 409 leveldb_env::ErrorParsingResult result = leveldb_env::ParseMethodAndError( | 409 leveldb_env::ErrorParsingResult result = leveldb_env::ParseMethodAndError( |
| 410 status.ToString().c_str(), &method, &error); | 410 status.ToString().c_str(), &method, &error); |
| 411 switch (result) { | 411 switch (result) { |
| 412 case leveldb_env::NONE: | 412 case leveldb_env::NONE: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 *data_loss = WebKit::WebIDBCallbacks::DataLossNone; | 447 *data_loss = WebKit::WebIDBCallbacks::DataLossNone; |
| 448 DefaultLevelDBFactory leveldb_factory; | 448 DefaultLevelDBFactory leveldb_factory; |
| 449 return IndexedDBBackingStore::Open(origin_identifier, | 449 return IndexedDBBackingStore::Open(origin_identifier, |
| 450 path_base, | 450 path_base, |
| 451 file_identifier, | 451 file_identifier, |
| 452 data_loss, | 452 data_loss, |
| 453 disk_full, | 453 disk_full, |
| 454 &leveldb_factory); | 454 &leveldb_factory); |
| 455 } | 455 } |
| 456 | 456 |
| 457 static void HistogramOpenStatus(IndexedDBBackingStoreOpenResult result) { | |
| 458 UMA_HISTOGRAM_ENUMERATION("WebCore.IndexedDB.BackingStore.OpenStatus", | |
| 459 result, | |
| 460 INDEXED_DB_BACKING_STORE_OPEN_MAX); | |
| 461 } | |
| 462 | |
| 463 // TODO(dgrogan): This only checks the lengths of the path components. It should | |
| 464 // also check the total path length against MAX_PATH. | |
|
jsbell
2013/10/01 23:56:46
I believe this is done implicitly by the call to G
dgrogan
2013/10/02 00:54:24
True. Comment removed.
| |
| 465 static bool IsPathTooLong(const base::FilePath& leveldb_dir) { | |
| 466 int limit = file_util::GetMaximumPathComponentLength(leveldb_dir); | |
|
jsbell
2013/10/01 23:56:46
Based on the windows impl of GetMaximumPathCompone
dgrogan
2013/10/02 00:54:24
Good catch. Changed back to only using the base di
| |
| 467 if (limit == -1) { | |
| 468 DLOG(WARNING) << "GetMaximumPathComponentLength returned -1"; | |
| 469 // In limited testing, ChromeOS returns 143, other OSes 255. | |
|
jsbell
2013/10/01 23:56:46
Bonus points if you can make clang-format not want
| |
| 470 #if defined(OS_CHROMEOS) | |
| 471 limit = 143; | |
| 472 #else | |
| 473 limit = 255; | |
| 474 #endif | |
| 475 } | |
| 476 size_t component_length = leveldb_dir.BaseName().value().length(); | |
| 477 if (component_length > static_cast<uint32_t>(limit)) { | |
| 478 DLOG(WARNING) << "Path component length (" << component_length | |
| 479 << ") exceeds maximum (" << limit | |
| 480 << ") allowed by this filesystem."; | |
| 481 const int min = 140; | |
| 482 const int max = 300; | |
| 483 const int num_buckets = 12; | |
| 484 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
| 485 "WebCore.IndexedDB.BackingStore.OverlyLargeOriginLength", | |
| 486 component_length, | |
| 487 min, | |
| 488 max, | |
| 489 num_buckets); | |
| 490 return true; | |
| 491 } | |
| 492 return false; | |
| 493 } | |
| 494 | |
| 457 scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::Open( | 495 scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::Open( |
| 458 const std::string& origin_identifier, | 496 const std::string& origin_identifier, |
| 459 const base::FilePath& path_base, | 497 const base::FilePath& path_base, |
| 460 const std::string& file_identifier, | 498 const std::string& file_identifier, |
| 461 WebKit::WebIDBCallbacks::DataLoss* data_loss, | 499 WebKit::WebIDBCallbacks::DataLoss* data_loss, |
| 462 bool* is_disk_full, | 500 bool* is_disk_full, |
| 463 LevelDBFactory* leveldb_factory) { | 501 LevelDBFactory* leveldb_factory) { |
| 464 IDB_TRACE("IndexedDBBackingStore::Open"); | 502 IDB_TRACE("IndexedDBBackingStore::Open"); |
| 465 DCHECK(!path_base.empty()); | 503 DCHECK(!path_base.empty()); |
| 466 *data_loss = WebKit::WebIDBCallbacks::DataLossNone; | 504 *data_loss = WebKit::WebIDBCallbacks::DataLossNone; |
| 467 *is_disk_full = false; | 505 *is_disk_full = false; |
| 468 | 506 |
| 469 scoped_ptr<LevelDBComparator> comparator(new Comparator()); | 507 scoped_ptr<LevelDBComparator> comparator(new Comparator()); |
| 470 | 508 |
| 471 if (!IsStringASCII(path_base.AsUTF8Unsafe())) { | 509 if (!IsStringASCII(path_base.AsUTF8Unsafe())) { |
| 472 base::Histogram::FactoryGet("WebCore.IndexedDB.BackingStore.OpenStatus", | 510 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_ATTEMPT_NON_ASCII); |
| 473 1, | |
| 474 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | |
| 475 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | |
| 476 base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 477 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_ATTEMPT_NON_ASCII); | |
| 478 } | 511 } |
| 479 if (!file_util::CreateDirectory(path_base)) { | 512 if (!file_util::CreateDirectory(path_base)) { |
| 480 LOG(ERROR) << "Unable to create IndexedDB database path " | 513 LOG(ERROR) << "Unable to create IndexedDB database path " |
| 481 << path_base.AsUTF8Unsafe(); | 514 << path_base.AsUTF8Unsafe(); |
| 482 base::Histogram::FactoryGet("WebCore.IndexedDB.BackingStore.OpenStatus", | 515 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_FAILED_DIRECTORY); |
| 483 1, | |
| 484 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | |
| 485 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | |
| 486 base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 487 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_FAILED_DIRECTORY); | |
| 488 return scoped_refptr<IndexedDBBackingStore>(); | 516 return scoped_refptr<IndexedDBBackingStore>(); |
| 489 } | 517 } |
| 490 | 518 |
| 491 base::FilePath identifier_path = | 519 base::FilePath file_path = |
| 492 base::FilePath().AppendASCII(origin_identifier) | 520 path_base.AppendASCII(origin_identifier) |
| 493 .AddExtension(FILE_PATH_LITERAL(".indexeddb.leveldb")); | 521 .AddExtension(FILE_PATH_LITERAL(".indexeddb.leveldb")); |
| 494 | 522 |
| 495 int limit = file_util::GetMaximumPathComponentLength(path_base); | 523 if (IsPathTooLong(file_path)) { |
| 496 if (limit == -1) { | 524 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_ORIGIN_TOO_LONG); |
| 497 DLOG(WARNING) << "GetMaximumPathComponentLength returned -1"; | |
| 498 // In limited testing, ChromeOS returns 143, other OSes 255. | |
| 499 #if defined(OS_CHROMEOS) | |
| 500 limit = 143; | |
| 501 #else | |
| 502 limit = 255; | |
| 503 #endif | |
| 504 } | |
| 505 if (identifier_path.value().length() > static_cast<uint32_t>(limit)) { | |
| 506 DLOG(WARNING) << "Path component length (" | |
| 507 << identifier_path.value().length() << ") exceeds maximum (" | |
| 508 << limit << ") allowed by this filesystem."; | |
| 509 const int min = 140; | |
| 510 const int max = 300; | |
| 511 const int num_buckets = 12; | |
| 512 // TODO(dgrogan): Remove WebCore from these histogram names. | |
| 513 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
| 514 "WebCore.IndexedDB.BackingStore.OverlyLargeOriginLength", | |
| 515 identifier_path.value().length(), | |
| 516 min, | |
| 517 max, | |
| 518 num_buckets); | |
| 519 // TODO(dgrogan): Translate the FactoryGet calls to | |
| 520 // UMA_HISTOGRAM_ENUMERATION. FactoryGet was the most direct translation | |
| 521 // from the WebCore code. | |
| 522 base::Histogram::FactoryGet("WebCore.IndexedDB.BackingStore.OpenStatus", | |
| 523 1, | |
| 524 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | |
| 525 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | |
| 526 base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 527 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_ORIGIN_TOO_LONG); | |
| 528 return scoped_refptr<IndexedDBBackingStore>(); | 525 return scoped_refptr<IndexedDBBackingStore>(); |
| 529 } | 526 } |
| 530 | 527 |
| 531 base::FilePath file_path = path_base.Append(identifier_path); | |
| 532 | |
| 533 scoped_ptr<LevelDBDatabase> db; | 528 scoped_ptr<LevelDBDatabase> db; |
| 534 leveldb::Status status = leveldb_factory->OpenLevelDB( | 529 leveldb::Status status = leveldb_factory->OpenLevelDB( |
| 535 file_path, comparator.get(), &db, is_disk_full); | 530 file_path, comparator.get(), &db, is_disk_full); |
| 536 | 531 |
| 537 if (!status.ok() && leveldb_env::IndicatesDiskFull(status)) { | 532 if (!status.ok() && leveldb_env::IndicatesDiskFull(status)) { |
| 538 DCHECK(!db); | 533 DCHECK(!db); |
| 539 *is_disk_full = true; | 534 *is_disk_full = true; |
| 540 } | 535 } |
| 541 | 536 |
| 542 if (db) { | 537 if (db) { |
| 543 bool known = false; | 538 bool known = false; |
| 544 bool ok = IsSchemaKnown(db.get(), &known); | 539 bool ok = IsSchemaKnown(db.get(), &known); |
| 545 if (!ok) { | 540 if (!ok) { |
| 546 LOG(ERROR) << "IndexedDB had IO error checking schema, treating it as " | 541 LOG(ERROR) << "IndexedDB had IO error checking schema, treating it as " |
| 547 "failure to open"; | 542 "failure to open"; |
| 548 base::Histogram::FactoryGet( | 543 HistogramOpenStatus( |
| 549 "WebCore.IndexedDB.BackingStore.OpenStatus", | 544 INDEXED_DB_BACKING_STORE_OPEN_FAILED_IO_ERROR_CHECKING_SCHEMA); |
| 550 1, | |
| 551 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | |
| 552 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | |
| 553 base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 554 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_FAILED_IO_ERROR_CHECKING_ SCHEMA); | |
| 555 db.reset(); | 545 db.reset(); |
| 556 } else if (!known) { | 546 } else if (!known) { |
| 557 LOG(ERROR) << "IndexedDB backing store had unknown schema, treating it " | 547 LOG(ERROR) << "IndexedDB backing store had unknown schema, treating it " |
| 558 "as failure to open"; | 548 "as failure to open"; |
| 559 base::Histogram::FactoryGet( | 549 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_FAILED_UNKNOWN_SCHEMA); |
| 560 "WebCore.IndexedDB.BackingStore.OpenStatus", | |
| 561 1, | |
| 562 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | |
| 563 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | |
| 564 base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 565 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_FAILED_UNKNOWN_SCHEMA); | |
| 566 db.reset(); | 550 db.reset(); |
| 567 } | 551 } |
| 568 } | 552 } |
| 569 | 553 |
| 570 if (db) { | 554 if (db) { |
| 571 base::Histogram::FactoryGet("WebCore.IndexedDB.BackingStore.OpenStatus", | 555 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_SUCCESS); |
| 572 1, | |
| 573 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | |
| 574 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | |
| 575 base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 576 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_SUCCESS); | |
| 577 } else if (!RecoveryCouldBeFruitful(status)) { | 556 } else if (!RecoveryCouldBeFruitful(status)) { |
| 578 LOG(ERROR) << "Unable to open backing store, not trying to recover - " | 557 LOG(ERROR) << "Unable to open backing store, not trying to recover - " |
| 579 << status.ToString(); | 558 << status.ToString(); |
| 580 base::Histogram::FactoryGet("WebCore.IndexedDB.BackingStore.OpenStatus", | 559 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_NO_RECOVERY); |
| 581 1, | |
| 582 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | |
| 583 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | |
| 584 base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 585 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_NO_RECOVERY); | |
| 586 return scoped_refptr<IndexedDBBackingStore>(); | 560 return scoped_refptr<IndexedDBBackingStore>(); |
| 587 } else if (*is_disk_full) { | 561 } else if (*is_disk_full) { |
| 588 LOG(ERROR) << "Unable to open backing store - disk is full."; | 562 LOG(ERROR) << "Unable to open backing store - disk is full."; |
| 589 base::Histogram::FactoryGet("WebCore.IndexedDB.BackingStore.OpenStatus", | 563 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_DISK_FULL); |
| 590 1, | |
| 591 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | |
| 592 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | |
| 593 base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 594 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_DISK_FULL); | |
| 595 return scoped_refptr<IndexedDBBackingStore>(); | 564 return scoped_refptr<IndexedDBBackingStore>(); |
| 596 } else { | 565 } else { |
| 597 LOG(ERROR) << "IndexedDB backing store open failed, attempting cleanup"; | 566 LOG(ERROR) << "IndexedDB backing store open failed, attempting cleanup"; |
| 598 *data_loss = WebKit::WebIDBCallbacks::DataLossTotal; | 567 *data_loss = WebKit::WebIDBCallbacks::DataLossTotal; |
| 599 bool success = leveldb_factory->DestroyLevelDB(file_path); | 568 bool success = leveldb_factory->DestroyLevelDB(file_path); |
| 600 if (!success) { | 569 if (!success) { |
| 601 LOG(ERROR) << "IndexedDB backing store cleanup failed"; | 570 LOG(ERROR) << "IndexedDB backing store cleanup failed"; |
| 602 base::Histogram::FactoryGet( | 571 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_CLEANUP_DESTROY_FAILED); |
| 603 "WebCore.IndexedDB.BackingStore.OpenStatus", | |
| 604 1, | |
| 605 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | |
| 606 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | |
| 607 base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 608 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_CLEANUP_DESTROY_FAILED); | |
| 609 return scoped_refptr<IndexedDBBackingStore>(); | 572 return scoped_refptr<IndexedDBBackingStore>(); |
| 610 } | 573 } |
| 611 | 574 |
| 612 LOG(ERROR) << "IndexedDB backing store cleanup succeeded, reopening"; | 575 LOG(ERROR) << "IndexedDB backing store cleanup succeeded, reopening"; |
| 613 leveldb_factory->OpenLevelDB(file_path, comparator.get(), &db, NULL); | 576 leveldb_factory->OpenLevelDB(file_path, comparator.get(), &db, NULL); |
| 614 if (!db) { | 577 if (!db) { |
| 615 LOG(ERROR) << "IndexedDB backing store reopen after recovery failed"; | 578 LOG(ERROR) << "IndexedDB backing store reopen after recovery failed"; |
| 616 base::Histogram::FactoryGet( | 579 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_CLEANUP_REOPEN_FAILED); |
| 617 "WebCore.IndexedDB.BackingStore.OpenStatus", | |
| 618 1, | |
| 619 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | |
| 620 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | |
| 621 base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 622 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_CLEANUP_REOPEN_FAILED); | |
| 623 return scoped_refptr<IndexedDBBackingStore>(); | 580 return scoped_refptr<IndexedDBBackingStore>(); |
| 624 } | 581 } |
| 625 base::Histogram::FactoryGet("WebCore.IndexedDB.BackingStore.OpenStatus", | 582 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_CLEANUP_REOPEN_SUCCESS); |
| 626 1, | |
| 627 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | |
| 628 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | |
| 629 base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 630 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_CLEANUP_REOPEN_SUCCESS); | |
| 631 } | 583 } |
| 632 | 584 |
| 633 if (!db) { | 585 if (!db) { |
| 634 NOTREACHED(); | 586 NOTREACHED(); |
| 635 base::Histogram::FactoryGet("WebCore.IndexedDB.BackingStore.OpenStatus", | 587 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_FAILED_UNKNOWN_ERR); |
| 636 1, | |
| 637 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | |
| 638 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | |
| 639 base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 640 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_FAILED_UNKNOWN_ERR); | |
| 641 return scoped_refptr<IndexedDBBackingStore>(); | 588 return scoped_refptr<IndexedDBBackingStore>(); |
| 642 } | 589 } |
| 643 | 590 |
| 644 return Create(file_identifier, db.Pass(), comparator.Pass()); | 591 return Create(file_identifier, db.Pass(), comparator.Pass()); |
| 645 } | 592 } |
| 646 | 593 |
| 647 scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::OpenInMemory( | 594 scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::OpenInMemory( |
| 648 const std::string& file_identifier) { | 595 const std::string& file_identifier) { |
| 649 DefaultLevelDBFactory leveldb_factory; | 596 DefaultLevelDBFactory leveldb_factory; |
| 650 return IndexedDBBackingStore::OpenInMemory(file_identifier, &leveldb_factory); | 597 return IndexedDBBackingStore::OpenInMemory(file_identifier, &leveldb_factory); |
| 651 } | 598 } |
| 652 | 599 |
| 653 scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::OpenInMemory( | 600 scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::OpenInMemory( |
| 654 const std::string& file_identifier, | 601 const std::string& file_identifier, |
| 655 LevelDBFactory* leveldb_factory) { | 602 LevelDBFactory* leveldb_factory) { |
| 656 IDB_TRACE("IndexedDBBackingStore::OpenInMemory"); | 603 IDB_TRACE("IndexedDBBackingStore::OpenInMemory"); |
| 657 | 604 |
| 658 scoped_ptr<LevelDBComparator> comparator(new Comparator()); | 605 scoped_ptr<LevelDBComparator> comparator(new Comparator()); |
| 659 scoped_ptr<LevelDBDatabase> db = | 606 scoped_ptr<LevelDBDatabase> db = |
| 660 LevelDBDatabase::OpenInMemory(comparator.get()); | 607 LevelDBDatabase::OpenInMemory(comparator.get()); |
| 661 if (!db) { | 608 if (!db) { |
| 662 LOG(ERROR) << "LevelDBDatabase::OpenInMemory failed."; | 609 LOG(ERROR) << "LevelDBDatabase::OpenInMemory failed."; |
| 663 base::Histogram::FactoryGet("WebCore.IndexedDB.BackingStore.OpenStatus", | 610 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_MEMORY_FAILED); |
| 664 1, | |
| 665 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | |
| 666 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | |
| 667 base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 668 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MEMORY_FAILED); | |
| 669 return scoped_refptr<IndexedDBBackingStore>(); | 611 return scoped_refptr<IndexedDBBackingStore>(); |
| 670 } | 612 } |
| 671 base::Histogram::FactoryGet("WebCore.IndexedDB.BackingStore.OpenStatus", | 613 HistogramOpenStatus(INDEXED_DB_BACKING_STORE_OPEN_MEMORY_SUCCESS); |
| 672 1, | |
| 673 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX, | |
| 674 INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1, | |
| 675 base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 676 ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MEMORY_SUCCESS); | |
| 677 | 614 |
| 678 return Create(file_identifier, db.Pass(), comparator.Pass()); | 615 return Create(file_identifier, db.Pass(), comparator.Pass()); |
| 679 } | 616 } |
| 680 | 617 |
| 681 scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::Create( | 618 scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::Create( |
| 682 const std::string& identifier, | 619 const std::string& identifier, |
| 683 scoped_ptr<LevelDBDatabase> db, | 620 scoped_ptr<LevelDBDatabase> db, |
| 684 scoped_ptr<LevelDBComparator> comparator) { | 621 scoped_ptr<LevelDBComparator> comparator) { |
| 685 // TODO(jsbell): Handle comparator name changes. | 622 // TODO(jsbell): Handle comparator name changes. |
| 686 scoped_refptr<IndexedDBBackingStore> backing_store( | 623 scoped_refptr<IndexedDBBackingStore> backing_store( |
| (...skipping 1951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2638 } | 2575 } |
| 2639 | 2576 |
| 2640 void IndexedDBBackingStore::Transaction::Rollback() { | 2577 void IndexedDBBackingStore::Transaction::Rollback() { |
| 2641 IDB_TRACE("IndexedDBBackingStore::Transaction::Rollback"); | 2578 IDB_TRACE("IndexedDBBackingStore::Transaction::Rollback"); |
| 2642 DCHECK(transaction_.get()); | 2579 DCHECK(transaction_.get()); |
| 2643 transaction_->Rollback(); | 2580 transaction_->Rollback(); |
| 2644 transaction_ = NULL; | 2581 transaction_ = NULL; |
| 2645 } | 2582 } |
| 2646 | 2583 |
| 2647 } // namespace content | 2584 } // namespace content |
| OLD | NEW |