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

Side by Side Diff: content/browser/leveldb_wrapper_impl.h

Issue 2596603002: Make LevelDBObserver an associated interface to LevelDBWrapper. (Closed)
Patch Set: Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_LEVELDB_WRAPPER_IMPL_H_ 5 #ifndef CONTENT_BROWSER_LEVELDB_WRAPPER_IMPL_H_
6 #define CONTENT_BROWSER_LEVELDB_WRAPPER_IMPL_H_ 6 #define CONTENT_BROWSER_LEVELDB_WRAPPER_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 26 matching lines...) Expand all
37 LevelDBWrapperImpl(leveldb::mojom::LevelDBDatabase* database, 37 LevelDBWrapperImpl(leveldb::mojom::LevelDBDatabase* database,
38 const std::string& prefix, 38 const std::string& prefix,
39 size_t max_size, 39 size_t max_size,
40 base::TimeDelta default_commit_delay, 40 base::TimeDelta default_commit_delay,
41 int max_bytes_per_hour, 41 int max_bytes_per_hour,
42 int max_commits_per_hour, 42 int max_commits_per_hour,
43 const base::Closure& no_bindings_callback); 43 const base::Closure& no_bindings_callback);
44 ~LevelDBWrapperImpl() override; 44 ~LevelDBWrapperImpl() override;
45 45
46 void Bind(mojom::LevelDBWrapperRequest request); 46 void Bind(mojom::LevelDBWrapperRequest request);
47 void AddObserver(mojom::LevelDBObserverPtr observer);
48 47
49 // Commence aggressive flushing. This should be called early during startup, 48 // Commence aggressive flushing. This should be called early during startup,
50 // before any localStorage writing. Currently scheduled writes will not be 49 // before any localStorage writing. Currently scheduled writes will not be
51 // rescheduled and will be flushed at the scheduled time after which 50 // rescheduled and will be flushed at the scheduled time after which
52 // aggressive flushing will commence. 51 // aggressive flushing will commence.
53 static void EnableAggressiveCommitDelay(); 52 static void EnableAggressiveCommitDelay();
54 53
55 private: 54 private:
56 friend class LevelDBWrapperImplTest; 55 friend class LevelDBWrapperImplTest;
57 56
(...skipping 27 matching lines...) Expand all
85 struct CommitBatch { 84 struct CommitBatch {
86 bool clear_all_first; 85 bool clear_all_first;
87 ChangedValueMap changed_values; 86 ChangedValueMap changed_values;
88 87
89 CommitBatch(); 88 CommitBatch();
90 ~CommitBatch(); 89 ~CommitBatch();
91 size_t GetDataSize() const; 90 size_t GetDataSize() const;
92 }; 91 };
93 92
94 // LevelDBWrapperImpl: 93 // LevelDBWrapperImpl:
94 void AddObserver(mojom::LevelDBObserverAssociatedPtrInfo observer) override;
95 void Put(const std::vector<uint8_t>& key, 95 void Put(const std::vector<uint8_t>& key,
96 const std::vector<uint8_t>& value, 96 const std::vector<uint8_t>& value,
97 const std::string& source, 97 const std::string& source,
98 const PutCallback& callback) override; 98 const PutCallback& callback) override;
99 void Delete(const std::vector<uint8_t>& key, 99 void Delete(const std::vector<uint8_t>& key,
100 const std::string& source, 100 const std::string& source,
101 const DeleteCallback& callback) override; 101 const DeleteCallback& callback) override;
102 void DeleteAll(const std::string& source, 102 void DeleteAll(const std::string& source,
103 const DeleteAllCallback& callback) override; 103 const DeleteAllCallback& callback) override;
104 void Get(const std::vector<uint8_t>& key, 104 void Get(const std::vector<uint8_t>& key,
105 const GetCallback& callback) override; 105 const GetCallback& callback) override;
106 void GetAll(const std::string& source, 106 void GetAll(const std::string& source,
107 const GetAllCallback& callback) override; 107 const GetAllCallback& callback) override;
108 108
109 void OnConnectionError(); 109 void OnConnectionError();
110 void LoadMap(const base::Closure& completion_callback); 110 void LoadMap(const base::Closure& completion_callback);
111 void OnLoadComplete(leveldb::mojom::DatabaseError status, 111 void OnLoadComplete(leveldb::mojom::DatabaseError status,
112 std::vector<leveldb::mojom::KeyValuePtr> data); 112 std::vector<leveldb::mojom::KeyValuePtr> data);
113 void CreateCommitBatchIfNeeded(); 113 void CreateCommitBatchIfNeeded();
114 void StartCommitTimer(); 114 void StartCommitTimer();
115 base::TimeDelta ComputeCommitDelay() const; 115 base::TimeDelta ComputeCommitDelay() const;
116 void CommitChanges(); 116 void CommitChanges();
117 void OnCommitComplete(leveldb::mojom::DatabaseError error); 117 void OnCommitComplete(leveldb::mojom::DatabaseError error);
118 118
119 std::vector<uint8_t> prefix_; 119 std::vector<uint8_t> prefix_;
120 mojo::BindingSet<mojom::LevelDBWrapper> bindings_; 120 mojo::BindingSet<mojom::LevelDBWrapper> bindings_;
121 mojo::InterfacePtrSet<mojom::LevelDBObserver> observers_; 121 mojo::AssociatedInterfacePtrSet<mojom::LevelDBObserver> observers_;
122 base::Closure no_bindings_callback_; 122 base::Closure no_bindings_callback_;
123 leveldb::mojom::LevelDBDatabase* database_; 123 leveldb::mojom::LevelDBDatabase* database_;
124 std::unique_ptr<ValueMap> map_; 124 std::unique_ptr<ValueMap> map_;
125 std::vector<base::Closure> on_load_complete_tasks_; 125 std::vector<base::Closure> on_load_complete_tasks_;
126 size_t bytes_used_; 126 size_t bytes_used_;
127 size_t max_size_; 127 size_t max_size_;
128 base::TimeTicks start_time_; 128 base::TimeTicks start_time_;
129 base::TimeDelta default_commit_delay_; 129 base::TimeDelta default_commit_delay_;
130 RateLimiter data_rate_limiter_; 130 RateLimiter data_rate_limiter_;
131 RateLimiter commit_rate_limiter_; 131 RateLimiter commit_rate_limiter_;
132 int commit_batches_in_flight_ = 0; 132 int commit_batches_in_flight_ = 0;
133 std::unique_ptr<CommitBatch> commit_batch_; 133 std::unique_ptr<CommitBatch> commit_batch_;
134 base::WeakPtrFactory<LevelDBWrapperImpl> weak_ptr_factory_; 134 base::WeakPtrFactory<LevelDBWrapperImpl> weak_ptr_factory_;
135 135
136 static bool s_aggressive_flushing_enabled_; 136 static bool s_aggressive_flushing_enabled_;
137 137
138 DISALLOW_COPY_AND_ASSIGN(LevelDBWrapperImpl); 138 DISALLOW_COPY_AND_ASSIGN(LevelDBWrapperImpl);
139 }; 139 };
140 140
141 } // namespace content 141 } // namespace content
142 142
143 #endif // CONTENT_BROWSER_LEVELDB_WRAPPER_IMPL_H_ 143 #endif // CONTENT_BROWSER_LEVELDB_WRAPPER_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/dom_storage/dom_storage_context_wrapper.cc ('k') | content/browser/leveldb_wrapper_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698