Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_POLICY_ASYNC_POLICY_PROVIDER_H_ | |
| 6 #define CHROME_BROWSER_POLICY_ASYNC_POLICY_PROVIDER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "chrome/browser/policy/configuration_policy_provider.h" | |
| 12 | |
| 13 namespace policy { | |
| 14 | |
| 15 class AsyncPolicyLoader; | |
| 16 class PolicyBundle; | |
| 17 | |
| 18 // A policy provider that loads its policies asynchronously in the FILE thread. | |
|
Mattias Nissler (ping if slow)
2012/06/04 08:48:26
in or on? on is more familiar to me.
Joao da Silva
2012/06/04 14:05:06
Done.
| |
| 19 // Platform-specific providers are created by passing an implementation of | |
| 20 // AsyncPolicyLoader to a new AsyncPolicyProvider. | |
| 21 class AsyncPolicyProvider : public ConfigurationPolicyProvider { | |
| 22 public: | |
| 23 // Takes ownership of |loader|. | |
| 24 AsyncPolicyProvider(const PolicyDefinitionList* policy_list, | |
| 25 AsyncPolicyLoader* loader); | |
|
Mattias Nissler (ping if slow)
2012/06/04 08:48:26
should declare a scoped_ptr<AsyncPolicyLoader> arg
Joao da Silva
2012/06/04 14:05:06
Done.
| |
| 26 virtual ~AsyncPolicyProvider(); | |
| 27 | |
| 28 // ConfigurationPolicyProvider implementation. | |
| 29 virtual void RefreshPolicies() OVERRIDE; | |
| 30 | |
| 31 private: | |
| 32 // Resumes initialization once the loops are spinning. | |
| 33 void InitWithLoopsReady(); | |
| 34 | |
| 35 // Helper for RefreshPolicies(). | |
| 36 void PostRefreshingReload(); | |
| 37 | |
| 38 // Invoked with the latest bundle loaded by the |loader_|. | |
| 39 void OnLoaderReloaded(scoped_ptr<PolicyBundle> bundle); | |
| 40 | |
| 41 // The |loader_| that does the platform-specific policy loading. It lives | |
| 42 // in the FILE thread, and always outlives |this|. | |
| 43 AsyncPolicyLoader* loader_; | |
| 44 | |
| 45 // Used to get WeakPtrs() to |this| on UI. These are used for the update | |
| 46 // callback passed to |loader_| and for the RefreshPolicies() tasks. | |
| 47 base::WeakPtrFactory<AsyncPolicyProvider> weak_factory_; | |
| 48 | |
| 49 // Number of RefreshPolicies() calls that have been received before | |
| 50 // OnLoaderReloaded() has been invoked. Updates are only triggered after the | |
| 51 // last RefreshPolicies() request has triggered its reload, to make sure | |
| 52 // its observer will see the policy changes made before calling | |
| 53 // RefreshPolicies(). | |
| 54 int pending_refreshes_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(AsyncPolicyProvider); | |
| 57 }; | |
| 58 | |
| 59 } // namespace policy | |
| 60 | |
| 61 #endif // CHROME_BROWSER_POLICY_ASYNC_POLICY_PROVIDER_H_ | |
| OLD | NEW |