| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 options.env = leveldb::IDBEnv(); | 121 options.env = leveldb::IDBEnv(); |
| 122 // ChromiumEnv assumes UTF8, converts back to FilePath before using. | 122 // ChromiumEnv assumes UTF8, converts back to FilePath before using. |
| 123 return leveldb::DestroyDB(file_name.AsUTF8Unsafe(), options); | 123 return leveldb::DestroyDB(file_name.AsUTF8Unsafe(), options); |
| 124 } | 124 } |
| 125 | 125 |
| 126 namespace { | 126 namespace { |
| 127 class LockImpl : public LevelDBLock { | 127 class LockImpl : public LevelDBLock { |
| 128 public: | 128 public: |
| 129 explicit LockImpl(leveldb::Env* env, leveldb::FileLock* lock) | 129 explicit LockImpl(leveldb::Env* env, leveldb::FileLock* lock) |
| 130 : env_(env), lock_(lock) {} | 130 : env_(env), lock_(lock) {} |
| 131 virtual ~LockImpl() { env_->UnlockFile(lock_); } | 131 ~LockImpl() override { env_->UnlockFile(lock_); } |
| 132 |
| 132 private: | 133 private: |
| 133 leveldb::Env* env_; | 134 leveldb::Env* env_; |
| 134 leveldb::FileLock* lock_; | 135 leveldb::FileLock* lock_; |
| 135 | 136 |
| 136 DISALLOW_COPY_AND_ASSIGN(LockImpl); | 137 DISALLOW_COPY_AND_ASSIGN(LockImpl); |
| 137 }; | 138 }; |
| 138 } // namespace | 139 } // namespace |
| 139 | 140 |
| 140 scoped_ptr<LevelDBLock> LevelDBDatabase::LockForTesting( | 141 scoped_ptr<LevelDBLock> LevelDBDatabase::LockForTesting( |
| 141 const base::FilePath& file_name) { | 142 const base::FilePath& file_name) { |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 const leveldb::Slice start_slice = MakeSlice(start); | 428 const leveldb::Slice start_slice = MakeSlice(start); |
| 428 const leveldb::Slice stop_slice = MakeSlice(stop); | 429 const leveldb::Slice stop_slice = MakeSlice(stop); |
| 429 // NULL batch means just wait for earlier writes to be done | 430 // NULL batch means just wait for earlier writes to be done |
| 430 db_->Write(leveldb::WriteOptions(), NULL); | 431 db_->Write(leveldb::WriteOptions(), NULL); |
| 431 db_->CompactRange(&start_slice, &stop_slice); | 432 db_->CompactRange(&start_slice, &stop_slice); |
| 432 } | 433 } |
| 433 | 434 |
| 434 void LevelDBDatabase::CompactAll() { db_->CompactRange(NULL, NULL); } | 435 void LevelDBDatabase::CompactAll() { db_->CompactRange(NULL, NULL); } |
| 435 | 436 |
| 436 } // namespace content | 437 } // namespace content |
| OLD | NEW |