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

Side by Side Diff: chrome/browser/policy/cloud_policy_cache_base.cc

Issue 8586030: Added ConfigurationPolicyProvider::RefreshPolicies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/policy/cloud_policy_cache_base.h" 5 #include "chrome/browser/policy/cloud_policy_cache_base.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "chrome/browser/policy/enterprise_metrics.h" 11 #include "chrome/browser/policy/enterprise_metrics.h"
12 #include "chrome/browser/policy/policy_notifier.h" 12 #include "chrome/browser/policy/policy_notifier.h"
13 13
14 namespace policy { 14 namespace policy {
15 15
16 CloudPolicyCacheBase::CloudPolicyCacheBase() 16 CloudPolicyCacheBase::CloudPolicyCacheBase()
17 : notifier_(NULL), 17 : notifier_(NULL),
18 initialization_complete_(false), 18 initialization_complete_(false),
19 is_unmanaged_(false) { 19 is_unmanaged_(false) {
20 public_key_version_.version = 0; 20 public_key_version_.version = 0;
21 public_key_version_.valid = false; 21 public_key_version_.valid = false;
22 } 22 }
23 23
24 CloudPolicyCacheBase::~CloudPolicyCacheBase() { 24 CloudPolicyCacheBase::~CloudPolicyCacheBase() {
25 FOR_EACH_OBSERVER(Observer, observer_list_, OnCacheGoingAway(this)); 25 FOR_EACH_OBSERVER(Observer, observer_list_, OnCacheGoingAway(this));
26 } 26 }
27 27
28 void CloudPolicyCacheBase::SetFetchingDone() {
29 // NotifyObservers only fires notifications if the cache is ready.
30 NotifyObservers();
31 }
32
28 void CloudPolicyCacheBase::AddObserver(Observer* observer) { 33 void CloudPolicyCacheBase::AddObserver(Observer* observer) {
29 observer_list_.AddObserver(observer); 34 observer_list_.AddObserver(observer);
30 } 35 }
31 36
32 void CloudPolicyCacheBase::RemoveObserver(Observer* observer) { 37 void CloudPolicyCacheBase::RemoveObserver(Observer* observer) {
33 observer_list_.RemoveObserver(observer); 38 observer_list_.RemoveObserver(observer);
34 } 39 }
35 40
36 void CloudPolicyCacheBase::Reset() { 41 void CloudPolicyCacheBase::Reset() {
37 last_policy_refresh_time_ = base::Time(); 42 last_policy_refresh_time_ = base::Time();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 !mandatory_policy_.Equals(mandatory_policy) || 107 !mandatory_policy_.Equals(mandatory_policy) ||
103 !recommended_policy_.Equals(recommended_policy); 108 !recommended_policy_.Equals(recommended_policy);
104 mandatory_policy_.Swap(&mandatory_policy); 109 mandatory_policy_.Swap(&mandatory_policy);
105 recommended_policy_.Swap(&recommended_policy); 110 recommended_policy_.Swap(&recommended_policy);
106 111
107 if (!new_policy_differs) { 112 if (!new_policy_differs) {
108 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchNotModified, 113 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchNotModified,
109 kMetricPolicySize); 114 kMetricPolicySize);
110 } 115 }
111 116
112 NotifyObservers();
113
114 InformNotifier(CloudPolicySubsystem::SUCCESS, 117 InformNotifier(CloudPolicySubsystem::SUCCESS,
115 CloudPolicySubsystem::NO_DETAILS); 118 CloudPolicySubsystem::NO_DETAILS);
116 return true; 119 return true;
117 } 120 }
118 121
119 void CloudPolicyCacheBase::SetUnmanagedInternal(const base::Time& timestamp) { 122 void CloudPolicyCacheBase::SetUnmanagedInternal(const base::Time& timestamp) {
120 is_unmanaged_ = true; 123 is_unmanaged_ = true;
121 public_key_version_.valid = false; 124 public_key_version_.valid = false;
122 mandatory_policy_.Clear(); 125 mandatory_policy_.Clear();
123 recommended_policy_.Clear(); 126 recommended_policy_.Clear();
124 last_policy_refresh_time_ = timestamp; 127 last_policy_refresh_time_ = timestamp;
125
126 NotifyObservers();
127 } 128 }
128 129
129 void CloudPolicyCacheBase::SetReady() { 130 void CloudPolicyCacheBase::SetReady() {
130 initialization_complete_ = true; 131 initialization_complete_ = true;
131 NotifyObservers(); 132 NotifyObservers();
132 } 133 }
133 134
134 bool CloudPolicyCacheBase::DecodePolicyResponse( 135 bool CloudPolicyCacheBase::DecodePolicyResponse(
135 const em::PolicyFetchResponse& policy_response, 136 const em::PolicyFetchResponse& policy_response,
136 PolicyMap* mandatory, 137 PolicyMap* mandatory,
(...skipping 27 matching lines...) Expand all
164 void CloudPolicyCacheBase::InformNotifier( 165 void CloudPolicyCacheBase::InformNotifier(
165 CloudPolicySubsystem::PolicySubsystemState state, 166 CloudPolicySubsystem::PolicySubsystemState state,
166 CloudPolicySubsystem::ErrorDetails error_details) { 167 CloudPolicySubsystem::ErrorDetails error_details) {
167 // TODO(jkummerow): To obsolete this NULL-check, make all uses of 168 // TODO(jkummerow): To obsolete this NULL-check, make all uses of
168 // UserPolicyCache explicitly set a notifier using |set_policy_notifier()|. 169 // UserPolicyCache explicitly set a notifier using |set_policy_notifier()|.
169 if (notifier_) 170 if (notifier_)
170 notifier_->Inform(state, error_details, PolicyNotifier::POLICY_CACHE); 171 notifier_->Inform(state, error_details, PolicyNotifier::POLICY_CACHE);
171 } 172 }
172 173
173 } // namespace policy 174 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud_policy_cache_base.h ('k') | chrome/browser/policy/cloud_policy_provider_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698