OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |