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

Side by Side Diff: content/browser/service_worker/service_worker_database.cc

Issue 1025433003: leveldb: Reuse manifest (AKA logs) during open. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Using leveldb_env::kDefaultLogReuseOptionValue for IDB 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/service_worker/service_worker_database.h" 5 #include "content/browser/service_worker/service_worker_database.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_split.h" 13 #include "base/strings/string_split.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "content/browser/service_worker/service_worker_database.pb.h" 16 #include "content/browser/service_worker/service_worker_database.pb.h"
17 #include "content/browser/service_worker/service_worker_metrics.h" 17 #include "content/browser/service_worker/service_worker_metrics.h"
18 #include "content/common/service_worker/service_worker_types.h" 18 #include "content/common/service_worker/service_worker_types.h"
19 #include "third_party/leveldatabase/env_chromium.h"
19 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" 20 #include "third_party/leveldatabase/src/helpers/memenv/memenv.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/env.h" 22 #include "third_party/leveldatabase/src/include/leveldb/env.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 // LevelDB database schema 25 // LevelDB database schema
25 // ======================= 26 // =======================
26 // 27 //
27 // NOTE 28 // NOTE
28 // - int64 value is serialized as a string by base::Int64ToString(). 29 // - int64 value is serialized as a string by base::Int64ToString().
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 // Avoid opening a database if it does not exist at the |path_|. 991 // Avoid opening a database if it does not exist at the |path_|.
991 if (use_in_memory_db || 992 if (use_in_memory_db ||
992 !base::PathExists(path_) || 993 !base::PathExists(path_) ||
993 base::IsDirectoryEmpty(path_)) { 994 base::IsDirectoryEmpty(path_)) {
994 return STATUS_ERROR_NOT_FOUND; 995 return STATUS_ERROR_NOT_FOUND;
995 } 996 }
996 } 997 }
997 998
998 leveldb::Options options; 999 leveldb::Options options;
999 options.create_if_missing = create_if_missing; 1000 options.create_if_missing = create_if_missing;
1001 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue;
1000 if (use_in_memory_db) { 1002 if (use_in_memory_db) {
1001 env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); 1003 env_.reset(leveldb::NewMemEnv(leveldb::Env::Default()));
1002 options.env = env_.get(); 1004 options.env = env_.get();
1003 } 1005 }
1004 1006
1005 leveldb::DB* db = NULL; 1007 leveldb::DB* db = NULL;
1006 Status status = LevelDBStatusToStatus( 1008 Status status = LevelDBStatusToStatus(
1007 leveldb::DB::Open(options, path_.AsUTF8Unsafe(), &db)); 1009 leveldb::DB::Open(options, path_.AsUTF8Unsafe(), &db));
1008 HandleOpenResult(FROM_HERE, status); 1010 HandleOpenResult(FROM_HERE, status);
1009 if (status != STATUS_OK) { 1011 if (status != STATUS_OK) {
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 1445
1444 void ServiceWorkerDatabase::HandleWriteResult( 1446 void ServiceWorkerDatabase::HandleWriteResult(
1445 const tracked_objects::Location& from_here, 1447 const tracked_objects::Location& from_here,
1446 Status status) { 1448 Status status) {
1447 if (status != STATUS_OK) 1449 if (status != STATUS_OK)
1448 Disable(from_here, status); 1450 Disable(from_here, status);
1449 ServiceWorkerMetrics::CountWriteDatabaseResult(status); 1451 ServiceWorkerMetrics::CountWriteDatabaseResult(status);
1450 } 1452 }
1451 1453
1452 } // namespace content 1454 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698