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

Side by Side Diff: extensions/browser/value_store/leveldb_value_store.cc

Issue 2953473002: Use leveldb_env::OpenDB() to open leveldb databases. (Closed)
Patch Set: Rebase; add comments to CHECK() Created 3 years, 5 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 "extensions/browser/value_store/leveldb_value_store.h" 5 #include "extensions/browser/value_store/leveldb_value_store.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 DCHECK(res); 252 DCHECK(res);
253 res = base::StringToUint64(value, &size); 253 res = base::StringToUint64(value, &size);
254 DCHECK(res); 254 DCHECK(res);
255 255
256 auto* dump = pmd->CreateAllocatorDump(base::StringPrintf( 256 auto* dump = pmd->CreateAllocatorDump(base::StringPrintf(
257 "leveldb/value_store/%s/0x%" PRIXPTR, open_histogram_name().c_str(), 257 "leveldb/value_store/%s/0x%" PRIXPTR, open_histogram_name().c_str(),
258 reinterpret_cast<uintptr_t>(this))); 258 reinterpret_cast<uintptr_t>(this)));
259 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 259 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
260 base::trace_event::MemoryAllocatorDump::kUnitsBytes, size); 260 base::trace_event::MemoryAllocatorDump::kUnitsBytes, size);
261 261
262 // Memory is allocated from system allocator (malloc). 262 // All leveldb databases are already dumped by leveldb_env::DBTracker. Add
263 const char* system_allocator_name = 263 // an edge to avoid double counting.
264 base::trace_event::MemoryDumpManager::GetInstance() 264 pmd->AddSuballocation(dump->guid(),
265 ->system_allocator_pool_name(); 265 leveldb_env::DBTracker::GetMemoryDumpName(db()));
266 if (system_allocator_name)
267 pmd->AddSuballocation(dump->guid(), system_allocator_name);
268 266
269 return true; 267 return true;
270 } 268 }
271 269
272 ValueStore::Status LeveldbValueStore::AddToBatch( 270 ValueStore::Status LeveldbValueStore::AddToBatch(
273 ValueStore::WriteOptions options, 271 ValueStore::WriteOptions options,
274 const std::string& key, 272 const std::string& key,
275 const base::Value& value, 273 const base::Value& value,
276 leveldb::WriteBatch* batch, 274 leveldb::WriteBatch* batch,
277 ValueStoreChangeList* changes) { 275 ValueStoreChangeList* changes) {
(...skipping 18 matching lines...) Expand all
296 return Status(OTHER_ERROR, kCannotSerialize); 294 return Status(OTHER_ERROR, kCannotSerialize);
297 batch->Put(key, value_as_json); 295 batch->Put(key, value_as_json);
298 } 296 }
299 297
300 return Status(); 298 return Status();
301 } 299 }
302 300
303 ValueStore::Status LeveldbValueStore::WriteToDb(leveldb::WriteBatch* batch) { 301 ValueStore::Status LeveldbValueStore::WriteToDb(leveldb::WriteBatch* batch) {
304 return ToValueStoreError(db()->Write(write_options(), batch)); 302 return ToValueStoreError(db()->Write(write_options(), batch));
305 } 303 }
OLDNEW
« no previous file with comments | « extensions/browser/value_store/lazy_leveldb.cc ('k') | google_apis/gcm/engine/gcm_store_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698