| 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 #include "chrome/browser/extensions/api/storage/policy_value_store.h" | 5 #include "chrome/browser/extensions/api/storage/policy_value_store.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 // Extends PolicyValueStore by overriding the mutating methods, so that the | 39 // Extends PolicyValueStore by overriding the mutating methods, so that the |
| 40 // Get() base implementation can be tested with the ValueStoreTest parameterized | 40 // Get() base implementation can be tested with the ValueStoreTest parameterized |
| 41 // tests. | 41 // tests. |
| 42 class MutablePolicyValueStore : public PolicyValueStore { | 42 class MutablePolicyValueStore : public PolicyValueStore { |
| 43 public: | 43 public: |
| 44 explicit MutablePolicyValueStore(const base::FilePath& path) | 44 explicit MutablePolicyValueStore(const base::FilePath& path) |
| 45 : PolicyValueStore(kTestExtensionId, | 45 : PolicyValueStore(kTestExtensionId, |
| 46 make_scoped_refptr(new SettingsObserverList()), | 46 make_scoped_refptr(new SettingsObserverList()), |
| 47 scoped_ptr<ValueStore>(new LeveldbValueStore(path))) {} | 47 scoped_ptr<ValueStore>(new LeveldbValueStore(path))) {} |
| 48 virtual ~MutablePolicyValueStore() {} | 48 ~MutablePolicyValueStore() override {} |
| 49 | 49 |
| 50 virtual WriteResult Set( | 50 WriteResult Set(WriteOptions options, |
| 51 WriteOptions options, | 51 const std::string& key, |
| 52 const std::string& key, | 52 const base::Value& value) override { |
| 53 const base::Value& value) override { | |
| 54 return delegate()->Set(options, key, value); | 53 return delegate()->Set(options, key, value); |
| 55 } | 54 } |
| 56 | 55 |
| 57 virtual WriteResult Set( | 56 WriteResult Set(WriteOptions options, |
| 58 WriteOptions options, const base::DictionaryValue& values) override { | 57 const base::DictionaryValue& values) override { |
| 59 return delegate()->Set(options, values); | 58 return delegate()->Set(options, values); |
| 60 } | 59 } |
| 61 | 60 |
| 62 virtual WriteResult Remove(const std::string& key) override { | 61 WriteResult Remove(const std::string& key) override { |
| 63 return delegate()->Remove(key); | 62 return delegate()->Remove(key); |
| 64 } | 63 } |
| 65 | 64 |
| 66 virtual WriteResult Remove(const std::vector<std::string>& keys) override { | 65 WriteResult Remove(const std::vector<std::string>& keys) override { |
| 67 return delegate()->Remove(keys); | 66 return delegate()->Remove(keys); |
| 68 } | 67 } |
| 69 | 68 |
| 70 virtual WriteResult Clear() override { | 69 WriteResult Clear() override { return delegate()->Clear(); } |
| 71 return delegate()->Clear(); | |
| 72 } | |
| 73 | 70 |
| 74 private: | 71 private: |
| 75 DISALLOW_COPY_AND_ASSIGN(MutablePolicyValueStore); | 72 DISALLOW_COPY_AND_ASSIGN(MutablePolicyValueStore); |
| 76 }; | 73 }; |
| 77 | 74 |
| 78 ValueStore* Param(const base::FilePath& file_path) { | 75 ValueStore* Param(const base::FilePath& file_path) { |
| 79 return new MutablePolicyValueStore(file_path); | 76 return new MutablePolicyValueStore(file_path); |
| 80 } | 77 } |
| 81 | 78 |
| 82 } // namespace | 79 } // namespace |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 Mock::VerifyAndClearExpectations(&observer_); | 218 Mock::VerifyAndClearExpectations(&observer_); |
| 222 | 219 |
| 223 // Don't notify when there aren't any changes. | 220 // Don't notify when there aren't any changes. |
| 224 EXPECT_CALL(observer_, OnSettingsChanged(_, _, _)).Times(0); | 221 EXPECT_CALL(observer_, OnSettingsChanged(_, _, _)).Times(0); |
| 225 store_->SetCurrentPolicy(policies); | 222 store_->SetCurrentPolicy(policies); |
| 226 loop_.RunUntilIdle(); | 223 loop_.RunUntilIdle(); |
| 227 Mock::VerifyAndClearExpectations(&observer_); | 224 Mock::VerifyAndClearExpectations(&observer_); |
| 228 } | 225 } |
| 229 | 226 |
| 230 } // namespace extensions | 227 } // namespace extensions |
| OLD | NEW |