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" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 void LevelDBDatabase::ComparatorAdapter::FindShortSuccessor( | 77 void LevelDBDatabase::ComparatorAdapter::FindShortSuccessor( |
| 78 std::string* key) const {} | 78 std::string* key) const {} |
| 79 | 79 |
| 80 LevelDBSnapshot::LevelDBSnapshot(LevelDBDatabase* db) | 80 LevelDBSnapshot::LevelDBSnapshot(LevelDBDatabase* db) |
| 81 : db_(db->db_.get()), snapshot_(db_->GetSnapshot()) {} | 81 : db_(db->db_.get()), snapshot_(db_->GetSnapshot()) {} |
| 82 | 82 |
| 83 LevelDBSnapshot::~LevelDBSnapshot() { db_->ReleaseSnapshot(snapshot_); } | 83 LevelDBSnapshot::~LevelDBSnapshot() { db_->ReleaseSnapshot(snapshot_); } |
| 84 | 84 |
| 85 LevelDBDatabase::LevelDBDatabase() {} | 85 LevelDBDatabase::LevelDBDatabase() {} |
| 86 | 86 |
| 87 LevelDBDatabase::~LevelDBDatabase() { | 87 LevelDBDatabase::~LevelDBDatabase() { |
|
dgrogan
2015/06/18 22:15:58
Mainly for my edification:
Looks like this gets c
cmumford
2015/06/18 22:20:14
Yes, timer is still in IndexedDBFactoryImpl::Relea
| |
| 88 // db_'s destructor uses comparator_adapter_; order of deletion is important. | 88 // db_'s destructor uses comparator_adapter_; order of deletion is important. |
| 89 db_.reset(); | 89 CloseDatabase(); |
| 90 comparator_adapter_.reset(); | 90 comparator_adapter_.reset(); |
| 91 env_.reset(); | 91 env_.reset(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void LevelDBDatabase::CloseDatabase() { | |
| 95 if (db_) { | |
| 96 base::TimeTicks begin_time = base::TimeTicks::Now(); | |
| 97 db_.reset(); | |
| 98 UMA_HISTOGRAM_MEDIUM_TIMES("WebCore.IndexedDB.LevelDB.CloseTime", | |
| 99 base::TimeTicks::Now() - begin_time); | |
| 100 } | |
| 101 } | |
| 102 | |
| 94 static leveldb::Status OpenDB( | 103 static leveldb::Status OpenDB( |
| 95 leveldb::Comparator* comparator, | 104 leveldb::Comparator* comparator, |
| 96 leveldb::Env* env, | 105 leveldb::Env* env, |
| 97 const base::FilePath& path, | 106 const base::FilePath& path, |
| 98 leveldb::DB** db, | 107 leveldb::DB** db, |
| 99 scoped_ptr<const leveldb::FilterPolicy>* filter_policy) { | 108 scoped_ptr<const leveldb::FilterPolicy>* filter_policy) { |
| 100 filter_policy->reset(leveldb::NewBloomFilterPolicy(10)); | 109 filter_policy->reset(leveldb::NewBloomFilterPolicy(10)); |
| 101 leveldb::Options options; | 110 leveldb::Options options; |
| 102 options.comparator = comparator; | 111 options.comparator = comparator; |
| 103 options.create_if_missing = true; | 112 options.create_if_missing = true; |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 417 const leveldb::Slice start_slice = MakeSlice(start); | 426 const leveldb::Slice start_slice = MakeSlice(start); |
| 418 const leveldb::Slice stop_slice = MakeSlice(stop); | 427 const leveldb::Slice stop_slice = MakeSlice(stop); |
| 419 // NULL batch means just wait for earlier writes to be done | 428 // NULL batch means just wait for earlier writes to be done |
| 420 db_->Write(leveldb::WriteOptions(), NULL); | 429 db_->Write(leveldb::WriteOptions(), NULL); |
| 421 db_->CompactRange(&start_slice, &stop_slice); | 430 db_->CompactRange(&start_slice, &stop_slice); |
| 422 } | 431 } |
| 423 | 432 |
| 424 void LevelDBDatabase::CompactAll() { db_->CompactRange(NULL, NULL); } | 433 void LevelDBDatabase::CompactAll() { db_->CompactRange(NULL, NULL); } |
| 425 | 434 |
| 426 } // namespace content | 435 } // namespace content |
| OLD | NEW |