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/leveldb/leveldb_transaction.h" | 5 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "content/browser/indexed_db/indexed_db_tracing.h" |
10 #include "content/browser/indexed_db/leveldb/leveldb_database.h" | 11 #include "content/browser/indexed_db/leveldb/leveldb_database.h" |
11 #include "content/browser/indexed_db/leveldb/leveldb_write_batch.h" | 12 #include "content/browser/indexed_db/leveldb/leveldb_write_batch.h" |
12 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 13 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
13 | 14 |
14 using base::StringPiece; | 15 using base::StringPiece; |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
18 LevelDBTransaction::LevelDBTransaction(LevelDBDatabase* db) | 19 LevelDBTransaction::LevelDBTransaction(LevelDBDatabase* db) |
19 : db_(db), | 20 : db_(db), |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 82 } |
82 | 83 |
83 leveldb::Status s = db_->Get(key, value, found, &snapshot_); | 84 leveldb::Status s = db_->Get(key, value, found, &snapshot_); |
84 if (!s.ok()) | 85 if (!s.ok()) |
85 DCHECK(!*found); | 86 DCHECK(!*found); |
86 return s; | 87 return s; |
87 } | 88 } |
88 | 89 |
89 leveldb::Status LevelDBTransaction::Commit() { | 90 leveldb::Status LevelDBTransaction::Commit() { |
90 DCHECK(!finished_); | 91 DCHECK(!finished_); |
| 92 IDB_TRACE("LevelDBTransaction::Commit"); |
91 | 93 |
92 if (data_.empty()) { | 94 if (data_.empty()) { |
93 finished_ = true; | 95 finished_ = true; |
94 return leveldb::Status::OK(); | 96 return leveldb::Status::OK(); |
95 } | 97 } |
96 | 98 |
97 base::TimeTicks begin_time = base::TimeTicks::Now(); | 99 base::TimeTicks begin_time = base::TimeTicks::Now(); |
98 scoped_ptr<LevelDBWriteBatch> write_batch = LevelDBWriteBatch::Create(); | 100 scoped_ptr<LevelDBWriteBatch> write_batch = LevelDBWriteBatch::Create(); |
99 | 101 |
100 for (const auto& iterator : data_) { | 102 for (const auto& iterator : data_) { |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 return s; | 477 return s; |
476 } | 478 } |
477 | 479 |
478 void LevelDBDirectTransaction::Remove(const StringPiece& key) { | 480 void LevelDBDirectTransaction::Remove(const StringPiece& key) { |
479 DCHECK(!finished_); | 481 DCHECK(!finished_); |
480 write_batch_->Remove(key); | 482 write_batch_->Remove(key); |
481 } | 483 } |
482 | 484 |
483 leveldb::Status LevelDBDirectTransaction::Commit() { | 485 leveldb::Status LevelDBDirectTransaction::Commit() { |
484 DCHECK(!finished_); | 486 DCHECK(!finished_); |
| 487 IDB_TRACE("LevelDBDirectTransaction::Commit"); |
485 | 488 |
486 leveldb::Status s = db_->Write(*write_batch_); | 489 leveldb::Status s = db_->Write(*write_batch_); |
487 if (s.ok()) { | 490 if (s.ok()) { |
488 finished_ = true; | 491 finished_ = true; |
489 write_batch_->Clear(); | 492 write_batch_->Clear(); |
490 } | 493 } |
491 return s; | 494 return s; |
492 } | 495 } |
493 | 496 |
494 } // namespace content | 497 } // namespace content |
OLD | NEW |