OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ |
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ |
7 | 7 |
8 #include <time.h> | 8 #include <time.h> |
9 | 9 |
10 #include <tr1/memory> | 10 #include <tr1/memory> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include <base/time.h> | 14 #include <base/time.h> |
15 #include <glib.h> | 15 #include <glib.h> |
16 #include <gtest/gtest_prod.h> // for FRIEND_TEST | 16 #include <gtest/gtest_prod.h> // for FRIEND_TEST |
17 | 17 |
18 #include "update_engine/action_processor.h" | 18 #include "update_engine/action_processor.h" |
19 #include "update_engine/chrome_proxy_resolver.h" | |
19 #include "update_engine/download_action.h" | 20 #include "update_engine/download_action.h" |
20 #include "update_engine/omaha_request_params.h" | 21 #include "update_engine/omaha_request_params.h" |
21 #include "update_engine/omaha_response_handler_action.h" | 22 #include "update_engine/omaha_response_handler_action.h" |
23 #include "update_engine/proxy_resolver.h" | |
22 | 24 |
23 class MetricsLibraryInterface; | 25 class MetricsLibraryInterface; |
24 struct UpdateEngineService; | 26 struct UpdateEngineService; |
25 | 27 |
26 namespace chromeos_update_engine { | 28 namespace chromeos_update_engine { |
27 | 29 |
28 class UpdateCheckScheduler; | 30 class UpdateCheckScheduler; |
29 | 31 |
30 extern const char* kUpdateCompletedMarker; | 32 extern const char* kUpdateCompletedMarker; |
31 | 33 |
32 enum UpdateStatus { | 34 enum UpdateStatus { |
33 UPDATE_STATUS_IDLE = 0, | 35 UPDATE_STATUS_IDLE = 0, |
34 UPDATE_STATUS_CHECKING_FOR_UPDATE, | 36 UPDATE_STATUS_CHECKING_FOR_UPDATE, |
35 UPDATE_STATUS_UPDATE_AVAILABLE, | 37 UPDATE_STATUS_UPDATE_AVAILABLE, |
36 UPDATE_STATUS_DOWNLOADING, | 38 UPDATE_STATUS_DOWNLOADING, |
37 UPDATE_STATUS_VERIFYING, | 39 UPDATE_STATUS_VERIFYING, |
38 UPDATE_STATUS_FINALIZING, | 40 UPDATE_STATUS_FINALIZING, |
39 UPDATE_STATUS_UPDATED_NEED_REBOOT, | 41 UPDATE_STATUS_UPDATED_NEED_REBOOT, |
40 UPDATE_STATUS_REPORTING_ERROR_EVENT, | 42 UPDATE_STATUS_REPORTING_ERROR_EVENT, |
41 }; | 43 }; |
42 | 44 |
43 const char* UpdateStatusToString(UpdateStatus status); | 45 const char* UpdateStatusToString(UpdateStatus status); |
44 | 46 |
45 class UpdateAttempter : public ActionProcessorDelegate, | 47 class UpdateAttempter : public ActionProcessorDelegate, |
46 public DownloadActionDelegate { | 48 public DownloadActionDelegate { |
47 public: | 49 public: |
48 static const int kMaxDeltaUpdateFailures; | 50 static const int kMaxDeltaUpdateFailures; |
49 | 51 |
50 UpdateAttempter(PrefsInterface* prefs, MetricsLibraryInterface* metrics_lib); | 52 UpdateAttempter(PrefsInterface* prefs, |
53 MetricsLibraryInterface* metrics_lib, | |
54 DbusGlibInterface* dbus_iface); | |
51 virtual ~UpdateAttempter(); | 55 virtual ~UpdateAttempter(); |
52 | 56 |
53 // Checks for update and, if a newer version is available, attempts | 57 // Checks for update and, if a newer version is available, attempts |
54 // to update the system. Non-empty |in_app_version| or | 58 // to update the system. Non-empty |in_app_version| or |
55 // |in_update_url| prevents automatic detection of the parameter. | 59 // |in_update_url| prevents automatic detection of the parameter. |
60 // If force_obey_proxies is true, the update will likely respect Chrome's | |
petkov
2010/11/19 05:37:15
|force_obey_proxies| or maybe just |obey_proxies|
adlr
2010/11/20 02:52:29
Done.
| |
61 // proxy setting. For security reasons, we may still not honor them. | |
56 virtual void Update(const std::string& app_version, | 62 virtual void Update(const std::string& app_version, |
57 const std::string& omaha_url); | 63 const std::string& omaha_url, |
64 bool force_obey_proxies); | |
58 | 65 |
59 // ActionProcessorDelegate methods: | 66 // ActionProcessorDelegate methods: |
60 void ProcessingDone(const ActionProcessor* processor, ActionExitCode code); | 67 void ProcessingDone(const ActionProcessor* processor, ActionExitCode code); |
61 void ProcessingStopped(const ActionProcessor* processor); | 68 void ProcessingStopped(const ActionProcessor* processor); |
62 void ActionCompleted(ActionProcessor* processor, | 69 void ActionCompleted(ActionProcessor* processor, |
63 AbstractAction* action, | 70 AbstractAction* action, |
64 ActionExitCode code); | 71 ActionExitCode code); |
65 | 72 |
66 // Stop updating. An attempt will be made to record status to the disk | 73 // Stop updating. An attempt will be made to record status to the disk |
67 // so that updates can be resumed later. | 74 // so that updates can be resumed later. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 static gboolean StaticManagePriorityCallback(gpointer data); | 153 static gboolean StaticManagePriorityCallback(gpointer data); |
147 bool ManagePriorityCallback(); | 154 bool ManagePriorityCallback(); |
148 | 155 |
149 // Checks if a full update is needed and forces it by updating the Omaha | 156 // Checks if a full update is needed and forces it by updating the Omaha |
150 // request params. | 157 // request params. |
151 void DisableDeltaUpdateIfNeeded(); | 158 void DisableDeltaUpdateIfNeeded(); |
152 | 159 |
153 // If this was a delta update attempt that failed, count it so that a full | 160 // If this was a delta update attempt that failed, count it so that a full |
154 // update can be tried when needed. | 161 // update can be tried when needed. |
155 void MarkDeltaUpdateFailure(); | 162 void MarkDeltaUpdateFailure(); |
163 | |
164 ProxyResolver* GetProxyResolver() { | |
165 return obeying_proxies_ ? | |
166 reinterpret_cast<ProxyResolver*>(&chrome_proxy_resolver_) : | |
167 reinterpret_cast<ProxyResolver*>(&direct_proxy_resolver_); | |
168 } | |
156 | 169 |
157 // Last status notification timestamp used for throttling. Use monotonic | 170 // Last status notification timestamp used for throttling. Use monotonic |
158 // TimeTicks to ensure that notifications are sent even if the system clock is | 171 // TimeTicks to ensure that notifications are sent even if the system clock is |
159 // set back in the middle of an update. | 172 // set back in the middle of an update. |
160 base::TimeTicks last_notify_time_; | 173 base::TimeTicks last_notify_time_; |
161 | 174 |
162 std::vector<std::tr1::shared_ptr<AbstractAction> > actions_; | 175 std::vector<std::tr1::shared_ptr<AbstractAction> > actions_; |
163 scoped_ptr<ActionProcessor> processor_; | 176 scoped_ptr<ActionProcessor> processor_; |
164 | 177 |
165 // If non-null, this UpdateAttempter will send status updates over this | 178 // If non-null, this UpdateAttempter will send status updates over this |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 UpdateStatus status_; | 214 UpdateStatus status_; |
202 double download_progress_; | 215 double download_progress_; |
203 int64_t last_checked_time_; | 216 int64_t last_checked_time_; |
204 std::string new_version_; | 217 std::string new_version_; |
205 int64_t new_size_; | 218 int64_t new_size_; |
206 bool is_full_update_; | 219 bool is_full_update_; |
207 | 220 |
208 // Device paramaters common to all Omaha requests. | 221 // Device paramaters common to all Omaha requests. |
209 OmahaRequestDeviceParams omaha_request_params_; | 222 OmahaRequestDeviceParams omaha_request_params_; |
210 | 223 |
224 // Number of consecutive manual update checks we've had where we obeyed | |
225 // Chrome's proxy settings. | |
226 int proxy_manual_checks_; | |
227 | |
228 // If true, this update cycle we are obeying proxies | |
229 bool obeying_proxies_; | |
230 | |
231 // Our two proxy resolvers | |
232 DirectProxyResolver direct_proxy_resolver_; | |
233 ChromeProxyResolver chrome_proxy_resolver_; | |
234 | |
211 DISALLOW_COPY_AND_ASSIGN(UpdateAttempter); | 235 DISALLOW_COPY_AND_ASSIGN(UpdateAttempter); |
212 }; | 236 }; |
213 | 237 |
214 } // namespace chromeos_update_engine | 238 } // namespace chromeos_update_engine |
215 | 239 |
216 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ | 240 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ |
OLD | NEW |