Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: chrome/browser/policy/cloud_policy_provider_impl.h

Issue 9911029: Refactored the CloudPolicyProvider so that it becomes initialized once and stays initialized. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_CLOUD_POLICY_PROVIDER_IMPL_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_IMPL_H_
7 #pragma once
8
9 #include <vector>
10
11 #include "chrome/browser/policy/cloud_policy_cache_base.h"
12 #include "chrome/browser/policy/cloud_policy_provider.h"
13 #include "chrome/browser/policy/policy_map.h"
14
15 namespace policy {
16
17 class BrowserPolicyConnector;
18
19 class CloudPolicyProviderImpl : public CloudPolicyProvider,
20 public CloudPolicyCacheBase::Observer {
21 public:
22 CloudPolicyProviderImpl(BrowserPolicyConnector* browser_policy_connector,
23 const PolicyDefinitionList* policy_list,
24 PolicyLevel level);
25 virtual ~CloudPolicyProviderImpl();
26
27 // ConfigurationPolicyProvider implementation.
28 virtual bool ProvideInternal(PolicyMap* result) OVERRIDE;
29 virtual bool IsInitializationComplete() const OVERRIDE;
30 virtual void RefreshPolicies() OVERRIDE;
31
32 // CloudPolicyCacheBase::Observer implementation.
33 virtual void OnCacheUpdate(CloudPolicyCacheBase* cache) OVERRIDE;
34 virtual void OnCacheGoingAway(CloudPolicyCacheBase* cache) OVERRIDE;
35 virtual void AppendCache(CloudPolicyCacheBase* cache) OVERRIDE;
36 virtual void PrependCache(CloudPolicyCacheBase* cache) OVERRIDE;
37
38 private:
39 friend class CloudPolicyProviderTest;
40
41 typedef std::vector<CloudPolicyCacheBase*> ListType;
42
43 // Recompute |combined_| from |caches_| and trigger an OnUpdatePolicy if
44 // something changed. This is called whenever a change in one of the caches
45 // is observed. For i=0..n-1: |caches_[i]| will contribute all its policies
46 // except those already provided by |caches_[0]|..|caches_[i-1]|.
47 void RecombineCachesAndTriggerUpdate();
48
49 // Removes |cache| from |caches|, if contained therein.
50 static void RemoveCache(CloudPolicyCacheBase* cache, ListType* caches);
51
52 // Weak pointer to the connector. Guaranteed to outlive |this|.
53 BrowserPolicyConnector* browser_policy_connector_;
54
55 // The underlying policy caches.
56 ListType caches_;
57
58 // Caches with pending updates. Used by RefreshPolicies to determine if a
59 // refresh has fully completed.
60 ListType pending_update_caches_;
61
62 // Policy level this provider will handle.
63 PolicyLevel level_;
64
65 // Whether all caches are fully initialized.
66 bool initialization_complete_;
67
68 // The currently valid combination of all the maps in |caches_|. Will be
69 // applied as is on call of Provide.
70 PolicyMap combined_;
71
72 DISALLOW_COPY_AND_ASSIGN(CloudPolicyProviderImpl);
73 };
74
75 } // namespace policy
76
77 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud_policy_provider.cc ('k') | chrome/browser/policy/cloud_policy_provider_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698