| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/dom_storage/session_storage_database.h" | 5 #include "content/browser/dom_storage/session_storage_database.h" |
| 6 | 6 |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "third_party/leveldatabase/env_chromium.h" |
| 13 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 14 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
| 14 #include "third_party/leveldatabase/src/include/leveldb/iterator.h" | 15 #include "third_party/leveldatabase/src/include/leveldb/iterator.h" |
| 15 #include "third_party/leveldatabase/src/include/leveldb/options.h" | 16 #include "third_party/leveldatabase/src/include/leveldb/options.h" |
| 16 #include "third_party/leveldatabase/src/include/leveldb/status.h" | 17 #include "third_party/leveldatabase/src/include/leveldb/status.h" |
| 17 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" | 18 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" |
| 18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 19 | 20 |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 return true; | 375 return true; |
| 375 } | 376 } |
| 376 | 377 |
| 377 leveldb::Status SessionStorageDatabase::TryToOpen(leveldb::DB** db) { | 378 leveldb::Status SessionStorageDatabase::TryToOpen(leveldb::DB** db) { |
| 378 leveldb::Options options; | 379 leveldb::Options options; |
| 379 // The directory exists but a valid leveldb database might not exist inside it | 380 // The directory exists but a valid leveldb database might not exist inside it |
| 380 // (e.g., a subset of the needed files might be missing). Handle this | 381 // (e.g., a subset of the needed files might be missing). Handle this |
| 381 // situation gracefully by creating the database now. | 382 // situation gracefully by creating the database now. |
| 382 options.max_open_files = 0; // Use minimum. | 383 options.max_open_files = 0; // Use minimum. |
| 383 options.create_if_missing = true; | 384 options.create_if_missing = true; |
| 385 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue; |
| 384 #if defined(OS_WIN) | 386 #if defined(OS_WIN) |
| 385 return leveldb::DB::Open(options, base::WideToUTF8(file_path_.value()), db); | 387 return leveldb::DB::Open(options, base::WideToUTF8(file_path_.value()), db); |
| 386 #elif defined(OS_POSIX) | 388 #elif defined(OS_POSIX) |
| 387 return leveldb::DB::Open(options, file_path_.value(), db); | 389 return leveldb::DB::Open(options, file_path_.value(), db); |
| 388 #endif | 390 #endif |
| 389 } | 391 } |
| 390 | 392 |
| 391 bool SessionStorageDatabase::IsOpen() const { | 393 bool SessionStorageDatabase::IsOpen() const { |
| 392 return db_.get() != NULL; | 394 return db_.get() != NULL; |
| 393 } | 395 } |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 std::string SessionStorageDatabase::MapKey(const std::string& map_id, | 727 std::string SessionStorageDatabase::MapKey(const std::string& map_id, |
| 726 const std::string& key) { | 728 const std::string& key) { |
| 727 return base::StringPrintf("map-%s-%s", map_id.c_str(), key.c_str()); | 729 return base::StringPrintf("map-%s-%s", map_id.c_str(), key.c_str()); |
| 728 } | 730 } |
| 729 | 731 |
| 730 const char* SessionStorageDatabase::NextMapIdKey() { | 732 const char* SessionStorageDatabase::NextMapIdKey() { |
| 731 return "next-map-id"; | 733 return "next-map-id"; |
| 732 } | 734 } |
| 733 | 735 |
| 734 } // namespace content | 736 } // namespace content |
| OLD | NEW |