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

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

Issue 12542015: Fixed a glitch in the ComponentCloudPolicyUpdater where a protobuf field was read before being vali… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/policy/component_cloud_policy_updater_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/policy/component_cloud_policy_updater.h" 5 #include "chrome/browser/policy/component_cloud_policy_updater.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 344
345 // Validate the policy before doing anything else. 345 // Validate the policy before doing anything else.
346 PolicyNamespace ns; 346 PolicyNamespace ns;
347 em::ExternalPolicyData data; 347 em::ExternalPolicyData data;
348 if (!store_->ValidatePolicy(response.Pass(), &ns, &data)) { 348 if (!store_->ValidatePolicy(response.Pass(), &ns, &data)) {
349 LOG(ERROR) << "Failed to validate component policy fetched from DMServer"; 349 LOG(ERROR) << "Failed to validate component policy fetched from DMServer";
350 return; 350 return;
351 } 351 }
352 352
353 // Maybe the data for this hash has already been downloaded and cached. 353 // Maybe the data for this hash has already been downloaded and cached.
354 if (data.secure_hash() == store_->GetCachedHash(ns)) 354 if (data.has_secure_hash() &&
355 data.secure_hash() == store_->GetCachedHash(ns)) {
355 return; 356 return;
357 }
356 358
357 // TODO(joaodasilva): implement the other two auth methods. 359 // TODO(joaodasilva): implement the other two auth methods.
358 if (data.download_auth_method() != em::ExternalPolicyData::NONE) 360 if (data.download_auth_method() != em::ExternalPolicyData::NONE)
359 return; 361 return;
360 362
361 // Check for an existing job for this component. 363 // Check for an existing job for this component.
362 FetchJob* job = fetch_jobs_[ns]; 364 FetchJob* job = fetch_jobs_[ns];
363 if (job) { 365 if (job) {
364 // Check if this data has already been seen. 366 // Check if this data has already been seen.
365 if (job->ParamsEquals(data)) 367 if (job->ParamsEquals(data))
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 DCHECK(fetch_jobs_[job->policy_namespace()] == job); 418 DCHECK(fetch_jobs_[job->policy_namespace()] == job);
417 DCHECK(!job_queue_.empty() && job_queue_.front() == job); 419 DCHECK(!job_queue_.empty() && job_queue_.front() == job);
418 // The job isn't deleted when it fails because a retry attempt may have been 420 // The job isn't deleted when it fails because a retry attempt may have been
419 // scheduled. It's also kept so that UpdateExternalPolicy() can see the 421 // scheduled. It's also kept so that UpdateExternalPolicy() can see the
420 // current data, and avoid a new fetch if the data hasn't changed. 422 // current data, and avoid a new fetch if the data hasn't changed.
421 job_queue_.pop(); 423 job_queue_.pop();
422 StartNextJob(); 424 StartNextJob();
423 } 425 }
424 426
425 } // namespace policy 427 } // namespace policy
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/policy/component_cloud_policy_updater_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698