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/leveldb/leveldb_database.h" | 5 #include "content/browser/indexed_db/leveldb/leveldb_database.h" |
| 6 | 6 |
| 7 #include <cerrno> | 7 #include <cerrno> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/sys_info.h" | 18 #include "base/sys_info.h" |
| 19 #include "base/trace_event/trace_event.h" | |
| 19 #include "content/browser/indexed_db/indexed_db_class_factory.h" | 20 #include "content/browser/indexed_db/indexed_db_class_factory.h" |
| 21 #include "content/browser/indexed_db/indexed_db_tracing.h" | |
| 20 #include "content/browser/indexed_db/leveldb/leveldb_comparator.h" | 22 #include "content/browser/indexed_db/leveldb/leveldb_comparator.h" |
| 21 #include "content/browser/indexed_db/leveldb/leveldb_env.h" | 23 #include "content/browser/indexed_db/leveldb/leveldb_env.h" |
| 22 #include "content/browser/indexed_db/leveldb/leveldb_iterator_impl.h" | 24 #include "content/browser/indexed_db/leveldb/leveldb_iterator_impl.h" |
| 23 #include "content/browser/indexed_db/leveldb/leveldb_write_batch.h" | 25 #include "content/browser/indexed_db/leveldb/leveldb_write_batch.h" |
| 24 #include "third_party/leveldatabase/env_chromium.h" | 26 #include "third_party/leveldatabase/env_chromium.h" |
| 25 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" | 27 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" |
| 26 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 28 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
| 27 #include "third_party/leveldatabase/src/include/leveldb/env.h" | 29 #include "third_party/leveldatabase/src/include/leveldb/env.h" |
| 28 #include "third_party/leveldatabase/src/include/leveldb/filter_policy.h" | 30 #include "third_party/leveldatabase/src/include/leveldb/filter_policy.h" |
| 29 #include "third_party/leveldatabase/src/include/leveldb/slice.h" | 31 #include "third_party/leveldatabase/src/include/leveldb/slice.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 base::TimeTicks::Now() - begin_time); | 101 base::TimeTicks::Now() - begin_time); |
| 100 } | 102 } |
| 101 } | 103 } |
| 102 | 104 |
| 103 static leveldb::Status OpenDB( | 105 static leveldb::Status OpenDB( |
| 104 leveldb::Comparator* comparator, | 106 leveldb::Comparator* comparator, |
| 105 leveldb::Env* env, | 107 leveldb::Env* env, |
| 106 const base::FilePath& path, | 108 const base::FilePath& path, |
| 107 leveldb::DB** db, | 109 leveldb::DB** db, |
| 108 scoped_ptr<const leveldb::FilterPolicy>* filter_policy) { | 110 scoped_ptr<const leveldb::FilterPolicy>* filter_policy) { |
| 111 IDB_TRACE("LevelDBDatabase::Open"); | |
|
cmumford
2015/08/03 17:31:33
What do you think about actually making this a sta
dmurph
2015/08/05 15:30:32
There already is one, I'll just move this trace th
| |
| 109 filter_policy->reset(leveldb::NewBloomFilterPolicy(10)); | 112 filter_policy->reset(leveldb::NewBloomFilterPolicy(10)); |
| 110 leveldb::Options options; | 113 leveldb::Options options; |
| 111 options.comparator = comparator; | 114 options.comparator = comparator; |
| 112 options.create_if_missing = true; | 115 options.create_if_missing = true; |
| 113 options.paranoid_checks = true; | 116 options.paranoid_checks = true; |
| 114 options.filter_policy = filter_policy->get(); | 117 options.filter_policy = filter_policy->get(); |
| 115 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue; | 118 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue; |
| 116 options.compression = leveldb::kSnappyCompression; | 119 options.compression = leveldb::kSnappyCompression; |
| 117 | 120 |
| 118 // For info about the troubles we've run into with this parameter, see: | 121 // For info about the troubles we've run into with this parameter, see: |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 416 return scoped_ptr<LevelDBIterator>( | 419 return scoped_ptr<LevelDBIterator>( |
| 417 IndexedDBClassFactory::Get()->CreateIteratorImpl(i.Pass())); | 420 IndexedDBClassFactory::Get()->CreateIteratorImpl(i.Pass())); |
| 418 } | 421 } |
| 419 | 422 |
| 420 const LevelDBComparator* LevelDBDatabase::Comparator() const { | 423 const LevelDBComparator* LevelDBDatabase::Comparator() const { |
| 421 return comparator_; | 424 return comparator_; |
| 422 } | 425 } |
| 423 | 426 |
| 424 void LevelDBDatabase::Compact(const base::StringPiece& start, | 427 void LevelDBDatabase::Compact(const base::StringPiece& start, |
| 425 const base::StringPiece& stop) { | 428 const base::StringPiece& stop) { |
| 429 TRACE_EVENT0("LevelDB", "LevelDBDatabase::Compact"); | |
|
cmumford
2015/08/03 17:31:33
Why TRACE_EVENT instead of IDB_TRACE?
dmurph
2015/08/05 15:30:32
Whoops :)
| |
| 426 const leveldb::Slice start_slice = MakeSlice(start); | 430 const leveldb::Slice start_slice = MakeSlice(start); |
| 427 const leveldb::Slice stop_slice = MakeSlice(stop); | 431 const leveldb::Slice stop_slice = MakeSlice(stop); |
| 428 // NULL batch means just wait for earlier writes to be done | 432 // NULL batch means just wait for earlier writes to be done |
| 429 db_->Write(leveldb::WriteOptions(), NULL); | 433 db_->Write(leveldb::WriteOptions(), NULL); |
| 430 db_->CompactRange(&start_slice, &stop_slice); | 434 db_->CompactRange(&start_slice, &stop_slice); |
| 431 } | 435 } |
| 432 | 436 |
| 433 void LevelDBDatabase::CompactAll() { db_->CompactRange(NULL, NULL); } | 437 void LevelDBDatabase::CompactAll() { db_->CompactRange(NULL, NULL); } |
| 434 | 438 |
| 435 } // namespace content | 439 } // namespace content |
| OLD | NEW |