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