Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: storage/browser/fileapi/sandbox_origin_database.cc

Issue 1025433003: leveldb: Reuse manifest (AKA logs) during open. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Deleted redundant DEPS path Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_origin_database.h" 5 #include "storage/browser/fileapi/sandbox_origin_database.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/format_macros.h" 12 #include "base/format_macros.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "storage/common/fileapi/file_system_util.h" 19 #include "storage/common/fileapi/file_system_util.h"
20 #include "third_party/leveldatabase/env_chromium.h"
20 #include "third_party/leveldatabase/src/include/leveldb/db.h" 21 #include "third_party/leveldatabase/src/include/leveldb/db.h"
21 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" 22 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h"
22 23
23 namespace { 24 namespace {
24 25
25 const base::FilePath::CharType kOriginDatabaseName[] = 26 const base::FilePath::CharType kOriginDatabaseName[] =
26 FILE_PATH_LITERAL("Origins"); 27 FILE_PATH_LITERAL("Origins");
27 const char kOriginKeyPrefix[] = "ORIGIN:"; 28 const char kOriginKeyPrefix[] = "ORIGIN:";
28 const char kLastPathKey[] = "LAST_PATH"; 29 const char kLastPathKey[] = "LAST_PATH";
29 const int64 kMinimumReportIntervalHours = 1; 30 const int64 kMinimumReportIntervalHours = 1;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return true; 74 return true;
74 75
75 base::FilePath db_path = GetDatabasePath(); 76 base::FilePath db_path = GetDatabasePath();
76 if (init_option == FAIL_IF_NONEXISTENT && !base::PathExists(db_path)) 77 if (init_option == FAIL_IF_NONEXISTENT && !base::PathExists(db_path))
77 return false; 78 return false;
78 79
79 std::string path = FilePathToString(db_path); 80 std::string path = FilePathToString(db_path);
80 leveldb::Options options; 81 leveldb::Options options;
81 options.max_open_files = 0; // Use minimum. 82 options.max_open_files = 0; // Use minimum.
82 options.create_if_missing = true; 83 options.create_if_missing = true;
84 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue;
83 if (env_override_) 85 if (env_override_)
84 options.env = env_override_; 86 options.env = env_override_;
85 leveldb::DB* db; 87 leveldb::DB* db;
86 leveldb::Status status = leveldb::DB::Open(options, path, &db); 88 leveldb::Status status = leveldb::DB::Open(options, path, &db);
87 ReportInitStatus(status); 89 ReportInitStatus(status);
88 if (status.ok()) { 90 if (status.ok()) {
89 db_.reset(db); 91 db_.reset(db);
90 return true; 92 return true;
91 } 93 }
92 HandleError(FROM_HERE, status); 94 HandleError(FROM_HERE, status);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1")); 340 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1"));
339 if (!status.ok()) { 341 if (!status.ok()) {
340 HandleError(FROM_HERE, status); 342 HandleError(FROM_HERE, status);
341 return false; 343 return false;
342 } 344 }
343 *number = -1; 345 *number = -1;
344 return true; 346 return true;
345 } 347 }
346 348
347 } // namespace storage 349 } // namespace storage
OLDNEW
« no previous file with comments | « storage/browser/fileapi/sandbox_directory_database.cc ('k') | sync/internal_api/attachments/on_disk_attachment_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698