| 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_MANAGED_VALUE_STORE_CACHE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_MANAGED_VALUE_STORE_CACHE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_MANAGED_VALUE_STORE_CACHE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_MANAGED_VALUE_STORE_CACHE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/linked_ptr.h" | |
| 16 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 17 #include "components/policy/core/common/policy_service.h" | 16 #include "components/policy/core/common/policy_service.h" |
| 18 #include "extensions/browser/api/storage/settings_observer.h" | 17 #include "extensions/browser/api/storage/settings_observer.h" |
| 19 #include "extensions/browser/api/storage/value_store_cache.h" | 18 #include "extensions/browser/api/storage/value_store_cache.h" |
| 20 | 19 |
| 21 class Profile; | 20 class Profile; |
| 22 | 21 |
| 23 namespace content { | 22 namespace content { |
| 24 class BrowserContext; | 23 class BrowserContext; |
| 25 } | 24 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 44 // |observers| is the list of SettingsObservers to notify when a ValueStore | 43 // |observers| is the list of SettingsObservers to notify when a ValueStore |
| 45 // changes. | 44 // changes. |
| 46 ManagedValueStoreCache(content::BrowserContext* context, | 45 ManagedValueStoreCache(content::BrowserContext* context, |
| 47 const scoped_refptr<ValueStoreFactory>& factory, | 46 const scoped_refptr<ValueStoreFactory>& factory, |
| 48 const scoped_refptr<SettingsObserverList>& observers); | 47 const scoped_refptr<SettingsObserverList>& observers); |
| 49 ~ManagedValueStoreCache() override; | 48 ~ManagedValueStoreCache() override; |
| 50 | 49 |
| 51 private: | 50 private: |
| 52 class ExtensionTracker; | 51 class ExtensionTracker; |
| 53 | 52 |
| 54 // Maps an extension ID to its PolicyValueStoreMap. | |
| 55 typedef std::map<std::string, linked_ptr<PolicyValueStore> > | |
| 56 PolicyValueStoreMap; | |
| 57 | |
| 58 // ValueStoreCache implementation: | 53 // ValueStoreCache implementation: |
| 59 void ShutdownOnUI() override; | 54 void ShutdownOnUI() override; |
| 60 void RunWithValueStoreForExtension( | 55 void RunWithValueStoreForExtension( |
| 61 const StorageCallback& callback, | 56 const StorageCallback& callback, |
| 62 scoped_refptr<const Extension> extension) override; | 57 scoped_refptr<const Extension> extension) override; |
| 63 void DeleteStorageSoon(const std::string& extension_id) override; | 58 void DeleteStorageSoon(const std::string& extension_id) override; |
| 64 | 59 |
| 65 // PolicyService::Observer implementation: | 60 // PolicyService::Observer implementation: |
| 66 void OnPolicyServiceInitialized(policy::PolicyDomain domain) override; | 61 void OnPolicyServiceInitialized(policy::PolicyDomain domain) override; |
| 67 void OnPolicyUpdated(const policy::PolicyNamespace& ns, | 62 void OnPolicyUpdated(const policy::PolicyNamespace& ns, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 89 // Observes extension loading and unloading, and keeps the Profile's | 84 // Observes extension loading and unloading, and keeps the Profile's |
| 90 // PolicyService aware of the current list of extensions. | 85 // PolicyService aware of the current list of extensions. |
| 91 std::unique_ptr<ExtensionTracker> extension_tracker_; | 86 std::unique_ptr<ExtensionTracker> extension_tracker_; |
| 92 | 87 |
| 93 // These live on the FILE thread. | 88 // These live on the FILE thread. |
| 94 scoped_refptr<ValueStoreFactory> storage_factory_; | 89 scoped_refptr<ValueStoreFactory> storage_factory_; |
| 95 scoped_refptr<SettingsObserverList> observers_; | 90 scoped_refptr<SettingsObserverList> observers_; |
| 96 | 91 |
| 97 // All the PolicyValueStores live on the FILE thread, and |store_map_| can be | 92 // All the PolicyValueStores live on the FILE thread, and |store_map_| can be |
| 98 // accessed only on the FILE thread as well. | 93 // accessed only on the FILE thread as well. |
| 99 PolicyValueStoreMap store_map_; | 94 std::map<std::string, std::unique_ptr<PolicyValueStore>> store_map_; |
| 100 | 95 |
| 101 DISALLOW_COPY_AND_ASSIGN(ManagedValueStoreCache); | 96 DISALLOW_COPY_AND_ASSIGN(ManagedValueStoreCache); |
| 102 }; | 97 }; |
| 103 | 98 |
| 104 } // namespace extensions | 99 } // namespace extensions |
| 105 | 100 |
| 106 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_MANAGED_VALUE_STORE_CACHE_H_ | 101 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_MANAGED_VALUE_STORE_CACHE_H_ |
| OLD | NEW |