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 "storage/browser/fileapi/sandbox_directory_database.h" | 5 #include "storage/browser/fileapi/sandbox_directory_database.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <set> | 9 #include <set> |
10 #include <stack> | 10 #include <stack> |
11 | 11 |
12 #include "base/files/file_enumerator.h" | 12 #include "base/files/file_enumerator.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "base/pickle.h" | 16 #include "base/pickle.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
19 #include "storage/browser/fileapi/file_system_usage_cache.h" | 19 #include "storage/browser/fileapi/file_system_usage_cache.h" |
20 #include "storage/common/fileapi/file_system_util.h" | 20 #include "storage/common/fileapi/file_system_util.h" |
| 21 #include "third_party/leveldatabase/env_chromium.h" |
21 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 22 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
22 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" | 23 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 bool PickleFromFileInfo(const storage::SandboxDirectoryDatabase::FileInfo& info, | 27 bool PickleFromFileInfo(const storage::SandboxDirectoryDatabase::FileInfo& info, |
27 Pickle* pickle) { | 28 Pickle* pickle) { |
28 DCHECK(pickle); | 29 DCHECK(pickle); |
29 std::string data_path; | 30 std::string data_path; |
30 // Round off here to match the behavior of the filesystem on real files. | 31 // Round off here to match the behavior of the filesystem on real files. |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 bool SandboxDirectoryDatabase::Init(RecoveryOption recovery_option) { | 721 bool SandboxDirectoryDatabase::Init(RecoveryOption recovery_option) { |
721 if (db_) | 722 if (db_) |
722 return true; | 723 return true; |
723 | 724 |
724 std::string path = | 725 std::string path = |
725 FilePathToString(filesystem_data_directory_.Append( | 726 FilePathToString(filesystem_data_directory_.Append( |
726 kDirectoryDatabaseName)); | 727 kDirectoryDatabaseName)); |
727 leveldb::Options options; | 728 leveldb::Options options; |
728 options.max_open_files = 0; // Use minimum. | 729 options.max_open_files = 0; // Use minimum. |
729 options.create_if_missing = true; | 730 options.create_if_missing = true; |
| 731 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue; |
730 if (env_override_) | 732 if (env_override_) |
731 options.env = env_override_; | 733 options.env = env_override_; |
732 leveldb::DB* db; | 734 leveldb::DB* db; |
733 leveldb::Status status = leveldb::DB::Open(options, path, &db); | 735 leveldb::Status status = leveldb::DB::Open(options, path, &db); |
734 ReportInitStatus(status); | 736 ReportInitStatus(status); |
735 if (status.ok()) { | 737 if (status.ok()) { |
736 db_.reset(db); | 738 db_.reset(db); |
737 return true; | 739 return true; |
738 } | 740 } |
739 HandleError(FROM_HERE, status); | 741 HandleError(FROM_HERE, status); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 | 933 |
932 void SandboxDirectoryDatabase::HandleError( | 934 void SandboxDirectoryDatabase::HandleError( |
933 const tracked_objects::Location& from_here, | 935 const tracked_objects::Location& from_here, |
934 const leveldb::Status& status) { | 936 const leveldb::Status& status) { |
935 LOG(ERROR) << "SandboxDirectoryDatabase failed at: " | 937 LOG(ERROR) << "SandboxDirectoryDatabase failed at: " |
936 << from_here.ToString() << " with error: " << status.ToString(); | 938 << from_here.ToString() << " with error: " << status.ToString(); |
937 db_.reset(); | 939 db_.reset(); |
938 } | 940 } |
939 | 941 |
940 } // namespace storage | 942 } // namespace storage |
OLD | NEW |