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

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: Use OpenDB in unittests; add allocation edges 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 DCHECK(res); 251 DCHECK(res);
252 res = base::StringToUint64(value, &size); 252 res = base::StringToUint64(value, &size);
253 DCHECK(res); 253 DCHECK(res);
254 254
255 auto* dump = pmd->CreateAllocatorDump(base::StringPrintf( 255 auto* dump = pmd->CreateAllocatorDump(base::StringPrintf(
256 "leveldb/value_store/%s/0x%" PRIXPTR, open_histogram_name().c_str(), 256 "leveldb/value_store/%s/0x%" PRIXPTR, open_histogram_name().c_str(),
257 reinterpret_cast<uintptr_t>(this))); 257 reinterpret_cast<uintptr_t>(this)));
258 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 258 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
259 base::trace_event::MemoryAllocatorDump::kUnitsBytes, size); 259 base::trace_event::MemoryAllocatorDump::kUnitsBytes, size);
260 260
261 // Memory is allocated from system allocator (malloc). 261 // All leveldb databases are already dumped by leveldb_env::DBTracker. Add
262 const char* system_allocator_name = 262 // an edge to avoid double counting.
263 base::trace_event::MemoryDumpManager::GetInstance() 263 pmd->AddSuballocation(dump->guid(),
264 ->system_allocator_pool_name(); 264 leveldb_env::DBTracker::GetMemoryDumpName(db()));
265 if (system_allocator_name)
266 pmd->AddSuballocation(dump->guid(), system_allocator_name);
267 265
268 return true; 266 return true;
269 } 267 }
270 268
271 ValueStore::Status LeveldbValueStore::AddToBatch( 269 ValueStore::Status LeveldbValueStore::AddToBatch(
272 ValueStore::WriteOptions options, 270 ValueStore::WriteOptions options,
273 const std::string& key, 271 const std::string& key,
274 const base::Value& value, 272 const base::Value& value,
275 leveldb::WriteBatch* batch, 273 leveldb::WriteBatch* batch,
276 ValueStoreChangeList* changes) { 274 ValueStoreChangeList* changes) {
(...skipping 18 matching lines...) Expand all
295 return Status(OTHER_ERROR, kCannotSerialize); 293 return Status(OTHER_ERROR, kCannotSerialize);
296 batch->Put(key, value_as_json); 294 batch->Put(key, value_as_json);
297 } 295 }
298 296
299 return Status(); 297 return Status();
300 } 298 }
301 299
302 ValueStore::Status LeveldbValueStore::WriteToDb(leveldb::WriteBatch* batch) { 300 ValueStore::Status LeveldbValueStore::WriteToDb(leveldb::WriteBatch* batch) {
303 return ToValueStoreError(db()->Write(write_options(), batch)); 301 return ToValueStoreError(db()->Write(write_options(), batch));
304 } 302 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698