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

Side by Side Diff: content/browser/indexed_db/leveldb/leveldb_database.h

Issue 1420193003: [tracing] Add IndexDB database memory usages to tracing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@leveldb
Patch Set: build fix. Created 4 years, 9 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_DATABASE_H_ 5 #ifndef CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_DATABASE_H_
6 #define CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_DATABASE_H_ 6 #define CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_DATABASE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "base/trace_event/memory_dump_provider.h"
15 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
16 #include "third_party/leveldatabase/src/include/leveldb/comparator.h" 17 #include "third_party/leveldatabase/src/include/leveldb/comparator.h"
17 #include "third_party/leveldatabase/src/include/leveldb/status.h" 18 #include "third_party/leveldatabase/src/include/leveldb/status.h"
18 19
19 namespace leveldb { 20 namespace leveldb {
20 class Comparator; 21 class Comparator;
21 class DB; 22 class DB;
22 class FilterPolicy; 23 class FilterPolicy;
23 class Env; 24 class Env;
24 class Snapshot; 25 class Snapshot;
(...skipping 22 matching lines...) Expand all
47 48
48 class CONTENT_EXPORT LevelDBLock { 49 class CONTENT_EXPORT LevelDBLock {
49 public: 50 public:
50 LevelDBLock() {} 51 LevelDBLock() {}
51 virtual ~LevelDBLock() {} 52 virtual ~LevelDBLock() {}
52 53
53 private: 54 private:
54 DISALLOW_COPY_AND_ASSIGN(LevelDBLock); 55 DISALLOW_COPY_AND_ASSIGN(LevelDBLock);
55 }; 56 };
56 57
57 class CONTENT_EXPORT LevelDBDatabase { 58 class CONTENT_EXPORT LevelDBDatabase
59 : public base::trace_event::MemoryDumpProvider {
58 public: 60 public:
59 class ComparatorAdapter : public leveldb::Comparator { 61 class ComparatorAdapter : public leveldb::Comparator {
60 public: 62 public:
61 explicit ComparatorAdapter(const LevelDBComparator* comparator); 63 explicit ComparatorAdapter(const LevelDBComparator* comparator);
62 64
63 int Compare(const leveldb::Slice& a, 65 int Compare(const leveldb::Slice& a,
64 const leveldb::Slice& b) const override; 66 const leveldb::Slice& b) const override;
65 67
66 const char* Name() const override; 68 const char* Name() const override;
67 69
68 void FindShortestSeparator(std::string* start, 70 void FindShortestSeparator(std::string* start,
69 const leveldb::Slice& limit) const override; 71 const leveldb::Slice& limit) const override;
70 void FindShortSuccessor(std::string* key) const override; 72 void FindShortSuccessor(std::string* key) const override;
71 73
72 private: 74 private:
73 const LevelDBComparator* comparator_; 75 const LevelDBComparator* comparator_;
74 }; 76 };
75 77
76 static leveldb::Status Open(const base::FilePath& file_name, 78 static leveldb::Status Open(const base::FilePath& file_name,
77 const LevelDBComparator* comparator, 79 const LevelDBComparator* comparator,
78 scoped_ptr<LevelDBDatabase>* db, 80 scoped_ptr<LevelDBDatabase>* db,
79 bool* is_disk_full = 0); 81 bool* is_disk_full = 0);
80 static scoped_ptr<LevelDBDatabase> OpenInMemory( 82 static scoped_ptr<LevelDBDatabase> OpenInMemory(
81 const LevelDBComparator* comparator); 83 const LevelDBComparator* comparator);
82 static leveldb::Status Destroy(const base::FilePath& file_name); 84 static leveldb::Status Destroy(const base::FilePath& file_name);
83 static scoped_ptr<LevelDBLock> LockForTesting( 85 static scoped_ptr<LevelDBLock> LockForTesting(
84 const base::FilePath& file_name); 86 const base::FilePath& file_name);
85 virtual ~LevelDBDatabase(); 87 ~LevelDBDatabase() override;
86 88
87 leveldb::Status Put(const base::StringPiece& key, std::string* value); 89 leveldb::Status Put(const base::StringPiece& key, std::string* value);
88 leveldb::Status Remove(const base::StringPiece& key); 90 leveldb::Status Remove(const base::StringPiece& key);
89 virtual leveldb::Status Get(const base::StringPiece& key, 91 virtual leveldb::Status Get(const base::StringPiece& key,
90 std::string* value, 92 std::string* value,
91 bool* found, 93 bool* found,
92 const LevelDBSnapshot* = 0); 94 const LevelDBSnapshot* = 0);
93 leveldb::Status Write(const LevelDBWriteBatch& write_batch); 95 leveldb::Status Write(const LevelDBWriteBatch& write_batch);
94 scoped_ptr<LevelDBIterator> CreateIterator(const LevelDBSnapshot* = 0); 96 scoped_ptr<LevelDBIterator> CreateIterator(const LevelDBSnapshot* = 0);
95 const LevelDBComparator* Comparator() const; 97 const LevelDBComparator* Comparator() const;
96 void Compact(const base::StringPiece& start, const base::StringPiece& stop); 98 void Compact(const base::StringPiece& start, const base::StringPiece& stop);
97 void CompactAll(); 99 void CompactAll();
98 100
101 // base::trace_event::MemoryDumpProvider implementation.
102 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
103 base::trace_event::ProcessMemoryDump* pmd) override;
104
99 protected: 105 protected:
100 LevelDBDatabase(); 106 LevelDBDatabase();
101 107
102 private: 108 private:
103 friend class LevelDBSnapshot; 109 friend class LevelDBSnapshot;
104 110
105 void CloseDatabase(); 111 void CloseDatabase();
106 112
107 scoped_ptr<leveldb::Env> env_; 113 scoped_ptr<leveldb::Env> env_;
108 scoped_ptr<leveldb::Comparator> comparator_adapter_; 114 scoped_ptr<leveldb::Comparator> comparator_adapter_;
109 scoped_ptr<leveldb::DB> db_; 115 scoped_ptr<leveldb::DB> db_;
110 scoped_ptr<const leveldb::FilterPolicy> filter_policy_; 116 scoped_ptr<const leveldb::FilterPolicy> filter_policy_;
111 const LevelDBComparator* comparator_; 117 const LevelDBComparator* comparator_;
118 std::string file_name_for_tracing;
112 }; 119 };
113 120
114 } // namespace content 121 } // namespace content
115 122
116 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_DATABASE_H_ 123 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698