OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/value_store/leveldb_value_store.h" | 5 #include "chrome/browser/value_store/leveldb_value_store.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 | 332 |
333 std::string LeveldbValueStore::EnsureDbIsOpen() { | 333 std::string LeveldbValueStore::EnsureDbIsOpen() { |
334 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 334 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
335 | 335 |
336 if (db_.get()) | 336 if (db_.get()) |
337 return ""; | 337 return ""; |
338 | 338 |
339 #if defined(OS_POSIX) | 339 #if defined(OS_POSIX) |
340 std::string os_path(db_path_.value()); | 340 std::string os_path(db_path_.value()); |
341 #elif defined(OS_WIN) | 341 #elif defined(OS_WIN) |
342 std::string os_path = base::SysWideToUTF8(db_path_.value()); | 342 std::string os_path = base::Sysbase::WideToUTF8(db_path_.value()); |
343 #endif | 343 #endif |
344 | 344 |
345 leveldb::Options options; | 345 leveldb::Options options; |
346 options.create_if_missing = true; | 346 options.create_if_missing = true; |
347 leveldb::DB* db; | 347 leveldb::DB* db; |
348 leveldb::Status status = leveldb::DB::Open(options, os_path, &db); | 348 leveldb::Status status = leveldb::DB::Open(options, os_path, &db); |
349 if (!status.ok()) { | 349 if (!status.ok()) { |
350 // |os_path| may contain sensitive data, and these strings are passed | 350 // |os_path| may contain sensitive data, and these strings are passed |
351 // through to the extension, so strip that out. | 351 // through to the extension, so strip that out. |
352 std::string status_string = status.ToString(); | 352 std::string status_string = status.ToString(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 scoped_ptr<leveldb::Iterator> it(db_->NewIterator(leveldb::ReadOptions())); | 427 scoped_ptr<leveldb::Iterator> it(db_->NewIterator(leveldb::ReadOptions())); |
428 | 428 |
429 it->SeekToFirst(); | 429 it->SeekToFirst(); |
430 bool is_empty = !it->Valid(); | 430 bool is_empty = !it->Valid(); |
431 if (!it->status().ok()) { | 431 if (!it->status().ok()) { |
432 LOG(ERROR) << "Checking DB emptiness failed: " << it->status().ToString(); | 432 LOG(ERROR) << "Checking DB emptiness failed: " << it->status().ToString(); |
433 return false; | 433 return false; |
434 } | 434 } |
435 return is_empty; | 435 return is_empty; |
436 } | 436 } |
OLD | NEW |