OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_settings_leveldb_storage.h" | 5 #include "chrome/browser/extensions/extension_settings_leveldb_storage.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/sys_string_conversions.h" | 13 #include "base/sys_string_conversions.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 #include "third_party/leveldatabase/src/include/leveldb/iterator.h" | 15 #include "third_party/leveldatabase/src/include/leveldb/iterator.h" |
16 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" | 16 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" |
17 | 17 |
| 18 using content::BrowserThread; |
| 19 |
18 namespace { | 20 namespace { |
19 | 21 |
20 // Generic error message sent to extensions on failure. | 22 // Generic error message sent to extensions on failure. |
21 const char* kGenericOnFailureMessage = "Extension settings failed"; | 23 const char* kGenericOnFailureMessage = "Extension settings failed"; |
22 | 24 |
23 // Scoped leveldb snapshot which releases the snapshot on destruction. | 25 // Scoped leveldb snapshot which releases the snapshot on destruction. |
24 class ScopedSnapshot { | 26 class ScopedSnapshot { |
25 public: | 27 public: |
26 explicit ScopedSnapshot(leveldb::DB* db) | 28 explicit ScopedSnapshot(leveldb::DB* db) |
27 : db_(db), snapshot_(db->GetSnapshot()) {} | 29 : db_(db), snapshot_(db->GetSnapshot()) {} |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 scoped_ptr<leveldb::Iterator> it(db_->NewIterator(leveldb::ReadOptions())); | 318 scoped_ptr<leveldb::Iterator> it(db_->NewIterator(leveldb::ReadOptions())); |
317 | 319 |
318 it->SeekToFirst(); | 320 it->SeekToFirst(); |
319 bool is_empty = !it->Valid(); | 321 bool is_empty = !it->Valid(); |
320 if (!it->status().ok()) { | 322 if (!it->status().ok()) { |
321 LOG(ERROR) << "Checking DB emptiness failed: " << it->status().ToString(); | 323 LOG(ERROR) << "Checking DB emptiness failed: " << it->status().ToString(); |
322 return false; | 324 return false; |
323 } | 325 } |
324 return is_empty; | 326 return is_empty; |
325 } | 327 } |
OLD | NEW |