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

Side by Side Diff: chrome/browser/extensions/settings/settings_storage_quota_enforcer.h

Issue 11747025: Run the JSON Schema Compiler's bundle compilation on JSON files. Previously it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix ms release build Created 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_QUOTA_ENFORCER_H_
6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_QUOTA_ENFORCER_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/value_store/value_store.h"
11
12 namespace extensions {
13
14 // Enforces total quota and a per-setting quota in bytes, and a maximum number
15 // of setting keys, for a delegate storage area.
16 class SettingsStorageQuotaEnforcer : public ValueStore {
17 public:
18 struct Limits {
19 // The total quota in bytes.
20 size_t quota_bytes;
21
22 // The quota for each individual item in bytes.
23 size_t quota_bytes_per_item;
24
25 // The maximum number of items allowed.
26 size_t max_items;
27 };
28
29 SettingsStorageQuotaEnforcer(const Limits& limits, ValueStore* delegate);
30
31 virtual ~SettingsStorageQuotaEnforcer();
32
33 // ValueStore implementation.
34 virtual size_t GetBytesInUse(const std::string& key) OVERRIDE;
35 virtual size_t GetBytesInUse(const std::vector<std::string>& keys) OVERRIDE;
36 virtual size_t GetBytesInUse() OVERRIDE;
37 virtual ReadResult Get(const std::string& key) OVERRIDE;
38 virtual ReadResult Get(const std::vector<std::string>& keys) OVERRIDE;
39 virtual ReadResult Get() OVERRIDE;
40 virtual WriteResult Set(
41 WriteOptions options,
42 const std::string& key,
43 const Value& value) OVERRIDE;
44 virtual WriteResult Set(
45 WriteOptions options, const DictionaryValue& values) OVERRIDE;
46 virtual WriteResult Remove(const std::string& key) OVERRIDE;
47 virtual WriteResult Remove(const std::vector<std::string>& keys) OVERRIDE;
48 virtual WriteResult Clear() OVERRIDE;
49
50 private:
51 // Limits configuration.
52 const Limits limits_;
53
54 // The delegate storage area.
55 scoped_ptr<ValueStore> const delegate_;
56
57 // Total bytes in used by |delegate_|. Includes both key lengths and
58 // JSON-encoded values.
59 size_t used_total_;
60
61 // Map of item key to its size, including the key itself.
62 std::map<std::string, size_t> used_per_setting_;
63
64 DISALLOW_COPY_AND_ASSIGN(SettingsStorageQuotaEnforcer);
65 };
66
67 } // namespace extensions
68
69 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_QUOTA_ENFORCER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698