| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/policy/cloud_external_data_manager_base.h" | 5 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include <map> | 10 #include <map> |
| 8 #include <string> | 11 #include <string> |
| 9 #include <vector> | 12 #include <vector> |
| 10 | 13 |
| 11 #include "base/bind.h" | 14 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
| 13 #include "base/callback.h" | 16 #include "base/callback.h" |
| 14 #include "base/location.h" | 17 #include "base/location.h" |
| 15 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/macros.h" |
| 16 #include "base/sequenced_task_runner.h" | 20 #include "base/sequenced_task_runner.h" |
| 17 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
| 18 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/thread_task_runner_handle.h" | 23 #include "base/thread_task_runner_handle.h" |
| 20 #include "base/values.h" | 24 #include "base/values.h" |
| 21 #include "chrome/browser/chromeos/policy/cloud_external_data_store.h" | 25 #include "chrome/browser/chromeos/policy/cloud_external_data_store.h" |
| 22 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 26 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 23 #include "components/policy/core/common/cloud/external_policy_data_fetcher.h" | 27 #include "components/policy/core/common/cloud/external_policy_data_fetcher.h" |
| 24 #include "components/policy/core/common/cloud/external_policy_data_updater.h" | 28 #include "components/policy/core/common/cloud/external_policy_data_updater.h" |
| 25 #include "components/policy/core/common/external_data_fetcher.h" | 29 #include "components/policy/core/common/external_data_fetcher.h" |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 const PolicyMap& policy_map = policy_store_->policy_map(); | 383 const PolicyMap& policy_map = policy_store_->policy_map(); |
| 380 for (PolicyMap::const_iterator it = policy_map.begin(); | 384 for (PolicyMap::const_iterator it = policy_map.begin(); |
| 381 it != policy_map.end(); ++it) { | 385 it != policy_map.end(); ++it) { |
| 382 if (!it->second.external_data_fetcher) { | 386 if (!it->second.external_data_fetcher) { |
| 383 // Skip policies that do not reference external data. | 387 // Skip policies that do not reference external data. |
| 384 continue; | 388 continue; |
| 385 } | 389 } |
| 386 const base::DictionaryValue* dict = NULL; | 390 const base::DictionaryValue* dict = NULL; |
| 387 std::string url; | 391 std::string url; |
| 388 std::string hex_hash; | 392 std::string hex_hash; |
| 389 std::vector<uint8> hash; | 393 std::vector<uint8_t> hash; |
| 390 if (it->second.value && it->second.value->GetAsDictionary(&dict) && | 394 if (it->second.value && it->second.value->GetAsDictionary(&dict) && |
| 391 dict->GetStringWithoutPathExpansion("url", &url) && | 395 dict->GetStringWithoutPathExpansion("url", &url) && |
| 392 dict->GetStringWithoutPathExpansion("hash", &hex_hash) && | 396 dict->GetStringWithoutPathExpansion("hash", &hex_hash) && |
| 393 !url.empty() && !hex_hash.empty() && | 397 !url.empty() && !hex_hash.empty() && |
| 394 base::HexStringToBytes(hex_hash, &hash)) { | 398 base::HexStringToBytes(hex_hash, &hash)) { |
| 395 // Add the external data reference to |metadata| if it is valid (URL and | 399 // Add the external data reference to |metadata| if it is valid (URL and |
| 396 // hash are not empty, hash can be decoded as a hex string). | 400 // hash are not empty, hash can be decoded as a hex string). |
| 397 (*metadata)[it->first] = | 401 (*metadata)[it->first] = |
| 398 MetadataEntry(url, std::string(hash.begin(), hash.end())); | 402 MetadataEntry(url, std::string(hash.begin(), hash.end())); |
| 399 } | 403 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 max_external_data_size_for_testing = max_size; | 445 max_external_data_size_for_testing = max_size; |
| 442 } | 446 } |
| 443 | 447 |
| 444 void CloudExternalDataManagerBase::FetchAll() { | 448 void CloudExternalDataManagerBase::FetchAll() { |
| 445 DCHECK(CalledOnValidThread()); | 449 DCHECK(CalledOnValidThread()); |
| 446 backend_task_runner_->PostTask(FROM_HERE, base::Bind( | 450 backend_task_runner_->PostTask(FROM_HERE, base::Bind( |
| 447 &Backend::FetchAll, base::Unretained(backend_.get()))); | 451 &Backend::FetchAll, base::Unretained(backend_.get()))); |
| 448 } | 452 } |
| 449 | 453 |
| 450 } // namespace policy | 454 } // namespace policy |
| OLD | NEW |