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

Side by Side Diff: chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.cc

Issue 2907493002: ChromeOS: Per-user time zone: refactor tests first. (Closed)
Patch Set: Fix debug build Created 3 years, 6 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
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 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 22 matching lines...) Expand all
33 scoped_refptr<base::SequencedTaskRunner> background_task_runner) 33 scoped_refptr<base::SequencedTaskRunner> background_task_runner)
34 : device_settings_service_(device_settings_service), 34 : device_settings_service_(device_settings_service),
35 install_attributes_(install_attributes), 35 install_attributes_(install_attributes),
36 background_task_runner_(background_task_runner), 36 background_task_runner_(background_task_runner),
37 weak_factory_(this) { 37 weak_factory_(this) {
38 device_settings_service_->AddObserver(this); 38 device_settings_service_->AddObserver(this);
39 device_settings_service_->SetDeviceMode(install_attributes_->GetMode()); 39 device_settings_service_->SetDeviceMode(install_attributes_->GetMode());
40 } 40 }
41 41
42 DeviceCloudPolicyStoreChromeOS::~DeviceCloudPolicyStoreChromeOS() { 42 DeviceCloudPolicyStoreChromeOS::~DeviceCloudPolicyStoreChromeOS() {
43 device_settings_service_->RemoveObserver(this); 43 if (device_settings_service_)
44 device_settings_service_->RemoveObserver(this);
44 } 45 }
45 46
46 void DeviceCloudPolicyStoreChromeOS::Store( 47 void DeviceCloudPolicyStoreChromeOS::Store(
47 const em::PolicyFetchResponse& policy) { 48 const em::PolicyFetchResponse& policy) {
48 // The policy and the public key must have already been loaded by the device 49 // The policy and the public key must have already been loaded by the device
49 // settings service. 50 // settings service.
50 DCHECK(is_initialized()); 51 DCHECK(is_initialized());
51 52
52 // Cancel all pending requests. 53 // Cancel all pending requests.
53 weak_factory_.InvalidateWeakPtrs(); 54 weak_factory_.InvalidateWeakPtrs();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 base::Bind(&DeviceCloudPolicyStoreChromeOS::OnPolicyToStoreValidated, 101 base::Bind(&DeviceCloudPolicyStoreChromeOS::OnPolicyToStoreValidated,
101 weak_factory_.GetWeakPtr())); 102 weak_factory_.GetWeakPtr()));
102 } 103 }
103 104
104 void DeviceCloudPolicyStoreChromeOS::DeviceSettingsUpdated() { 105 void DeviceCloudPolicyStoreChromeOS::DeviceSettingsUpdated() {
105 if (!weak_factory_.HasWeakPtrs()) 106 if (!weak_factory_.HasWeakPtrs())
106 UpdateFromService(); 107 UpdateFromService();
107 } 108 }
108 109
109 void DeviceCloudPolicyStoreChromeOS::OnDeviceSettingsServiceShutdown() { 110 void DeviceCloudPolicyStoreChromeOS::OnDeviceSettingsServiceShutdown() {
111 device_settings_service_->RemoveObserver(this);
110 device_settings_service_ = nullptr; 112 device_settings_service_ = nullptr;
111 } 113 }
112 114
113 std::unique_ptr<DeviceCloudPolicyValidator> 115 std::unique_ptr<DeviceCloudPolicyValidator>
114 DeviceCloudPolicyStoreChromeOS::CreateValidator( 116 DeviceCloudPolicyStoreChromeOS::CreateValidator(
115 const em::PolicyFetchResponse& policy) { 117 const em::PolicyFetchResponse& policy) {
116 std::unique_ptr<DeviceCloudPolicyValidator> validator( 118 std::unique_ptr<DeviceCloudPolicyValidator> validator(
117 DeviceCloudPolicyValidator::Create( 119 DeviceCloudPolicyValidator::Create(
118 base::MakeUnique<em::PolicyFetchResponse>(policy), 120 base::MakeUnique<em::PolicyFetchResponse>(policy),
119 background_task_runner_)); 121 background_task_runner_));
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 UMA_HISTOGRAM_BOOLEAN(kDMTokenCheckHistogram, true); 239 UMA_HISTOGRAM_BOOLEAN(kDMTokenCheckHistogram, true);
238 } else { 240 } else {
239 LOG(ERROR) << "Device policy read on enrolled device yields " 241 LOG(ERROR) << "Device policy read on enrolled device yields "
240 << "no DM token! Status: " << service_status << "."; 242 << "no DM token! Status: " << service_status << ".";
241 chromeos::StartupUtils::MarkEnrollmentRecoveryRequired(); 243 chromeos::StartupUtils::MarkEnrollmentRecoveryRequired();
242 UMA_HISTOGRAM_BOOLEAN(kDMTokenCheckHistogram, false); 244 UMA_HISTOGRAM_BOOLEAN(kDMTokenCheckHistogram, false);
243 } 245 }
244 } 246 }
245 247
246 } // namespace policy 248 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698