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

Side by Side Diff: chrome/browser/chromeos/attestation/attestation_policy_observer.cc

Issue 23494053: Remove NOTIFICATION_SYSTEM_SETTING_CHANGED, switch CrosSettings to base::CallbackRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/chromeos/attestation/attestation_policy_observer.h" 5 #include "chrome/browser/chromeos/attestation/attestation_policy_observer.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 AttestationPolicyObserver::AttestationPolicyObserver( 95 AttestationPolicyObserver::AttestationPolicyObserver(
96 policy::CloudPolicyClient* policy_client) 96 policy::CloudPolicyClient* policy_client)
97 : cros_settings_(CrosSettings::Get()), 97 : cros_settings_(CrosSettings::Get()),
98 policy_client_(policy_client), 98 policy_client_(policy_client),
99 cryptohome_client_(NULL), 99 cryptohome_client_(NULL),
100 attestation_flow_(NULL), 100 attestation_flow_(NULL),
101 num_retries_(0), 101 num_retries_(0),
102 retry_delay_(kRetryDelay), 102 retry_delay_(kRetryDelay),
103 weak_factory_(this) { 103 weak_factory_(this) {
104 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 104 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
105 cros_settings_->AddSettingsObserver(kDeviceAttestationEnabled, this); 105 attestation_subscription_ = cros_settings_->AddSettingsObserver(
106 kDeviceAttestationEnabled,
107 base::Bind(&AttestationPolicyObserver::AttestationSettingChanged,
108 base::Unretained(this)));
106 Start(); 109 Start();
107 } 110 }
108 111
109 AttestationPolicyObserver::AttestationPolicyObserver( 112 AttestationPolicyObserver::AttestationPolicyObserver(
110 policy::CloudPolicyClient* policy_client, 113 policy::CloudPolicyClient* policy_client,
111 CryptohomeClient* cryptohome_client, 114 CryptohomeClient* cryptohome_client,
112 AttestationFlow* attestation_flow) 115 AttestationFlow* attestation_flow)
113 : cros_settings_(CrosSettings::Get()), 116 : cros_settings_(CrosSettings::Get()),
114 policy_client_(policy_client), 117 policy_client_(policy_client),
115 cryptohome_client_(cryptohome_client), 118 cryptohome_client_(cryptohome_client),
116 attestation_flow_(attestation_flow), 119 attestation_flow_(attestation_flow),
117 num_retries_(0), 120 num_retries_(0),
118 retry_delay_(kRetryDelay), 121 retry_delay_(kRetryDelay),
119 weak_factory_(this) { 122 weak_factory_(this) {
120 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 123 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
121 cros_settings_->AddSettingsObserver(kDeviceAttestationEnabled, this); 124 attestation_subscription_ = cros_settings_->AddSettingsObserver(
125 kDeviceAttestationEnabled,
126 base::Bind(&AttestationPolicyObserver::AttestationSettingChanged,
127 base::Unretained(this)));
122 Start(); 128 Start();
123 } 129 }
124 130
125 AttestationPolicyObserver::~AttestationPolicyObserver() { 131 AttestationPolicyObserver::~AttestationPolicyObserver() {
126 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 132 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
127 cros_settings_->RemoveSettingsObserver(kDeviceAttestationEnabled, this);
128 } 133 }
129 134
130 void AttestationPolicyObserver::Observe( 135 void AttestationPolicyObserver::AttestationSettingChanged() {
131 int type,
132 const content::NotificationSource& source,
133 const content::NotificationDetails& details) {
134 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
Darren Krahn 2013/09/18 09:05:37 Was removing this DCHECK intentional? If so, we m
Avi (use Gerrit) 2013/09/18 16:41:44 Not intentional. I'll re-insert.
135 std::string* path = content::Details<std::string>(details).ptr();
136 if (type != chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED ||
137 *path != kDeviceAttestationEnabled) {
138 LOG(WARNING) << "AttestationPolicyObserver: Unexpected event received.";
139 return;
140 }
141 num_retries_ = 0; 136 num_retries_ = 0;
142 Start(); 137 Start();
143 } 138 }
144 139
145 void AttestationPolicyObserver::Start() { 140 void AttestationPolicyObserver::Start() {
146 // If attestation is not enabled, there is nothing to do. 141 // If attestation is not enabled, there is nothing to do.
147 bool enabled = false; 142 bool enabled = false;
148 if (!cros_settings_->GetBoolean(kDeviceAttestationEnabled, &enabled) || 143 if (!cros_settings_->GetBoolean(kDeviceAttestationEnabled, &enabled) ||
149 !enabled) 144 !enabled)
150 return; 145 return;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 base::Bind(&AttestationPolicyObserver::Start, 300 base::Bind(&AttestationPolicyObserver::Start,
306 weak_factory_.GetWeakPtr()), 301 weak_factory_.GetWeakPtr()),
307 base::TimeDelta::FromSeconds(retry_delay_)); 302 base::TimeDelta::FromSeconds(retry_delay_));
308 } else { 303 } else {
309 LOG(WARNING) << "AttestationPolicyObserver: Retry limit exceeded."; 304 LOG(WARNING) << "AttestationPolicyObserver: Retry limit exceeded.";
310 } 305 }
311 } 306 }
312 307
313 } // namespace attestation 308 } // namespace attestation
314 } // namespace chromeos 309 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698