| 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 #ifndef CHROME_BROWSER_POLICY_CLOUD_EXTERNAL_POLICY_DATA_UPDATER_H_ | 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_CLOUD_EXTERNAL_POLICY_DATA_UPDATER_H_ |
| 6 #define CHROME_BROWSER_POLICY_CLOUD_EXTERNAL_POLICY_DATA_UPDATER_H_ | 6 #define COMPONENTS_POLICY_CORE_COMMON_CLOUD_EXTERNAL_POLICY_DATA_UPDATER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "components/policy/policy_export.h" |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 class SequencedTaskRunner; | 20 class SequencedTaskRunner; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace policy { | 23 namespace policy { |
| 23 | 24 |
| 24 class ExternalPolicyDataFetcher; | 25 class ExternalPolicyDataFetcher; |
| 25 | 26 |
| 26 // This class downloads external policy data. Given a |Request|, data is fetched | 27 // This class downloads external policy data. Given a |Request|, data is fetched |
| 27 // from the |url|, verified to not exceed |max_size| and to match the expected | 28 // from the |url|, verified to not exceed |max_size| and to match the expected |
| 28 // |hash| and then handed to a callback that can do further verification before | 29 // |hash| and then handed to a callback that can do further verification before |
| 29 // finally deciding whether the fetched data is valid. | 30 // finally deciding whether the fetched data is valid. |
| 30 // If a fetch is not successful or retrieves invalid data, retries are scheduled | 31 // If a fetch is not successful or retrieves invalid data, retries are scheduled |
| 31 // with exponential backoff. | 32 // with exponential backoff. |
| 32 // The actual fetching is handled by an ExternalPolicyDataFetcher, allowing this | 33 // The actual fetching is handled by an ExternalPolicyDataFetcher, allowing this |
| 33 // class to run on a background thread where network I/O is not possible. | 34 // class to run on a background thread where network I/O is not possible. |
| 34 class ExternalPolicyDataUpdater { | 35 class POLICY_EXPORT ExternalPolicyDataUpdater { |
| 35 public: | 36 public: |
| 36 struct Request { | 37 struct POLICY_EXPORT Request { |
| 37 public: | 38 public: |
| 38 Request(); | 39 Request(); |
| 39 Request(const std::string& url, const std::string& hash, int64 max_size); | 40 Request(const std::string& url, const std::string& hash, int64 max_size); |
| 40 | 41 |
| 41 bool operator==(const Request& other) const; | 42 bool operator==(const Request& other) const; |
| 42 | 43 |
| 43 std::string url; | 44 std::string url; |
| 44 std::string hash; | 45 std::string hash; |
| 45 int64 max_size; | 46 int64 max_size; |
| 46 }; | 47 }; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 117 |
| 117 // |True| once the destructor starts. Prevents jobs from being started during | 118 // |True| once the destructor starts. Prevents jobs from being started during |
| 118 // shutdown. | 119 // shutdown. |
| 119 bool shutting_down_; | 120 bool shutting_down_; |
| 120 | 121 |
| 121 DISALLOW_COPY_AND_ASSIGN(ExternalPolicyDataUpdater); | 122 DISALLOW_COPY_AND_ASSIGN(ExternalPolicyDataUpdater); |
| 122 }; | 123 }; |
| 123 | 124 |
| 124 } // namespace policy | 125 } // namespace policy |
| 125 | 126 |
| 126 #endif // CHROME_BROWSER_POLICY_CLOUD_EXTERNAL_POLICY_DATA_UPDATER_H_ | 127 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_EXTERNAL_POLICY_DATA_UPDATER_H_ |
| OLD | NEW |