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

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

Issue 2855953002: leveldb: Add DBTracker for exposing databases to Chrome's memory-infra. (Closed)
Patch Set: Created 3 years, 7 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 <utility> 7 #include <utility>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue; 1117 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue;
1118 if (IsDatabaseInMemory()) { 1118 if (IsDatabaseInMemory()) {
1119 env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); 1119 env_.reset(leveldb::NewMemEnv(leveldb::Env::Default()));
1120 options.env = env_.get(); 1120 options.env = env_.get();
1121 } else { 1121 } else {
1122 options.env = g_service_worker_env.Pointer(); 1122 options.env = g_service_worker_env.Pointer();
1123 } 1123 }
1124 1124
1125 leveldb::DB* db = NULL; 1125 leveldb::DB* db = NULL;
1126 Status status = LevelDBStatusToStatus( 1126 Status status = LevelDBStatusToStatus(
1127 leveldb::DB::Open(options, path_.AsUTF8Unsafe(), &db)); 1127 leveldb_env::DBRegistry::Open(options, path_.AsUTF8Unsafe(), &db));
1128 HandleOpenResult(FROM_HERE, status); 1128 HandleOpenResult(FROM_HERE, status);
1129 if (status != STATUS_OK) { 1129 if (status != STATUS_OK) {
1130 DCHECK(!db); 1130 DCHECK(!db);
1131 // TODO(nhiroki): Should we retry to open the database? 1131 // TODO(nhiroki): Should we retry to open the database?
1132 return status; 1132 return status;
1133 } 1133 }
1134 db_.reset(db); 1134 db_.reset(db);
1135 1135
1136 int64_t db_version; 1136 int64_t db_version;
1137 status = ReadDatabaseVersion(&db_version); 1137 status = ReadDatabaseVersion(&db_version);
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 if (status != STATUS_OK) 1720 if (status != STATUS_OK)
1721 Disable(from_here, status); 1721 Disable(from_here, status);
1722 ServiceWorkerMetrics::CountWriteDatabaseResult(status); 1722 ServiceWorkerMetrics::CountWriteDatabaseResult(status);
1723 } 1723 }
1724 1724
1725 bool ServiceWorkerDatabase::IsDatabaseInMemory() const { 1725 bool ServiceWorkerDatabase::IsDatabaseInMemory() const {
1726 return path_.empty(); 1726 return path_.empty();
1727 } 1727 }
1728 1728
1729 } // namespace content 1729 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698