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

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

Issue 2604963002: Store per-origin metadata for localstorage. (Closed)
Patch Set: remove duplicate include line Created 3 years, 11 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 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 15 matching lines...) Expand all
26 // features not found directly in leveldb. 26 // features not found directly in leveldb.
27 // 1) Adds the given prefix, if any, to all keys. This allows the sharing of one 27 // 1) Adds the given prefix, if any, to all keys. This allows the sharing of one
28 // database across many, possibly untrusted, consumers and ensuring that they 28 // database across many, possibly untrusted, consumers and ensuring that they
29 // can't access each other's values. 29 // can't access each other's values.
30 // 2) Enforces a max_size constraint. 30 // 2) Enforces a max_size constraint.
31 // 3) Informs observers when values scoped by prefix are modified. 31 // 3) Informs observers when values scoped by prefix are modified.
32 // 4) Throttles requests to avoid overwhelming the disk. 32 // 4) Throttles requests to avoid overwhelming the disk.
33 class CONTENT_EXPORT LevelDBWrapperImpl : public mojom::LevelDBWrapper { 33 class CONTENT_EXPORT LevelDBWrapperImpl : public mojom::LevelDBWrapper {
34 public: 34 public:
35 using PrepareToCommitCallback = 35 using PrepareToCommitCallback =
36 base::Callback<std::vector<leveldb::mojom::BatchedOperationPtr>()>; 36 base::Callback<std::vector<leveldb::mojom::BatchedOperationPtr>(
37 const LevelDBWrapperImpl&)>;
37 38
38 // |no_bindings_callback| will be called when this object has no more 39 // |no_bindings_callback| will be called when this object has no more
39 // bindings and all pending modifications have been processed. 40 // bindings and all pending modifications have been processed.
40 LevelDBWrapperImpl(leveldb::mojom::LevelDBDatabase* database, 41 LevelDBWrapperImpl(leveldb::mojom::LevelDBDatabase* database,
41 const std::string& prefix, 42 const std::string& prefix,
42 size_t max_size, 43 size_t max_size,
43 base::TimeDelta default_commit_delay, 44 base::TimeDelta default_commit_delay,
44 int max_bytes_per_hour, 45 int max_bytes_per_hour,
45 int max_commits_per_hour, 46 int max_commits_per_hour,
46 const base::Closure& no_bindings_callback, 47 const base::Closure& no_bindings_callback,
47 const PrepareToCommitCallback& prepare_to_commit_callback); 48 const PrepareToCommitCallback& prepare_to_commit_callback);
48 ~LevelDBWrapperImpl() override; 49 ~LevelDBWrapperImpl() override;
49 50
50 void Bind(mojom::LevelDBWrapperRequest request); 51 void Bind(mojom::LevelDBWrapperRequest request);
51 52
53 size_t bytes_used() const { return bytes_used_; }
54
52 // Commence aggressive flushing. This should be called early during startup, 55 // Commence aggressive flushing. This should be called early during startup,
53 // before any localStorage writing. Currently scheduled writes will not be 56 // before any localStorage writing. Currently scheduled writes will not be
54 // rescheduled and will be flushed at the scheduled time after which 57 // rescheduled and will be flushed at the scheduled time after which
55 // aggressive flushing will commence. 58 // aggressive flushing will commence.
56 static void EnableAggressiveCommitDelay(); 59 static void EnableAggressiveCommitDelay();
57 60
58 private: 61 private:
59 friend class LevelDBWrapperImplTest; 62 friend class LevelDBWrapperImplTest;
60 63
61 using ValueMap = std::map<std::vector<uint8_t>, std::vector<uint8_t>>; 64 using ValueMap = std::map<std::vector<uint8_t>, std::vector<uint8_t>>;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 base::WeakPtrFactory<LevelDBWrapperImpl> weak_ptr_factory_; 140 base::WeakPtrFactory<LevelDBWrapperImpl> weak_ptr_factory_;
138 141
139 static bool s_aggressive_flushing_enabled_; 142 static bool s_aggressive_flushing_enabled_;
140 143
141 DISALLOW_COPY_AND_ASSIGN(LevelDBWrapperImpl); 144 DISALLOW_COPY_AND_ASSIGN(LevelDBWrapperImpl);
142 }; 145 };
143 146
144 } // namespace content 147 } // namespace content
145 148
146 #endif // CONTENT_BROWSER_LEVELDB_WRAPPER_IMPL_H_ 149 #endif // CONTENT_BROWSER_LEVELDB_WRAPPER_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/dom_storage/local_storage_database.proto ('k') | content/browser/leveldb_wrapper_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698