| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_API_STORAGE_POLICY_VALUE_STORE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_POLICY_VALUE_STORE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_POLICY_VALUE_STORE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_POLICY_VALUE_STORE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // A ValueStore that is backed by another, persistent ValueStore, and stores | 23 // A ValueStore that is backed by another, persistent ValueStore, and stores |
| 24 // the policies for a specific extension there. This ValueStore is used to | 24 // the policies for a specific extension there. This ValueStore is used to |
| 25 // run the function of the storage.managed namespace; it's read-only for the | 25 // run the function of the storage.managed namespace; it's read-only for the |
| 26 // extension. The ManagedValueStoreCache sends updated policy to this store | 26 // extension. The ManagedValueStoreCache sends updated policy to this store |
| 27 // and manages its lifetime. | 27 // and manages its lifetime. |
| 28 class PolicyValueStore : public ValueStore { | 28 class PolicyValueStore : public ValueStore { |
| 29 public: | 29 public: |
| 30 PolicyValueStore(const std::string& extension_id, | 30 PolicyValueStore(const std::string& extension_id, |
| 31 const scoped_refptr<SettingsObserverList>& observers, | 31 const scoped_refptr<SettingsObserverList>& observers, |
| 32 scoped_ptr<ValueStore> delegate); | 32 scoped_ptr<ValueStore> delegate); |
| 33 virtual ~PolicyValueStore(); | 33 ~PolicyValueStore() override; |
| 34 | 34 |
| 35 // Stores |policy| in the persistent database represented by the |delegate_| | 35 // Stores |policy| in the persistent database represented by the |delegate_| |
| 36 // and notifies observers with the changes from the previous policy. | 36 // and notifies observers with the changes from the previous policy. |
| 37 void SetCurrentPolicy(const policy::PolicyMap& policy); | 37 void SetCurrentPolicy(const policy::PolicyMap& policy); |
| 38 | 38 |
| 39 // Clears all the stored data and deletes the database. | 39 // Clears all the stored data and deletes the database. |
| 40 void DeleteStorage(); | 40 void DeleteStorage(); |
| 41 | 41 |
| 42 // ValueStore implementation: | 42 // ValueStore implementation: |
| 43 virtual size_t GetBytesInUse(const std::string& key) override; | 43 size_t GetBytesInUse(const std::string& key) override; |
| 44 virtual size_t GetBytesInUse(const std::vector<std::string>& keys) override; | 44 size_t GetBytesInUse(const std::vector<std::string>& keys) override; |
| 45 virtual size_t GetBytesInUse() override; | 45 size_t GetBytesInUse() override; |
| 46 virtual ReadResult Get(const std::string& key) override; | 46 ReadResult Get(const std::string& key) override; |
| 47 virtual ReadResult Get(const std::vector<std::string>& keys) override; | 47 ReadResult Get(const std::vector<std::string>& keys) override; |
| 48 virtual ReadResult Get() override; | 48 ReadResult Get() override; |
| 49 virtual WriteResult Set( | 49 WriteResult Set(WriteOptions options, |
| 50 WriteOptions options, | 50 const std::string& key, |
| 51 const std::string& key, | 51 const base::Value& value) override; |
| 52 const base::Value& value) override; | 52 WriteResult Set(WriteOptions options, |
| 53 virtual WriteResult Set( | 53 const base::DictionaryValue& values) override; |
| 54 WriteOptions options, const base::DictionaryValue& values) override; | 54 WriteResult Remove(const std::string& key) override; |
| 55 virtual WriteResult Remove(const std::string& key) override; | 55 WriteResult Remove(const std::vector<std::string>& keys) override; |
| 56 virtual WriteResult Remove(const std::vector<std::string>& keys) override; | 56 WriteResult Clear() override; |
| 57 virtual WriteResult Clear() override; | |
| 58 // Hopefully, as a Read-Only database, there is no reason to use these. | 57 // Hopefully, as a Read-Only database, there is no reason to use these. |
| 59 virtual bool Restore() override; | 58 bool Restore() override; |
| 60 virtual bool RestoreKey(const std::string& key) override; | 59 bool RestoreKey(const std::string& key) override; |
| 61 | 60 |
| 62 // For unit tests. | 61 // For unit tests. |
| 63 ValueStore* delegate() { return delegate_.get(); } | 62 ValueStore* delegate() { return delegate_.get(); } |
| 64 | 63 |
| 65 private: | 64 private: |
| 66 std::string extension_id_; | 65 std::string extension_id_; |
| 67 scoped_refptr<SettingsObserverList> observers_; | 66 scoped_refptr<SettingsObserverList> observers_; |
| 68 scoped_ptr<ValueStore> delegate_; | 67 scoped_ptr<ValueStore> delegate_; |
| 69 | 68 |
| 70 DISALLOW_COPY_AND_ASSIGN(PolicyValueStore); | 69 DISALLOW_COPY_AND_ASSIGN(PolicyValueStore); |
| 71 }; | 70 }; |
| 72 | 71 |
| 73 } // namespace extensions | 72 } // namespace extensions |
| 74 | 73 |
| 75 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_POLICY_VALUE_STORE_H_ | 74 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_POLICY_VALUE_STORE_H_ |
| OLD | NEW |