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

Side by Side Diff: chrome/browser/chromeos/settings/session_manager_operation.cc

Issue 2922453002: Remove validation retry logic from DeviceSettingsService (Closed)
Patch Set: 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/settings/session_manager_operation.h" 5 #include "chrome/browser/chromeos/settings/session_manager_operation.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 void SessionManagerOperation::BlockingRetrieveDeviceSettings() { 144 void SessionManagerOperation::BlockingRetrieveDeviceSettings() {
145 std::string policy_blob; 145 std::string policy_blob;
146 RetrievePolicyResponseType response = 146 RetrievePolicyResponseType response =
147 session_manager_client()->BlockingRetrieveDevicePolicy(&policy_blob); 147 session_manager_client()->BlockingRetrieveDevicePolicy(&policy_blob);
148 ValidateDeviceSettings(policy_blob, response); 148 ValidateDeviceSettings(policy_blob, response);
149 } 149 }
150 150
151 void SessionManagerOperation::ValidateDeviceSettings( 151 void SessionManagerOperation::ValidateDeviceSettings(
152 const std::string& policy_blob, 152 const std::string& policy_blob,
153 RetrievePolicyResponseType response_type) { 153 RetrievePolicyResponseType response_type) {
154 std::unique_ptr<em::PolicyFetchResponse> policy(
155 new em::PolicyFetchResponse());
156 if (policy_blob.empty()) { 154 if (policy_blob.empty()) {
157 ReportResult(DeviceSettingsService::STORE_NO_POLICY); 155 ReportResult(DeviceSettingsService::STORE_NO_POLICY);
158 return; 156 return;
159 } 157 }
160 158
161 if (!policy->ParseFromString(policy_blob) || !policy->IsInitialized()) { 159 std::unique_ptr<em::PolicyFetchResponse> policy =
Thiemo Nagel 2017/06/01 11:55:26 Funny enough, IsInitialized() maps to true [1]. T
emaxx 2017/06/01 18:51:17 Not sure about this change. It's identical to "tru
Thiemo Nagel 2017/06/02 09:30:53 Thanks for explaining the intention of IsInitializ
160 base::MakeUnique<em::PolicyFetchResponse>();
161 if (!policy->ParseFromString(policy_blob)) {
162 ReportResult(DeviceSettingsService::STORE_INVALID_POLICY); 162 ReportResult(DeviceSettingsService::STORE_INVALID_POLICY);
163 return; 163 return;
164 } 164 }
165 165
166 base::SequencedWorkerPool* pool = 166 base::SequencedWorkerPool* pool =
167 content::BrowserThread::GetBlockingPool(); 167 content::BrowserThread::GetBlockingPool();
168 scoped_refptr<base::SequencedTaskRunner> background_task_runner = 168 scoped_refptr<base::SequencedTaskRunner> background_task_runner =
169 pool->GetSequencedTaskRunnerWithShutdownBehavior( 169 pool->GetSequencedTaskRunnerWithShutdownBehavior(
170 pool->GetSequenceToken(), 170 pool->GetSequenceToken(),
171 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); 171 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } else { 203 } else {
204 policy::DeviceCloudPolicyValidator::StartValidation( 204 policy::DeviceCloudPolicyValidator::StartValidation(
205 std::move(validator), 205 std::move(validator),
206 base::Bind(&SessionManagerOperation::ReportValidatorStatus, 206 base::Bind(&SessionManagerOperation::ReportValidatorStatus,
207 weak_factory_.GetWeakPtr())); 207 weak_factory_.GetWeakPtr()));
208 } 208 }
209 } 209 }
210 210
211 void SessionManagerOperation::ReportValidatorStatus( 211 void SessionManagerOperation::ReportValidatorStatus(
212 policy::DeviceCloudPolicyValidator* validator) { 212 policy::DeviceCloudPolicyValidator* validator) {
213 DeviceSettingsService::Status status =
214 DeviceSettingsService::STORE_VALIDATION_ERROR;
215 if (validator->success()) { 213 if (validator->success()) {
216 status = DeviceSettingsService::STORE_SUCCESS;
217 policy_data_ = std::move(validator->policy_data()); 214 policy_data_ = std::move(validator->policy_data());
218 device_settings_ = std::move(validator->payload()); 215 device_settings_ = std::move(validator->payload());
216 ReportResult(DeviceSettingsService::STORE_SUCCESS);
219 } else { 217 } else {
220 LOG(ERROR) << "Policy validation failed: " << validator->status(); 218 LOG(ERROR) << "Policy validation failed: " << validator->status();
221 219 ReportResult(DeviceSettingsService::STORE_VALIDATION_ERROR);
222 // Those are mostly caused by RTC loss and are recoverable.
223 if (validator->status() ==
224 policy::DeviceCloudPolicyValidator::VALIDATION_BAD_TIMESTAMP) {
225 status = DeviceSettingsService::STORE_TEMP_VALIDATION_ERROR;
226 }
227 } 220 }
228
229 ReportResult(status);
230 } 221 }
231 222
232 LoadSettingsOperation::LoadSettingsOperation(bool force_key_load, 223 LoadSettingsOperation::LoadSettingsOperation(bool force_key_load,
233 bool cloud_validations, 224 bool cloud_validations,
234 bool force_immediate_load, 225 bool force_immediate_load,
235 const Callback& callback) 226 const Callback& callback)
236 : SessionManagerOperation(callback) { 227 : SessionManagerOperation(callback) {
237 force_key_load_ = force_key_load; 228 force_key_load_ = force_key_load;
238 cloud_validations_ = cloud_validations; 229 cloud_validations_ = cloud_validations;
239 force_immediate_load_ = force_immediate_load; 230 force_immediate_load_ = force_immediate_load;
(...skipping 28 matching lines...) Expand all
268 } 259 }
269 260
270 void StoreSettingsOperation::HandleStoreResult(bool success) { 261 void StoreSettingsOperation::HandleStoreResult(bool success) {
271 if (!success) 262 if (!success)
272 ReportResult(DeviceSettingsService::STORE_OPERATION_FAILED); 263 ReportResult(DeviceSettingsService::STORE_OPERATION_FAILED);
273 else 264 else
274 StartLoading(); 265 StartLoading();
275 } 266 }
276 267
277 } // namespace chromeos 268 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698