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

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: Deleted redundant DEPS path Created 5 years, 8 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 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 // Avoid opening a database if it does not exist at the |path_|. 993 // Avoid opening a database if it does not exist at the |path_|.
993 if (use_in_memory_db || 994 if (use_in_memory_db ||
994 !base::PathExists(path_) || 995 !base::PathExists(path_) ||
995 base::IsDirectoryEmpty(path_)) { 996 base::IsDirectoryEmpty(path_)) {
996 return STATUS_ERROR_NOT_FOUND; 997 return STATUS_ERROR_NOT_FOUND;
997 } 998 }
998 } 999 }
999 1000
1000 leveldb::Options options; 1001 leveldb::Options options;
1001 options.create_if_missing = create_if_missing; 1002 options.create_if_missing = create_if_missing;
1003 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue;
1002 if (use_in_memory_db) { 1004 if (use_in_memory_db) {
1003 env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); 1005 env_.reset(leveldb::NewMemEnv(leveldb::Env::Default()));
1004 options.env = env_.get(); 1006 options.env = env_.get();
1005 } 1007 }
1006 1008
1007 leveldb::DB* db = NULL; 1009 leveldb::DB* db = NULL;
1008 Status status = LevelDBStatusToStatus( 1010 Status status = LevelDBStatusToStatus(
1009 leveldb::DB::Open(options, path_.AsUTF8Unsafe(), &db)); 1011 leveldb::DB::Open(options, path_.AsUTF8Unsafe(), &db));
1010 HandleOpenResult(FROM_HERE, status); 1012 HandleOpenResult(FROM_HERE, status);
1011 if (status != STATUS_OK) { 1013 if (status != STATUS_OK) {
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 1447
1446 void ServiceWorkerDatabase::HandleWriteResult( 1448 void ServiceWorkerDatabase::HandleWriteResult(
1447 const tracked_objects::Location& from_here, 1449 const tracked_objects::Location& from_here,
1448 Status status) { 1450 Status status) {
1449 if (status != STATUS_OK) 1451 if (status != STATUS_OK)
1450 Disable(from_here, status); 1452 Disable(from_here, status);
1451 ServiceWorkerMetrics::CountWriteDatabaseResult(status); 1453 ServiceWorkerMetrics::CountWriteDatabaseResult(status);
1452 } 1454 }
1453 1455
1454 } // namespace content 1456 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/notifications/notification_database.cc ('k') | extensions/browser/value_store/leveldb_value_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698