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

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

Issue 1310513004: [tracing] Add memory statistics from level db clients to tracing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@skia_res
Patch Set: Fix mac suballocation and make names unique. Created 5 years, 1 month 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
« no previous file with comments | « no previous file | extensions/browser/value_store/leveldb_value_store.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef EXTENSIONS_BROWSER_VALUE_STORE_LEVELDB_VALUE_STORE_H_ 5 #ifndef EXTENSIONS_BROWSER_VALUE_STORE_LEVELDB_VALUE_STORE_H_
6 #define EXTENSIONS_BROWSER_VALUE_STORE_LEVELDB_VALUE_STORE_H_ 6 #define EXTENSIONS_BROWSER_VALUE_STORE_LEVELDB_VALUE_STORE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/trace_event/memory_dump_provider.h"
14 #include "extensions/browser/value_store/value_store.h" 15 #include "extensions/browser/value_store/value_store.h"
15 #include "third_party/leveldatabase/src/include/leveldb/db.h" 16 #include "third_party/leveldatabase/src/include/leveldb/db.h"
16 17
17 namespace base { 18 namespace base {
18 class HistogramBase; 19 class HistogramBase;
19 } // namespace base 20 } // namespace base
20 21
21 // Value store area, backed by a leveldb database. 22 // Value store area, backed by a leveldb database.
22 // All methods must be run on the FILE thread. 23 // All methods must be run on the FILE thread.
23 class LeveldbValueStore : public ValueStore { 24 class LeveldbValueStore : public ValueStore,
25 public base::trace_event::MemoryDumpProvider {
24 public: 26 public:
25 // Creates a database bound to |path|. The underlying database won't be 27 // Creates a database bound to |path|. The underlying database won't be
26 // opened (i.e. may not be created) until one of the get/set/etc methods are 28 // opened (i.e. may not be created) until one of the get/set/etc methods are
27 // called - this is because opening the database may fail, and extensions 29 // called - this is because opening the database may fail, and extensions
28 // need to be notified of that, but we don't want to permanently give up. 30 // need to be notified of that, but we don't want to permanently give up.
29 // 31 //
30 // Must be created on the FILE thread. 32 // Must be created on the FILE thread.
31 LeveldbValueStore(const std::string& uma_client_name, 33 LeveldbValueStore(const std::string& uma_client_name,
32 const base::FilePath& path); 34 const base::FilePath& path);
33 35
(...skipping 15 matching lines...) Expand all
49 WriteResult Remove(const std::string& key) override; 51 WriteResult Remove(const std::string& key) override;
50 WriteResult Remove(const std::vector<std::string>& keys) override; 52 WriteResult Remove(const std::vector<std::string>& keys) override;
51 WriteResult Clear() override; 53 WriteResult Clear() override;
52 bool Restore() override; 54 bool Restore() override;
53 bool RestoreKey(const std::string& key) override; 55 bool RestoreKey(const std::string& key) override;
54 56
55 // Write directly to the backing levelDB. Only used for testing to cause 57 // Write directly to the backing levelDB. Only used for testing to cause
56 // corruption in the database. 58 // corruption in the database.
57 bool WriteToDbForTest(leveldb::WriteBatch* batch); 59 bool WriteToDbForTest(leveldb::WriteBatch* batch);
58 60
61 // base::trace_event::MemoryDumpProvider implementation.
62 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
63 base::trace_event::ProcessMemoryDump* pmd) override;
64
59 private: 65 private:
60 // Tries to open the database if it hasn't been opened already. 66 // Tries to open the database if it hasn't been opened already.
61 scoped_ptr<ValueStore::Error> EnsureDbIsOpen(); 67 scoped_ptr<ValueStore::Error> EnsureDbIsOpen();
62 68
63 // Reads a setting from the database. 69 // Reads a setting from the database.
64 scoped_ptr<ValueStore::Error> ReadFromDb( 70 scoped_ptr<ValueStore::Error> ReadFromDb(
65 leveldb::ReadOptions options, 71 leveldb::ReadOptions options,
66 const std::string& key, 72 const std::string& key,
67 // Will be reset() with the result, if any. 73 // Will be reset() with the result, if any.
68 scoped_ptr<base::Value>* setting); 74 scoped_ptr<base::Value>* setting);
(...skipping 26 matching lines...) Expand all
95 const base::FilePath db_path_; 101 const base::FilePath db_path_;
96 102
97 // leveldb backend. 103 // leveldb backend.
98 scoped_ptr<leveldb::DB> db_; 104 scoped_ptr<leveldb::DB> db_;
99 base::HistogramBase* open_histogram_; 105 base::HistogramBase* open_histogram_;
100 106
101 DISALLOW_COPY_AND_ASSIGN(LeveldbValueStore); 107 DISALLOW_COPY_AND_ASSIGN(LeveldbValueStore);
102 }; 108 };
103 109
104 #endif // EXTENSIONS_BROWSER_VALUE_STORE_LEVELDB_VALUE_STORE_H_ 110 #endif // EXTENSIONS_BROWSER_VALUE_STORE_LEVELDB_VALUE_STORE_H_
OLDNEW
« no previous file with comments | « no previous file | extensions/browser/value_store/leveldb_value_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698