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

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

Issue 1238393003: [IndexedDB] Adding traces, perf tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 5 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_backing_store.h" 5 #include "content/browser/indexed_db/indexed_db_backing_store.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 return AppendBlobsToBlobJournal(transaction, LiveBlobJournalKey::Encode(), 659 return AppendBlobsToBlobJournal(transaction, LiveBlobJournalKey::Encode(),
660 journal); 660 journal);
661 } 661 }
662 662
663 // Append a database to the specified blob journal via the supplied transaction. 663 // Append a database to the specified blob journal via the supplied transaction.
664 // The key must be either the primary journal key or live journal key. 664 // The key must be either the primary journal key or live journal key.
665 static leveldb::Status MergeDatabaseIntoBlobJournal( 665 static leveldb::Status MergeDatabaseIntoBlobJournal(
666 LevelDBDirectTransaction* transaction, 666 LevelDBDirectTransaction* transaction,
667 const std::string& key, 667 const std::string& key,
668 int64 database_id) { 668 int64 database_id) {
669 IDB_TRACE("IndexedDBBackingStore::MergeDatabaseIntoBlobJournal");
669 BlobJournalType journal; 670 BlobJournalType journal;
670 leveldb::Status s = GetBlobJournal(key, transaction, &journal); 671 leveldb::Status s = GetBlobJournal(key, transaction, &journal);
671 if (!s.ok()) 672 if (!s.ok())
672 return s; 673 return s;
673 journal.push_back( 674 journal.push_back(
674 std::make_pair(database_id, DatabaseMetaDataKey::kAllBlobsKey)); 675 std::make_pair(database_id, DatabaseMetaDataKey::kAllBlobsKey));
675 UpdateBlobJournal(transaction, key, journal); 676 UpdateBlobJournal(transaction, key, journal);
676 return leveldb::Status::OK(); 677 return leveldb::Status::OK();
677 } 678 }
678 679
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 s = GetIDBDatabaseMetaData(name, &metadata, &success); 1468 s = GetIDBDatabaseMetaData(name, &metadata, &success);
1468 if (!s.ok()) 1469 if (!s.ok())
1469 return s; 1470 return s;
1470 if (!success) 1471 if (!success)
1471 return leveldb::Status::OK(); 1472 return leveldb::Status::OK();
1472 1473
1473 const std::string start_key = DatabaseMetaDataKey::Encode( 1474 const std::string start_key = DatabaseMetaDataKey::Encode(
1474 metadata.id, DatabaseMetaDataKey::ORIGIN_NAME); 1475 metadata.id, DatabaseMetaDataKey::ORIGIN_NAME);
1475 const std::string stop_key = DatabaseMetaDataKey::Encode( 1476 const std::string stop_key = DatabaseMetaDataKey::Encode(
1476 metadata.id + 1, DatabaseMetaDataKey::ORIGIN_NAME); 1477 metadata.id + 1, DatabaseMetaDataKey::ORIGIN_NAME);
1477 scoped_ptr<LevelDBIterator> it = db_->CreateIterator(); 1478 {
1478 for (s = it->Seek(start_key); 1479 IDB_TRACE("IndexedDBBackingStore::DeleteDatabase::DeleteEntries");
cmumford 2015/08/03 17:31:33 Nit: I believe that all other traces we use <class
dmurph 2015/08/05 15:30:32 Sure, that sounds good. I'll switch to the '.' ver
1479 s.ok() && it->IsValid() && CompareKeys(it->Key(), stop_key) < 0; 1480 scoped_ptr<LevelDBIterator> it = db_->CreateIterator();
1480 s = it->Next()) 1481 for (s = it->Seek(start_key);
1481 transaction->Remove(it->Key()); 1482 s.ok() && it->IsValid() && CompareKeys(it->Key(), stop_key) < 0;
1483 s = it->Next())
1484 transaction->Remove(it->Key());
1485 }
1482 if (!s.ok()) { 1486 if (!s.ok()) {
1483 INTERNAL_WRITE_ERROR_UNTESTED(DELETE_DATABASE); 1487 INTERNAL_WRITE_ERROR_UNTESTED(DELETE_DATABASE);
1484 return s; 1488 return s;
1485 } 1489 }
1486 1490
1487 const std::string key = DatabaseNameKey::Encode(origin_identifier_, name); 1491 const std::string key = DatabaseNameKey::Encode(origin_identifier_, name);
1488 transaction->Remove(key); 1492 transaction->Remove(key);
1489 1493
1490 bool need_cleanup = false; 1494 bool need_cleanup = false;
1491 if (active_blob_registry()->MarkDeletedCheckIfUsed( 1495 if (active_blob_registry()->MarkDeletedCheckIfUsed(
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after
2705 DCHECK(DatabaseMetaDataKey::IsValidBlobKey(blob_key)); 2709 DCHECK(DatabaseMetaDataKey::IsValidBlobKey(blob_key));
2706 if (!RemoveBlobFile(database_id, blob_key)) 2710 if (!RemoveBlobFile(database_id, blob_key))
2707 return IOErrorStatus(); 2711 return IOErrorStatus();
2708 } 2712 }
2709 } 2713 }
2710 return leveldb::Status::OK(); 2714 return leveldb::Status::OK();
2711 } 2715 }
2712 2716
2713 leveldb::Status IndexedDBBackingStore::CleanUpBlobJournal( 2717 leveldb::Status IndexedDBBackingStore::CleanUpBlobJournal(
2714 const std::string& level_db_key) const { 2718 const std::string& level_db_key) const {
2719 IDB_TRACE("IndexedDBBackingStore::CleanUpBlobJournal");
2715 DCHECK(!committing_transaction_count_); 2720 DCHECK(!committing_transaction_count_);
2716 leveldb::Status s; 2721 leveldb::Status s;
2717 scoped_refptr<LevelDBTransaction> journal_transaction = 2722 scoped_refptr<LevelDBTransaction> journal_transaction =
2718 IndexedDBClassFactory::Get()->CreateLevelDBTransaction(db_.get()); 2723 IndexedDBClassFactory::Get()->CreateLevelDBTransaction(db_.get());
2719 BlobJournalType journal; 2724 BlobJournalType journal;
2720 2725
2721 s = GetBlobJournal(level_db_key, journal_transaction.get(), &journal); 2726 s = GetBlobJournal(level_db_key, journal_transaction.get(), &journal);
2722 if (!s.ok()) 2727 if (!s.ok())
2723 return s; 2728 return s;
2724 if (journal.empty()) 2729 if (journal.empty())
(...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after
4493 4498
4494 IndexedDBBackingStore::Transaction::WriteDescriptor::WriteDescriptor( 4499 IndexedDBBackingStore::Transaction::WriteDescriptor::WriteDescriptor(
4495 const WriteDescriptor& other) = default; 4500 const WriteDescriptor& other) = default;
4496 IndexedDBBackingStore::Transaction::WriteDescriptor::~WriteDescriptor() = 4501 IndexedDBBackingStore::Transaction::WriteDescriptor::~WriteDescriptor() =
4497 default; 4502 default;
4498 IndexedDBBackingStore::Transaction::WriteDescriptor& 4503 IndexedDBBackingStore::Transaction::WriteDescriptor&
4499 IndexedDBBackingStore::Transaction::WriteDescriptor:: 4504 IndexedDBBackingStore::Transaction::WriteDescriptor::
4500 operator=(const WriteDescriptor& other) = default; 4505 operator=(const WriteDescriptor& other) = default;
4501 4506
4502 } // namespace content 4507 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698