| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_QUOTA_ENFORCER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_QUOTA_ENFORCER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_QUOTA_ENFORCER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_QUOTA_ENFORCER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 size_t max_keys, | 22 size_t max_keys, |
| 23 // Ownership taken. | 23 // Ownership taken. |
| 24 SettingsStorage* delegate); | 24 SettingsStorage* delegate); |
| 25 | 25 |
| 26 virtual ~SettingsStorageQuotaEnforcer(); | 26 virtual ~SettingsStorageQuotaEnforcer(); |
| 27 | 27 |
| 28 // SettingsStorage implementation. | 28 // SettingsStorage implementation. |
| 29 virtual ReadResult Get(const std::string& key) OVERRIDE; | 29 virtual ReadResult Get(const std::string& key) OVERRIDE; |
| 30 virtual ReadResult Get(const std::vector<std::string>& keys) OVERRIDE; | 30 virtual ReadResult Get(const std::vector<std::string>& keys) OVERRIDE; |
| 31 virtual ReadResult Get() OVERRIDE; | 31 virtual ReadResult Get() OVERRIDE; |
| 32 virtual WriteResult Set(const std::string& key, const Value& value) OVERRIDE; | 32 virtual WriteResult Set( |
| 33 virtual WriteResult Set(const DictionaryValue& settings) OVERRIDE; | 33 WriteOptions options, |
| 34 virtual WriteResult Remove(const std::string& key) OVERRIDE; | 34 const std::string& key, |
| 35 virtual WriteResult Remove(const std::vector<std::string>& keys) OVERRIDE; | 35 const Value& value) OVERRIDE; |
| 36 virtual WriteResult Clear() OVERRIDE; | 36 virtual WriteResult Set( |
| 37 WriteOptions options, const DictionaryValue& values) OVERRIDE; |
| 38 virtual WriteResult Remove( |
| 39 WriteOptions options, const std::string& key) OVERRIDE; |
| 40 virtual WriteResult Remove( |
| 41 WriteOptions options, const std::vector<std::string>& keys) OVERRIDE; |
| 42 virtual WriteResult Clear(WriteOptions options) OVERRIDE; |
| 37 | 43 |
| 38 private: | 44 private: |
| 39 // The storage quota in bytes. | 45 // The storage quota in bytes. |
| 40 size_t const quota_bytes_; | 46 size_t const quota_bytes_; |
| 41 | 47 |
| 42 // The quota per individual setting in bytes. | 48 // The quota per individual setting in bytes. |
| 43 size_t const quota_bytes_per_setting_; | 49 size_t const quota_bytes_per_setting_; |
| 44 | 50 |
| 45 // The maximum number of settings keys allowed. | 51 // The maximum number of settings keys allowed. |
| 46 size_t const max_keys_; | 52 size_t const max_keys_; |
| 47 | 53 |
| 48 // The delegate storage area. | 54 // The delegate storage area. |
| 49 scoped_ptr<SettingsStorage> const delegate_; | 55 scoped_ptr<SettingsStorage> const delegate_; |
| 50 | 56 |
| 51 // Total size of the settings currently being used. Includes both settings | 57 // Total size of the settings currently being used. Includes both settings |
| 52 // keys and their JSON-encoded values. | 58 // keys and their JSON-encoded values. |
| 53 size_t used_total_; | 59 size_t used_total_; |
| 54 | 60 |
| 55 // Map of key to size of that key, including the key itself. | 61 // Map of key to size of that key, including the key itself. |
| 56 std::map<std::string, size_t> used_per_setting_; | 62 std::map<std::string, size_t> used_per_setting_; |
| 57 | 63 |
| 58 DISALLOW_COPY_AND_ASSIGN(SettingsStorageQuotaEnforcer); | 64 DISALLOW_COPY_AND_ASSIGN(SettingsStorageQuotaEnforcer); |
| 59 }; | 65 }; |
| 60 | 66 |
| 61 } // namespace extensions | 67 } // namespace extensions |
| 62 | 68 |
| 63 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_QUOTA_ENFORCER_H_ | 69 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_STORAGE_QUOTA_ENFORCER_H_ |
| OLD | NEW |