Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "update_engine/update_attempter.h" |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 6 | |
| 7 | // From 'man clock_gettime': feature test macro: _POSIX_C_SOURCE >= 199309L |
| 8 | #ifndef _POSIX_C_SOURCE |
| 9 | #define _POSIX_C_SOURCE 199309L |
| 10 | #endif // _POSIX_C_SOURCE |
| 11 | #include <time.h> |
| 12 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 13 | #include <string> |
Darin Petkov | 9b23057 | 2010-10-08 10:20:09 -0700 | [diff] [blame] | 14 | #include <tr1/memory> |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 15 | #include <vector> |
Darin Petkov | 9d65b7b | 2010-07-20 09:13:01 -0700 | [diff] [blame] | 16 | |
Jay Srinivasan | c1ba09a | 2012-08-14 14:15:57 -0700 | [diff] [blame] | 17 | #include <base/file_util.h> |
Andrew de los Reyes | 4516810 | 2010-11-22 11:13:50 -0800 | [diff] [blame] | 18 | #include <base/rand_util.h> |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 19 | #include <glib.h> |
Darin Petkov | 1023a60 | 2010-08-30 13:47:51 -0700 | [diff] [blame] | 20 | #include <metrics/metrics_library.h> |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 21 | #include <policy/libpolicy.h> |
| 22 | #include <policy/device_policy.h> |
Darin Petkov | 9d65b7b | 2010-07-20 09:13:01 -0700 | [diff] [blame] | 23 | |
Bruno Rocha | 7f9aea2 | 2011-09-12 14:31:24 -0700 | [diff] [blame] | 24 | #include "update_engine/certificate_checker.h" |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 25 | #include "update_engine/dbus_service.h" |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 26 | #include "update_engine/download_action.h" |
| 27 | #include "update_engine/filesystem_copier_action.h" |
| 28 | #include "update_engine/libcurl_http_fetcher.h" |
Andrew de los Reyes | 819fef2 | 2010-12-17 11:33:58 -0800 | [diff] [blame] | 29 | #include "update_engine/multi_range_http_fetcher.h" |
Darin Petkov | 6a5b322 | 2010-07-13 14:55:28 -0700 | [diff] [blame] | 30 | #include "update_engine/omaha_request_action.h" |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 31 | #include "update_engine/omaha_request_params.h" |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 32 | #include "update_engine/omaha_response_handler_action.h" |
| 33 | #include "update_engine/postinstall_runner_action.h" |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 34 | #include "update_engine/prefs_interface.h" |
Andrew de los Reyes | 6dbf30a | 2011-04-19 10:58:16 -0700 | [diff] [blame] | 35 | #include "update_engine/subprocess.h" |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 36 | #include "update_engine/system_state.h" |
Darin Petkov | 1023a60 | 2010-08-30 13:47:51 -0700 | [diff] [blame] | 37 | #include "update_engine/update_check_scheduler.h" |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 38 | |
Darin Petkov | af18305 | 2010-08-23 12:07:13 -0700 | [diff] [blame] | 39 | using base::TimeDelta; |
| 40 | using base::TimeTicks; |
Andrew de los Reyes | 21816e1 | 2011-04-07 14:18:56 -0700 | [diff] [blame] | 41 | using google::protobuf::NewPermanentCallback; |
Darin Petkov | 9b23057 | 2010-10-08 10:20:09 -0700 | [diff] [blame] | 42 | using std::make_pair; |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 43 | using std::tr1::shared_ptr; |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 44 | using std::set; |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 45 | using std::string; |
| 46 | using std::vector; |
| 47 | |
| 48 | namespace chromeos_update_engine { |
| 49 | |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 50 | const int UpdateAttempter::kMaxDeltaUpdateFailures = 3; |
| 51 | |
Gilad Arnold | 1ebd813 | 2012-03-05 10:19:29 -0800 | [diff] [blame] | 52 | // Private test server URL w/ custom port number. |
Gilad Arnold | ed74731 | 2012-03-15 18:20:41 -0700 | [diff] [blame] | 53 | // TODO(garnold) This is a temporary hack to allow us to test the closed loop |
| 54 | // automated update testing. To be replaced with an hard-coded local IP address. |
| 55 | const char* const UpdateAttempter::kTestUpdateUrl( |
| 56 | "http://garnold.mtv.corp.google.com:8080/update"); |
Gilad Arnold | 28e2f39 | 2012-02-09 14:36:46 -0800 | [diff] [blame] | 57 | |
Darin Petkov | cd1666f | 2010-09-23 09:53:44 -0700 | [diff] [blame] | 58 | const char* kUpdateCompletedMarker = |
| 59 | "/var/run/update_engine_autoupdate_completed"; |
Andrew de los Reyes | 6b78e29 | 2010-05-10 15:54:39 -0700 | [diff] [blame] | 60 | |
Andrew de los Reyes | 4516810 | 2010-11-22 11:13:50 -0800 | [diff] [blame] | 61 | namespace { |
| 62 | const int kMaxConsecutiveObeyProxyRequests = 20; |
| 63 | } // namespace {} |
| 64 | |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 65 | const char* UpdateStatusToString(UpdateStatus status) { |
| 66 | switch (status) { |
| 67 | case UPDATE_STATUS_IDLE: |
| 68 | return "UPDATE_STATUS_IDLE"; |
| 69 | case UPDATE_STATUS_CHECKING_FOR_UPDATE: |
| 70 | return "UPDATE_STATUS_CHECKING_FOR_UPDATE"; |
| 71 | case UPDATE_STATUS_UPDATE_AVAILABLE: |
| 72 | return "UPDATE_STATUS_UPDATE_AVAILABLE"; |
| 73 | case UPDATE_STATUS_DOWNLOADING: |
| 74 | return "UPDATE_STATUS_DOWNLOADING"; |
| 75 | case UPDATE_STATUS_VERIFYING: |
| 76 | return "UPDATE_STATUS_VERIFYING"; |
| 77 | case UPDATE_STATUS_FINALIZING: |
| 78 | return "UPDATE_STATUS_FINALIZING"; |
| 79 | case UPDATE_STATUS_UPDATED_NEED_REBOOT: |
| 80 | return "UPDATE_STATUS_UPDATED_NEED_REBOOT"; |
Darin Petkov | 09f96c3 | 2010-07-20 09:24:57 -0700 | [diff] [blame] | 81 | case UPDATE_STATUS_REPORTING_ERROR_EVENT: |
| 82 | return "UPDATE_STATUS_REPORTING_ERROR_EVENT"; |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 83 | default: |
| 84 | return "unknown status"; |
| 85 | } |
| 86 | } |
| 87 | |
Darin Petkov | 777dbfa | 2010-07-20 15:03:37 -0700 | [diff] [blame] | 88 | // Turns a generic kActionCodeError to a generic error code specific |
| 89 | // to |action| (e.g., kActionCodeFilesystemCopierError). If |code| is |
| 90 | // not kActionCodeError, or the action is not matched, returns |code| |
| 91 | // unchanged. |
| 92 | ActionExitCode GetErrorCodeForAction(AbstractAction* action, |
| 93 | ActionExitCode code) { |
| 94 | if (code != kActionCodeError) |
| 95 | return code; |
| 96 | |
| 97 | const string type = action->Type(); |
| 98 | if (type == OmahaRequestAction::StaticType()) |
| 99 | return kActionCodeOmahaRequestError; |
| 100 | if (type == OmahaResponseHandlerAction::StaticType()) |
| 101 | return kActionCodeOmahaResponseHandlerError; |
| 102 | if (type == FilesystemCopierAction::StaticType()) |
| 103 | return kActionCodeFilesystemCopierError; |
| 104 | if (type == PostinstallRunnerAction::StaticType()) |
| 105 | return kActionCodePostinstallRunnerError; |
Darin Petkov | 777dbfa | 2010-07-20 15:03:37 -0700 | [diff] [blame] | 106 | |
| 107 | return code; |
| 108 | } |
| 109 | |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 110 | UpdateAttempter::UpdateAttempter(SystemState* system_state, |
Gilad Arnold | bf7919b | 2013-01-08 13:07:37 -0800 | [diff] [blame^] | 111 | DbusGlibInterface* dbus_iface) |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 112 | : processor_(new ActionProcessor()), |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 113 | system_state_(system_state), |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 114 | dbus_service_(NULL), |
Darin Petkov | 1023a60 | 2010-08-30 13:47:51 -0700 | [diff] [blame] | 115 | update_check_scheduler_(NULL), |
Andrew de los Reyes | c1d5c93 | 2011-04-20 17:15:47 -0700 | [diff] [blame] | 116 | fake_update_success_(false), |
Darin Petkov | 1023a60 | 2010-08-30 13:47:51 -0700 | [diff] [blame] | 117 | http_response_code_(0), |
Chris Sosa | 4f8ee27 | 2012-11-30 13:01:54 -0800 | [diff] [blame] | 118 | shares_(utils::kCpuSharesNormal), |
| 119 | manage_shares_source_(NULL), |
Darin Petkov | 9d911fa | 2010-08-19 09:36:08 -0700 | [diff] [blame] | 120 | download_active_(false), |
Darin Petkov | c6c135c | 2010-08-11 13:36:18 -0700 | [diff] [blame] | 121 | status_(UPDATE_STATUS_IDLE), |
| 122 | download_progress_(0.0), |
| 123 | last_checked_time_(0), |
| 124 | new_version_("0.0.0.0"), |
Jay Srinivasan | 51dcf26 | 2012-09-13 17:24:32 -0700 | [diff] [blame] | 125 | new_payload_size_(0), |
Andrew de los Reyes | 4516810 | 2010-11-22 11:13:50 -0800 | [diff] [blame] | 126 | proxy_manual_checks_(0), |
| 127 | obeying_proxies_(true), |
Andrew de los Reyes | 6dbf30a | 2011-04-19 10:58:16 -0700 | [diff] [blame] | 128 | chrome_proxy_resolver_(dbus_iface), |
Darin Petkov | 58dd134 | 2011-05-06 12:05:13 -0700 | [diff] [blame] | 129 | updated_boot_flags_(false), |
| 130 | update_boot_flags_running_(false), |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 131 | start_action_processor_(false), |
Gilad Arnold | 1ebd813 | 2012-03-05 10:19:29 -0800 | [diff] [blame] | 132 | policy_provider_(NULL), |
Gilad Arnold | 4d740eb | 2012-05-15 08:48:13 -0700 | [diff] [blame] | 133 | is_using_test_url_(false), |
Gilad Arnold | 7c04e76 | 2012-05-23 10:54:02 -0700 | [diff] [blame] | 134 | is_test_mode_(false), |
Gilad Arnold | bf7919b | 2013-01-08 13:07:37 -0800 | [diff] [blame^] | 135 | is_test_update_attempted_(false) { |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 136 | prefs_ = system_state->prefs(); |
Darin Petkov | c6c135c | 2010-08-11 13:36:18 -0700 | [diff] [blame] | 137 | if (utils::FileExists(kUpdateCompletedMarker)) |
| 138 | status_ = UPDATE_STATUS_UPDATED_NEED_REBOOT; |
| 139 | } |
| 140 | |
| 141 | UpdateAttempter::~UpdateAttempter() { |
Chris Sosa | 4f8ee27 | 2012-11-30 13:01:54 -0800 | [diff] [blame] | 142 | CleanupCpuSharesManagement(); |
Darin Petkov | c6c135c | 2010-08-11 13:36:18 -0700 | [diff] [blame] | 143 | } |
| 144 | |
Gilad Arnold | 28e2f39 | 2012-02-09 14:36:46 -0800 | [diff] [blame] | 145 | void UpdateAttempter::Update(const string& app_version, |
| 146 | const string& omaha_url, |
Andrew de los Reyes | fb2f461 | 2011-06-09 18:21:49 -0700 | [diff] [blame] | 147 | bool obey_proxies, |
Gilad Arnold | 1ebd813 | 2012-03-05 10:19:29 -0800 | [diff] [blame] | 148 | bool interactive, |
Gilad Arnold | 7c04e76 | 2012-05-23 10:54:02 -0700 | [diff] [blame] | 149 | bool is_test_mode, |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 150 | bool is_user_initiated) { |
Andrew de los Reyes | 000d895 | 2011-03-02 15:21:14 -0800 | [diff] [blame] | 151 | chrome_proxy_resolver_.Init(); |
Andrew de los Reyes | c1d5c93 | 2011-04-20 17:15:47 -0700 | [diff] [blame] | 152 | fake_update_success_ = false; |
Andrew de los Reyes | 6b78e29 | 2010-05-10 15:54:39 -0700 | [diff] [blame] | 153 | if (status_ == UPDATE_STATUS_UPDATED_NEED_REBOOT) { |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 154 | // Although we have applied an update, we still want to ping Omaha |
| 155 | // to ensure the number of active statistics is accurate. |
Andrew de los Reyes | 6b78e29 | 2010-05-10 15:54:39 -0700 | [diff] [blame] | 156 | LOG(INFO) << "Not updating b/c we already updated and we're waiting for " |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 157 | << "reboot, we'll ping Omaha instead"; |
| 158 | PingOmaha(); |
Andrew de los Reyes | 6b78e29 | 2010-05-10 15:54:39 -0700 | [diff] [blame] | 159 | return; |
| 160 | } |
| 161 | if (status_ != UPDATE_STATUS_IDLE) { |
| 162 | // Update in progress. Do nothing |
| 163 | return; |
| 164 | } |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 165 | |
| 166 | if (!CalculateUpdateParams(app_version, |
| 167 | omaha_url, |
| 168 | obey_proxies, |
| 169 | interactive, |
Gilad Arnold | 7c04e76 | 2012-05-23 10:54:02 -0700 | [diff] [blame] | 170 | is_test_mode, |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 171 | is_user_initiated)) { |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 172 | return; |
| 173 | } |
| 174 | |
| 175 | BuildUpdateActions(interactive); |
| 176 | |
| 177 | SetStatusAndNotify(UPDATE_STATUS_CHECKING_FOR_UPDATE, |
| 178 | kUpdateNoticeUnspecified); |
| 179 | |
| 180 | // Just in case we didn't update boot flags yet, make sure they're updated |
| 181 | // before any update processing starts. |
| 182 | start_action_processor_ = true; |
| 183 | UpdateBootFlags(); |
| 184 | } |
| 185 | |
| 186 | bool UpdateAttempter::CalculateUpdateParams(const string& app_version, |
| 187 | const string& omaha_url, |
| 188 | bool obey_proxies, |
| 189 | bool interactive, |
Gilad Arnold | 7c04e76 | 2012-05-23 10:54:02 -0700 | [diff] [blame] | 190 | bool is_test_mode, |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 191 | bool is_user_initiated) { |
Darin Petkov | 1023a60 | 2010-08-30 13:47:51 -0700 | [diff] [blame] | 192 | http_response_code_ = 0; |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 193 | |
Gilad Arnold | 7c04e76 | 2012-05-23 10:54:02 -0700 | [diff] [blame] | 194 | // Set the test mode flag for the current update attempt. |
| 195 | is_test_mode_ = is_test_mode; |
| 196 | |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 197 | // Lazy initialize the policy provider, or reload the latest policy data. |
| 198 | if (!policy_provider_.get()) { |
| 199 | policy_provider_.reset(new policy::PolicyProvider()); |
| 200 | } else { |
| 201 | policy_provider_->Reload(); |
| 202 | } |
| 203 | |
| 204 | // If the release_track is specified by policy, that takes precedence. |
| 205 | string release_track; |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 206 | |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 207 | if (policy_provider_->device_policy_is_loaded()) { |
| 208 | const policy::DevicePolicy& device_policy = |
| 209 | policy_provider_->GetDevicePolicy(); |
| 210 | device_policy.GetReleaseChannel(&release_track); |
| 211 | device_policy.GetUpdateDisabled(&omaha_request_params_.update_disabled); |
| 212 | device_policy.GetTargetVersionPrefix( |
| 213 | &omaha_request_params_.target_version_prefix); |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 214 | |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 215 | system_state_->set_device_policy(&device_policy); |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 216 | |
| 217 | set<string> allowed_types; |
| 218 | string allowed_types_str; |
| 219 | if (device_policy.GetAllowedConnectionTypesForUpdate(&allowed_types)) { |
| 220 | set<string>::const_iterator iter; |
| 221 | for (iter = allowed_types.begin(); iter != allowed_types.end(); ++iter) |
| 222 | allowed_types_str += *iter + " "; |
| 223 | } |
| 224 | |
| 225 | LOG(INFO) << "Networks over which updates are allowed per policy : " |
| 226 | << (allowed_types_str.empty() ? "all" : allowed_types_str); |
| 227 | } else { |
| 228 | LOG(INFO) << "No device policies present."; |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 229 | system_state_->set_device_policy(NULL); |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 230 | } |
| 231 | |
Jay Srinivasan | 21be075 | 2012-07-25 15:44:56 -0700 | [diff] [blame] | 232 | CalculateScatteringParams(is_user_initiated); |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 233 | |
Gilad Arnold | 1ebd813 | 2012-03-05 10:19:29 -0800 | [diff] [blame] | 234 | // Determine whether an alternative test address should be used. |
Gilad Arnold | 28e2f39 | 2012-02-09 14:36:46 -0800 | [diff] [blame] | 235 | string omaha_url_to_use = omaha_url; |
Gilad Arnold | 7c04e76 | 2012-05-23 10:54:02 -0700 | [diff] [blame] | 236 | if ((is_using_test_url_ = (omaha_url_to_use.empty() && is_test_mode_))) { |
Gilad Arnold | 1ebd813 | 2012-03-05 10:19:29 -0800 | [diff] [blame] | 237 | omaha_url_to_use = kTestUpdateUrl; |
| 238 | LOG(INFO) << "using alternative server address: " << omaha_url_to_use; |
Gilad Arnold | 28e2f39 | 2012-02-09 14:36:46 -0800 | [diff] [blame] | 239 | } |
| 240 | |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 241 | if (!omaha_request_params_.Init(app_version, |
| 242 | omaha_url_to_use, |
Gilad Arnold | 28e2f39 | 2012-02-09 14:36:46 -0800 | [diff] [blame] | 243 | release_track)) { |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 244 | LOG(ERROR) << "Unable to initialize Omaha request device params."; |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 245 | return false; |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 246 | } |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 247 | |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 248 | LOG(INFO) << "update_disabled = " |
| 249 | << (omaha_request_params_.update_disabled ? "true" : "false") |
| 250 | << ", target_version_prefix = " |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 251 | << omaha_request_params_.target_version_prefix |
| 252 | << ", scatter_factor_in_seconds = " |
| 253 | << utils::FormatSecs(scatter_factor_.InSeconds()); |
| 254 | |
| 255 | LOG(INFO) << "Wall Clock Based Wait Enabled = " |
| 256 | << omaha_request_params_.wall_clock_based_wait_enabled |
| 257 | << ", Update Check Count Wait Enabled = " |
| 258 | << omaha_request_params_.update_check_count_wait_enabled |
Jay Srinivasan | 21be075 | 2012-07-25 15:44:56 -0700 | [diff] [blame] | 259 | << ", Waiting Period = " << utils::FormatSecs( |
| 260 | omaha_request_params_.waiting_period.InSeconds()); |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 261 | |
Andrew de los Reyes | 4516810 | 2010-11-22 11:13:50 -0800 | [diff] [blame] | 262 | obeying_proxies_ = true; |
| 263 | if (obey_proxies || proxy_manual_checks_ == 0) { |
| 264 | LOG(INFO) << "forced to obey proxies"; |
| 265 | // If forced to obey proxies, every 20th request will not use proxies |
| 266 | proxy_manual_checks_++; |
| 267 | LOG(INFO) << "proxy manual checks: " << proxy_manual_checks_; |
| 268 | if (proxy_manual_checks_ >= kMaxConsecutiveObeyProxyRequests) { |
| 269 | proxy_manual_checks_ = 0; |
| 270 | obeying_proxies_ = false; |
| 271 | } |
| 272 | } else if (base::RandInt(0, 4) == 0) { |
| 273 | obeying_proxies_ = false; |
| 274 | } |
| 275 | LOG_IF(INFO, !obeying_proxies_) << "To help ensure updates work, this update " |
| 276 | "check we are ignoring the proxy settings and using " |
| 277 | "direct connections."; |
| 278 | |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 279 | DisableDeltaUpdateIfNeeded(); |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 280 | return true; |
| 281 | } |
| 282 | |
Jay Srinivasan | 21be075 | 2012-07-25 15:44:56 -0700 | [diff] [blame] | 283 | void UpdateAttempter::CalculateScatteringParams(bool is_user_initiated) { |
| 284 | // Take a copy of the old scatter value before we update it, as |
| 285 | // we need to update the waiting period if this value changes. |
| 286 | TimeDelta old_scatter_factor = scatter_factor_; |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 287 | const policy::DevicePolicy* device_policy = system_state_->device_policy(); |
Jay Srinivasan | 21be075 | 2012-07-25 15:44:56 -0700 | [diff] [blame] | 288 | if (device_policy) { |
| 289 | int64 new_scatter_factor_in_secs = 0; |
| 290 | device_policy->GetScatterFactorInSeconds(&new_scatter_factor_in_secs); |
| 291 | if (new_scatter_factor_in_secs < 0) // sanitize input, just in case. |
| 292 | new_scatter_factor_in_secs = 0; |
| 293 | scatter_factor_ = TimeDelta::FromSeconds(new_scatter_factor_in_secs); |
| 294 | } |
| 295 | |
| 296 | bool is_scatter_enabled = false; |
| 297 | if (scatter_factor_.InSeconds() == 0) { |
| 298 | LOG(INFO) << "Scattering disabled since scatter factor is set to 0"; |
| 299 | } else if (is_user_initiated) { |
| 300 | LOG(INFO) << "Scattering disabled as this update check is user-initiated"; |
| 301 | } else if (!system_state_->IsOOBEComplete()) { |
| 302 | LOG(INFO) << "Scattering disabled since OOBE is not complete yet"; |
| 303 | } else { |
| 304 | is_scatter_enabled = true; |
| 305 | LOG(INFO) << "Scattering is enabled"; |
| 306 | } |
| 307 | |
| 308 | if (is_scatter_enabled) { |
| 309 | // This means the scattering policy is turned on. |
| 310 | // Now check if we need to update the waiting period. The two cases |
| 311 | // in which we'd need to update the waiting period are: |
| 312 | // 1. First time in process or a scheduled check after a user-initiated one. |
| 313 | // (omaha_request_params_.waiting_period will be zero in this case). |
| 314 | // 2. Admin has changed the scattering policy value. |
| 315 | // (new scattering value will be different from old one in this case). |
| 316 | int64 wait_period_in_secs = 0; |
| 317 | if (omaha_request_params_.waiting_period.InSeconds() == 0) { |
| 318 | // First case. Check if we have a suitable value to set for |
| 319 | // the waiting period. |
| 320 | if (prefs_->GetInt64(kPrefsWallClockWaitPeriod, &wait_period_in_secs) && |
| 321 | wait_period_in_secs > 0 && |
| 322 | wait_period_in_secs <= scatter_factor_.InSeconds()) { |
| 323 | // This means: |
| 324 | // 1. There's a persisted value for the waiting period available. |
| 325 | // 2. And that persisted value is still valid. |
| 326 | // So, in this case, we should reuse the persisted value instead of |
| 327 | // generating a new random value to improve the chances of a good |
| 328 | // distribution for scattering. |
| 329 | omaha_request_params_.waiting_period = |
| 330 | TimeDelta::FromSeconds(wait_period_in_secs); |
| 331 | LOG(INFO) << "Using persisted wall-clock waiting period: " << |
| 332 | utils::FormatSecs(omaha_request_params_.waiting_period.InSeconds()); |
| 333 | } |
| 334 | else { |
| 335 | // This means there's no persisted value for the waiting period |
| 336 | // available or its value is invalid given the new scatter_factor value. |
| 337 | // So, we should go ahead and regenerate a new value for the |
| 338 | // waiting period. |
| 339 | LOG(INFO) << "Persisted value not present or not valid (" |
| 340 | << utils::FormatSecs(wait_period_in_secs) |
| 341 | << ") for wall-clock waiting period."; |
| 342 | GenerateNewWaitingPeriod(); |
| 343 | } |
| 344 | } else if (scatter_factor_ != old_scatter_factor) { |
| 345 | // This means there's already a waiting period value, but we detected |
| 346 | // a change in the scattering policy value. So, we should regenerate the |
| 347 | // waiting period to make sure it's within the bounds of the new scatter |
| 348 | // factor value. |
| 349 | GenerateNewWaitingPeriod(); |
| 350 | } else { |
| 351 | // Neither the first time scattering is enabled nor the scattering value |
| 352 | // changed. Nothing to do. |
| 353 | LOG(INFO) << "Keeping current wall-clock waiting period: " << |
| 354 | utils::FormatSecs(omaha_request_params_.waiting_period.InSeconds()); |
| 355 | } |
| 356 | |
| 357 | // The invariant at this point is that omaha_request_params_.waiting_period |
| 358 | // is non-zero no matter which path we took above. |
| 359 | LOG_IF(ERROR, omaha_request_params_.waiting_period.InSeconds() == 0) |
| 360 | << "Waiting Period should NOT be zero at this point!!!"; |
| 361 | |
| 362 | // Since scattering is enabled, wall clock based wait will always be |
| 363 | // enabled. |
| 364 | omaha_request_params_.wall_clock_based_wait_enabled = true; |
| 365 | |
| 366 | // If we don't have any issues in accessing the file system to update |
| 367 | // the update check count value, we'll turn that on as well. |
| 368 | bool decrement_succeeded = DecrementUpdateCheckCount(); |
| 369 | omaha_request_params_.update_check_count_wait_enabled = decrement_succeeded; |
| 370 | } else { |
| 371 | // This means the scattering feature is turned off or disabled for |
| 372 | // this particular update check. Make sure to disable |
| 373 | // all the knobs and artifacts so that we don't invoke any scattering |
| 374 | // related code. |
| 375 | omaha_request_params_.wall_clock_based_wait_enabled = false; |
| 376 | omaha_request_params_.update_check_count_wait_enabled = false; |
| 377 | omaha_request_params_.waiting_period = TimeDelta::FromSeconds(0); |
| 378 | prefs_->Delete(kPrefsWallClockWaitPeriod); |
| 379 | prefs_->Delete(kPrefsUpdateCheckCount); |
| 380 | // Don't delete the UpdateFirstSeenAt file as we don't want manual checks |
| 381 | // that result in no-updates (e.g. due to server side throttling) to |
| 382 | // cause update starvation by having the client generate a new |
| 383 | // UpdateFirstSeenAt for each scheduled check that follows a manual check. |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | void UpdateAttempter::GenerateNewWaitingPeriod() { |
| 388 | omaha_request_params_.waiting_period = TimeDelta::FromSeconds( |
| 389 | base::RandInt(1, scatter_factor_.InSeconds())); |
| 390 | |
| 391 | LOG(INFO) << "Generated new wall-clock waiting period: " << utils::FormatSecs( |
| 392 | omaha_request_params_.waiting_period.InSeconds()); |
| 393 | |
| 394 | // Do a best-effort to persist this in all cases. Even if the persistence |
| 395 | // fails, we'll still be able to scatter based on our in-memory value. |
| 396 | // The persistence only helps in ensuring a good overall distribution |
| 397 | // across multiple devices if they tend to reboot too often. |
| 398 | prefs_->SetInt64(kPrefsWallClockWaitPeriod, |
| 399 | omaha_request_params_.waiting_period.InSeconds()); |
| 400 | } |
| 401 | |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 402 | void UpdateAttempter::BuildUpdateActions(bool interactive) { |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 403 | CHECK(!processor_->IsRunning()); |
| 404 | processor_->set_delegate(this); |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 405 | |
| 406 | // Actions: |
Darin Petkov | a092955 | 2010-11-29 14:19:06 -0800 | [diff] [blame] | 407 | LibcurlHttpFetcher* update_check_fetcher = |
Gilad Arnold | 7c04e76 | 2012-05-23 10:54:02 -0700 | [diff] [blame] | 408 | new LibcurlHttpFetcher(GetProxyResolver(), system_state_, is_test_mode_); |
Andrew de los Reyes | fb2f461 | 2011-06-09 18:21:49 -0700 | [diff] [blame] | 409 | // Try harder to connect to the network, esp when not interactive. |
| 410 | // See comment in libcurl_http_fetcher.cc. |
| 411 | update_check_fetcher->set_no_network_max_retries(interactive ? 1 : 3); |
Bruno Rocha | 7f9aea2 | 2011-09-12 14:31:24 -0700 | [diff] [blame] | 412 | update_check_fetcher->set_check_certificate(CertificateChecker::kUpdate); |
Darin Petkov | 6a5b322 | 2010-07-13 14:55:28 -0700 | [diff] [blame] | 413 | shared_ptr<OmahaRequestAction> update_check_action( |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 414 | new OmahaRequestAction(system_state_, |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 415 | &omaha_request_params_, |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 416 | NULL, |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 417 | update_check_fetcher, // passes ownership |
| 418 | false)); |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 419 | shared_ptr<OmahaResponseHandlerAction> response_handler_action( |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 420 | new OmahaResponseHandlerAction(system_state_)); |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 421 | shared_ptr<FilesystemCopierAction> filesystem_copier_action( |
Gilad Arnold | 581c2ea | 2012-07-19 12:33:49 -0700 | [diff] [blame] | 422 | new FilesystemCopierAction(false, false)); |
Andrew de los Reyes | f971443 | 2010-05-04 10:21:23 -0700 | [diff] [blame] | 423 | shared_ptr<FilesystemCopierAction> kernel_filesystem_copier_action( |
Gilad Arnold | 581c2ea | 2012-07-19 12:33:49 -0700 | [diff] [blame] | 424 | new FilesystemCopierAction(true, false)); |
Darin Petkov | 8c2980e | 2010-07-16 15:16:49 -0700 | [diff] [blame] | 425 | shared_ptr<OmahaRequestAction> download_started_action( |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 426 | new OmahaRequestAction(system_state_, |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 427 | &omaha_request_params_, |
Darin Petkov | 8c2980e | 2010-07-16 15:16:49 -0700 | [diff] [blame] | 428 | new OmahaEvent( |
Darin Petkov | e17f86b | 2010-07-20 09:12:01 -0700 | [diff] [blame] | 429 | OmahaEvent::kTypeUpdateDownloadStarted), |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 430 | new LibcurlHttpFetcher(GetProxyResolver(), |
Gilad Arnold | 7c04e76 | 2012-05-23 10:54:02 -0700 | [diff] [blame] | 431 | system_state_, |
| 432 | is_test_mode_), |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 433 | false)); |
Bruno Rocha | 7f9aea2 | 2011-09-12 14:31:24 -0700 | [diff] [blame] | 434 | LibcurlHttpFetcher* download_fetcher = |
Gilad Arnold | 7c04e76 | 2012-05-23 10:54:02 -0700 | [diff] [blame] | 435 | new LibcurlHttpFetcher(GetProxyResolver(), system_state_, is_test_mode_); |
Bruno Rocha | 7f9aea2 | 2011-09-12 14:31:24 -0700 | [diff] [blame] | 436 | download_fetcher->set_check_certificate(CertificateChecker::kDownload); |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 437 | shared_ptr<DownloadAction> download_action( |
Bruno Rocha | 7f9aea2 | 2011-09-12 14:31:24 -0700 | [diff] [blame] | 438 | new DownloadAction(prefs_, |
Jay Srinivasan | f057205 | 2012-10-23 18:12:56 -0700 | [diff] [blame] | 439 | system_state_, |
Gilad Arnold | 9bedeb5 | 2011-11-17 16:19:57 -0800 | [diff] [blame] | 440 | new MultiRangeHttpFetcher( |
Bruno Rocha | 7f9aea2 | 2011-09-12 14:31:24 -0700 | [diff] [blame] | 441 | download_fetcher))); // passes ownership |
Darin Petkov | 8c2980e | 2010-07-16 15:16:49 -0700 | [diff] [blame] | 442 | shared_ptr<OmahaRequestAction> download_finished_action( |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 443 | new OmahaRequestAction(system_state_, |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 444 | &omaha_request_params_, |
Darin Petkov | 8c2980e | 2010-07-16 15:16:49 -0700 | [diff] [blame] | 445 | new OmahaEvent( |
Darin Petkov | e17f86b | 2010-07-20 09:12:01 -0700 | [diff] [blame] | 446 | OmahaEvent::kTypeUpdateDownloadFinished), |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 447 | new LibcurlHttpFetcher(GetProxyResolver(), |
Gilad Arnold | 7c04e76 | 2012-05-23 10:54:02 -0700 | [diff] [blame] | 448 | system_state_, |
| 449 | is_test_mode_), |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 450 | false)); |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 451 | shared_ptr<FilesystemCopierAction> filesystem_verifier_action( |
Gilad Arnold | 581c2ea | 2012-07-19 12:33:49 -0700 | [diff] [blame] | 452 | new FilesystemCopierAction(false, true)); |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 453 | shared_ptr<FilesystemCopierAction> kernel_filesystem_verifier_action( |
Gilad Arnold | 581c2ea | 2012-07-19 12:33:49 -0700 | [diff] [blame] | 454 | new FilesystemCopierAction(true, true)); |
Darin Petkov | 6d5dbf6 | 2010-11-08 16:09:55 -0800 | [diff] [blame] | 455 | shared_ptr<PostinstallRunnerAction> postinstall_runner_action( |
| 456 | new PostinstallRunnerAction); |
Darin Petkov | 8c2980e | 2010-07-16 15:16:49 -0700 | [diff] [blame] | 457 | shared_ptr<OmahaRequestAction> update_complete_action( |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 458 | new OmahaRequestAction(system_state_, |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 459 | &omaha_request_params_, |
Darin Petkov | e17f86b | 2010-07-20 09:12:01 -0700 | [diff] [blame] | 460 | new OmahaEvent(OmahaEvent::kTypeUpdateComplete), |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 461 | new LibcurlHttpFetcher(GetProxyResolver(), |
Gilad Arnold | 7c04e76 | 2012-05-23 10:54:02 -0700 | [diff] [blame] | 462 | system_state_, |
| 463 | is_test_mode_), |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 464 | false)); |
Darin Petkov | 6a5b322 | 2010-07-13 14:55:28 -0700 | [diff] [blame] | 465 | |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 466 | download_action->set_delegate(this); |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 467 | response_handler_action_ = response_handler_action; |
Darin Petkov | 9b23057 | 2010-10-08 10:20:09 -0700 | [diff] [blame] | 468 | download_action_ = download_action; |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 469 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 470 | actions_.push_back(shared_ptr<AbstractAction>(update_check_action)); |
| 471 | actions_.push_back(shared_ptr<AbstractAction>(response_handler_action)); |
| 472 | actions_.push_back(shared_ptr<AbstractAction>(filesystem_copier_action)); |
Andrew de los Reyes | f918517 | 2010-05-03 11:07:05 -0700 | [diff] [blame] | 473 | actions_.push_back(shared_ptr<AbstractAction>( |
Andrew de los Reyes | f971443 | 2010-05-04 10:21:23 -0700 | [diff] [blame] | 474 | kernel_filesystem_copier_action)); |
Darin Petkov | 8c2980e | 2010-07-16 15:16:49 -0700 | [diff] [blame] | 475 | actions_.push_back(shared_ptr<AbstractAction>(download_started_action)); |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 476 | actions_.push_back(shared_ptr<AbstractAction>(download_action)); |
Darin Petkov | 8c2980e | 2010-07-16 15:16:49 -0700 | [diff] [blame] | 477 | actions_.push_back(shared_ptr<AbstractAction>(download_finished_action)); |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 478 | actions_.push_back(shared_ptr<AbstractAction>(filesystem_verifier_action)); |
| 479 | actions_.push_back(shared_ptr<AbstractAction>( |
| 480 | kernel_filesystem_verifier_action)); |
Darin Petkov | 6d5dbf6 | 2010-11-08 16:09:55 -0800 | [diff] [blame] | 481 | actions_.push_back(shared_ptr<AbstractAction>(postinstall_runner_action)); |
Darin Petkov | 8c2980e | 2010-07-16 15:16:49 -0700 | [diff] [blame] | 482 | actions_.push_back(shared_ptr<AbstractAction>(update_complete_action)); |
Darin Petkov | 6a5b322 | 2010-07-13 14:55:28 -0700 | [diff] [blame] | 483 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 484 | // Enqueue the actions |
| 485 | for (vector<shared_ptr<AbstractAction> >::iterator it = actions_.begin(); |
| 486 | it != actions_.end(); ++it) { |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 487 | processor_->EnqueueAction(it->get()); |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 488 | } |
| 489 | |
| 490 | // Bond them together. We have to use the leaf-types when calling |
| 491 | // BondActions(). |
Andrew de los Reyes | f98bff8 | 2010-05-06 13:33:25 -0700 | [diff] [blame] | 492 | BondActions(update_check_action.get(), |
| 493 | response_handler_action.get()); |
Andrew de los Reyes | f918517 | 2010-05-03 11:07:05 -0700 | [diff] [blame] | 494 | BondActions(response_handler_action.get(), |
Andrew de los Reyes | f98bff8 | 2010-05-06 13:33:25 -0700 | [diff] [blame] | 495 | filesystem_copier_action.get()); |
| 496 | BondActions(filesystem_copier_action.get(), |
Andrew de los Reyes | f971443 | 2010-05-04 10:21:23 -0700 | [diff] [blame] | 497 | kernel_filesystem_copier_action.get()); |
| 498 | BondActions(kernel_filesystem_copier_action.get(), |
Andrew de los Reyes | f918517 | 2010-05-03 11:07:05 -0700 | [diff] [blame] | 499 | download_action.get()); |
Andrew de los Reyes | f98bff8 | 2010-05-06 13:33:25 -0700 | [diff] [blame] | 500 | BondActions(download_action.get(), |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 501 | filesystem_verifier_action.get()); |
| 502 | BondActions(filesystem_verifier_action.get(), |
| 503 | kernel_filesystem_verifier_action.get()); |
| 504 | BondActions(kernel_filesystem_verifier_action.get(), |
Darin Petkov | 6d5dbf6 | 2010-11-08 16:09:55 -0800 | [diff] [blame] | 505 | postinstall_runner_action.get()); |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 506 | } |
| 507 | |
Gilad Arnold | 28e2f39 | 2012-02-09 14:36:46 -0800 | [diff] [blame] | 508 | void UpdateAttempter::CheckForUpdate(const string& app_version, |
Jay Srinivasan | e73acab | 2012-07-10 14:34:03 -0700 | [diff] [blame] | 509 | const string& omaha_url, |
| 510 | bool is_user_initiated) { |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 511 | LOG(INFO) << "New update check requested"; |
| 512 | |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 513 | if (status_ != UPDATE_STATUS_IDLE) { |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 514 | LOG(INFO) << "Skipping update check because current status is " |
| 515 | << UpdateStatusToString(status_); |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 516 | return; |
| 517 | } |
Gilad Arnold | 1ebd813 | 2012-03-05 10:19:29 -0800 | [diff] [blame] | 518 | |
| 519 | // Read GPIO signals and determine whether this is an automated test scenario. |
| 520 | // For safety, we only allow a test update to be performed once; subsequent |
| 521 | // update requests will be carried out normally. |
Gilad Arnold | bf7919b | 2013-01-08 13:07:37 -0800 | [diff] [blame^] | 522 | bool is_test_mode = (!is_test_update_attempted_ && |
| 523 | system_state_->gpio_handler()->IsTestModeSignaled()); |
Gilad Arnold | 7c04e76 | 2012-05-23 10:54:02 -0700 | [diff] [blame] | 524 | if (is_test_mode) { |
| 525 | LOG(WARNING) << "this is a test mode update attempt!"; |
Gilad Arnold | 4d740eb | 2012-05-15 08:48:13 -0700 | [diff] [blame] | 526 | is_test_update_attempted_ = true; |
Gilad Arnold | 1ebd813 | 2012-03-05 10:19:29 -0800 | [diff] [blame] | 527 | } |
| 528 | |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 529 | // Passing true for is_user_initiated to indicate that this |
| 530 | // is not a scheduled update check. |
Gilad Arnold | 7c04e76 | 2012-05-23 10:54:02 -0700 | [diff] [blame] | 531 | Update(app_version, omaha_url, true, true, is_test_mode, is_user_initiated); |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 532 | } |
| 533 | |
Darin Petkov | 296889c | 2010-07-23 16:20:54 -0700 | [diff] [blame] | 534 | bool UpdateAttempter::RebootIfNeeded() { |
| 535 | if (status_ != UPDATE_STATUS_UPDATED_NEED_REBOOT) { |
| 536 | LOG(INFO) << "Reboot requested, but status is " |
| 537 | << UpdateStatusToString(status_) << ", so not rebooting."; |
| 538 | return false; |
| 539 | } |
| 540 | TEST_AND_RETURN_FALSE(utils::Reboot()); |
| 541 | return true; |
| 542 | } |
| 543 | |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 544 | // Delegate methods: |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 545 | void UpdateAttempter::ProcessingDone(const ActionProcessor* processor, |
Darin Petkov | c1a8b42 | 2010-07-19 11:34:49 -0700 | [diff] [blame] | 546 | ActionExitCode code) { |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 547 | CHECK(response_handler_action_); |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 548 | LOG(INFO) << "Processing Done."; |
Andrew de los Reyes | 6b78e29 | 2010-05-10 15:54:39 -0700 | [diff] [blame] | 549 | actions_.clear(); |
Darin Petkov | 09f96c3 | 2010-07-20 09:24:57 -0700 | [diff] [blame] | 550 | |
Chris Sosa | 4f8ee27 | 2012-11-30 13:01:54 -0800 | [diff] [blame] | 551 | // Reset cpu shares back to normal. |
| 552 | CleanupCpuSharesManagement(); |
Darin Petkov | c6c135c | 2010-08-11 13:36:18 -0700 | [diff] [blame] | 553 | |
Darin Petkov | 09f96c3 | 2010-07-20 09:24:57 -0700 | [diff] [blame] | 554 | if (status_ == UPDATE_STATUS_REPORTING_ERROR_EVENT) { |
| 555 | LOG(INFO) << "Error event sent."; |
Gilad Arnold | 1ebd813 | 2012-03-05 10:19:29 -0800 | [diff] [blame] | 556 | |
| 557 | // Inform scheduler of new status; also specifically inform about a failed |
| 558 | // update attempt with a test address. |
| 559 | SetStatusAndNotify(UPDATE_STATUS_IDLE, |
| 560 | (is_using_test_url_ ? kUpdateNoticeTestAddrFailed : |
| 561 | kUpdateNoticeUnspecified)); |
| 562 | |
Andrew de los Reyes | c1d5c93 | 2011-04-20 17:15:47 -0700 | [diff] [blame] | 563 | if (!fake_update_success_) { |
| 564 | return; |
| 565 | } |
| 566 | LOG(INFO) << "Booted from FW B and tried to install new firmware, " |
| 567 | "so requesting reboot from user."; |
Darin Petkov | 09f96c3 | 2010-07-20 09:24:57 -0700 | [diff] [blame] | 568 | } |
| 569 | |
Darin Petkov | c1a8b42 | 2010-07-19 11:34:49 -0700 | [diff] [blame] | 570 | if (code == kActionCodeSuccess) { |
Andrew de los Reyes | 6b78e29 | 2010-05-10 15:54:39 -0700 | [diff] [blame] | 571 | utils::WriteFile(kUpdateCompletedMarker, "", 0); |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 572 | prefs_->SetInt64(kPrefsDeltaUpdateFailures, 0); |
Darin Petkov | 95508da | 2011-01-05 12:42:29 -0800 | [diff] [blame] | 573 | prefs_->SetString(kPrefsPreviousVersion, omaha_request_params_.app_version); |
Darin Petkov | 9b23057 | 2010-10-08 10:20:09 -0700 | [diff] [blame] | 574 | DeltaPerformer::ResetUpdateProgress(prefs_, false); |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 575 | |
| 576 | // Since we're done with scattering fully at this point, this is the |
| 577 | // safest point delete the state files, as we're sure that the status is |
| 578 | // set to reboot (which means no more updates will be applied until reboot) |
| 579 | // This deletion is required for correctness as we want the next update |
| 580 | // check to re-create a new random number for the update check count. |
| 581 | // Similarly, we also delete the wall-clock-wait period that was persisted |
| 582 | // so that we start with a new random value for the next update check |
| 583 | // after reboot so that the same device is not favored or punished in any |
| 584 | // way. |
| 585 | prefs_->Delete(kPrefsUpdateCheckCount); |
| 586 | prefs_->Delete(kPrefsWallClockWaitPeriod); |
Jay Srinivasan | 34b5d86 | 2012-07-23 11:43:22 -0700 | [diff] [blame] | 587 | prefs_->Delete(kPrefsUpdateFirstSeenAt); |
Jay Srinivasan | f057205 | 2012-10-23 18:12:56 -0700 | [diff] [blame] | 588 | LOG(INFO) << "Update successfully applied, waiting to reboot."; |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 589 | |
Gilad Arnold | 1ebd813 | 2012-03-05 10:19:29 -0800 | [diff] [blame] | 590 | SetStatusAndNotify(UPDATE_STATUS_UPDATED_NEED_REBOOT, |
| 591 | kUpdateNoticeUnspecified); |
Darin Petkov | 9d65b7b | 2010-07-20 09:13:01 -0700 | [diff] [blame] | 592 | |
| 593 | // Report the time it took to update the system. |
| 594 | int64_t update_time = time(NULL) - last_checked_time_; |
Andrew de los Reyes | c1d5c93 | 2011-04-20 17:15:47 -0700 | [diff] [blame] | 595 | if (!fake_update_success_) |
Jay Srinivasan | f057205 | 2012-10-23 18:12:56 -0700 | [diff] [blame] | 596 | system_state_->metrics_lib()->SendToUMA( |
| 597 | "Installer.UpdateTime", |
| 598 | static_cast<int>(update_time), // sample |
| 599 | 1, // min = 1 second |
| 600 | 20 * 60, // max = 20 minutes |
| 601 | 50); // buckets |
| 602 | |
| 603 | // Also report the success code so that the percentiles can be |
| 604 | // interpreted properly for the remaining error codes in UMA. |
Jay Srinivasan | edce283 | 2012-10-24 18:57:47 -0700 | [diff] [blame] | 605 | utils::SendErrorCodeToUma(system_state_->metrics_lib(), code); |
Darin Petkov | 09f96c3 | 2010-07-20 09:24:57 -0700 | [diff] [blame] | 606 | return; |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 607 | } |
Darin Petkov | 09f96c3 | 2010-07-20 09:24:57 -0700 | [diff] [blame] | 608 | |
Darin Petkov | 1023a60 | 2010-08-30 13:47:51 -0700 | [diff] [blame] | 609 | if (ScheduleErrorEventAction()) { |
Darin Petkov | 09f96c3 | 2010-07-20 09:24:57 -0700 | [diff] [blame] | 610 | return; |
Darin Petkov | 1023a60 | 2010-08-30 13:47:51 -0700 | [diff] [blame] | 611 | } |
| 612 | LOG(INFO) << "No update."; |
Gilad Arnold | 1ebd813 | 2012-03-05 10:19:29 -0800 | [diff] [blame] | 613 | SetStatusAndNotify(UPDATE_STATUS_IDLE, kUpdateNoticeUnspecified); |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | void UpdateAttempter::ProcessingStopped(const ActionProcessor* processor) { |
Chris Sosa | 4f8ee27 | 2012-11-30 13:01:54 -0800 | [diff] [blame] | 617 | // Reset cpu shares back to normal. |
| 618 | CleanupCpuSharesManagement(); |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 619 | download_progress_ = 0.0; |
Gilad Arnold | 1ebd813 | 2012-03-05 10:19:29 -0800 | [diff] [blame] | 620 | SetStatusAndNotify(UPDATE_STATUS_IDLE, kUpdateNoticeUnspecified); |
Andrew de los Reyes | 6b78e29 | 2010-05-10 15:54:39 -0700 | [diff] [blame] | 621 | actions_.clear(); |
Darin Petkov | 09f96c3 | 2010-07-20 09:24:57 -0700 | [diff] [blame] | 622 | error_event_.reset(NULL); |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | // Called whenever an action has finished processing, either successfully |
| 626 | // or otherwise. |
| 627 | void UpdateAttempter::ActionCompleted(ActionProcessor* processor, |
| 628 | AbstractAction* action, |
Darin Petkov | c1a8b42 | 2010-07-19 11:34:49 -0700 | [diff] [blame] | 629 | ActionExitCode code) { |
Darin Petkov | 1023a60 | 2010-08-30 13:47:51 -0700 | [diff] [blame] | 630 | // Reset download progress regardless of whether or not the download |
| 631 | // action succeeded. Also, get the response code from HTTP request |
| 632 | // actions (update download as well as the initial update check |
| 633 | // actions). |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 634 | const string type = action->Type(); |
Darin Petkov | 1023a60 | 2010-08-30 13:47:51 -0700 | [diff] [blame] | 635 | if (type == DownloadAction::StaticType()) { |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 636 | download_progress_ = 0.0; |
Darin Petkov | 1023a60 | 2010-08-30 13:47:51 -0700 | [diff] [blame] | 637 | DownloadAction* download_action = dynamic_cast<DownloadAction*>(action); |
| 638 | http_response_code_ = download_action->GetHTTPResponseCode(); |
| 639 | } else if (type == OmahaRequestAction::StaticType()) { |
| 640 | OmahaRequestAction* omaha_request_action = |
| 641 | dynamic_cast<OmahaRequestAction*>(action); |
| 642 | // If the request is not an event, then it's the update-check. |
| 643 | if (!omaha_request_action->IsEvent()) { |
| 644 | http_response_code_ = omaha_request_action->GetHTTPResponseCode(); |
Darin Petkov | 85ced13 | 2010-09-01 10:20:56 -0700 | [diff] [blame] | 645 | // Forward the server-dictated poll interval to the update check |
| 646 | // scheduler, if any. |
| 647 | if (update_check_scheduler_) { |
| 648 | update_check_scheduler_->set_poll_interval( |
| 649 | omaha_request_action->GetOutputObject().poll_interval); |
| 650 | } |
Darin Petkov | 1023a60 | 2010-08-30 13:47:51 -0700 | [diff] [blame] | 651 | } |
| 652 | } |
Darin Petkov | 09f96c3 | 2010-07-20 09:24:57 -0700 | [diff] [blame] | 653 | if (code != kActionCodeSuccess) { |
Darin Petkov | 7ed561b | 2011-10-04 02:59:03 -0700 | [diff] [blame] | 654 | // If the current state is at or past the download phase, count the failure |
| 655 | // in case a switch to full update becomes necessary. Ignore network |
| 656 | // transfer timeouts and failures. |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 657 | if (status_ >= UPDATE_STATUS_DOWNLOADING && |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 658 | code != kActionCodeDownloadTransferError) { |
| 659 | MarkDeltaUpdateFailure(); |
| 660 | } |
Darin Petkov | 777dbfa | 2010-07-20 15:03:37 -0700 | [diff] [blame] | 661 | // On failure, schedule an error event to be sent to Omaha. |
| 662 | CreatePendingErrorEvent(action, code); |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 663 | return; |
Darin Petkov | 09f96c3 | 2010-07-20 09:24:57 -0700 | [diff] [blame] | 664 | } |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 665 | // Find out which action completed. |
| 666 | if (type == OmahaResponseHandlerAction::StaticType()) { |
Darin Petkov | 9b23057 | 2010-10-08 10:20:09 -0700 | [diff] [blame] | 667 | // Note that the status will be updated to DOWNLOADING when some bytes get |
| 668 | // actually downloaded from the server and the BytesReceived callback is |
| 669 | // invoked. This avoids notifying the user that a download has started in |
| 670 | // cases when the server and the client are unable to initiate the download. |
| 671 | CHECK(action == response_handler_action_.get()); |
| 672 | const InstallPlan& plan = response_handler_action_->install_plan(); |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 673 | last_checked_time_ = time(NULL); |
| 674 | // TODO(adlr): put version in InstallPlan |
| 675 | new_version_ = "0.0.0.0"; |
Jay Srinivasan | 51dcf26 | 2012-09-13 17:24:32 -0700 | [diff] [blame] | 676 | new_payload_size_ = plan.payload_size; |
Darin Petkov | 9b23057 | 2010-10-08 10:20:09 -0700 | [diff] [blame] | 677 | SetupDownload(); |
Chris Sosa | 4f8ee27 | 2012-11-30 13:01:54 -0800 | [diff] [blame] | 678 | SetupCpuSharesManagement(); |
Gilad Arnold | 1ebd813 | 2012-03-05 10:19:29 -0800 | [diff] [blame] | 679 | SetStatusAndNotify(UPDATE_STATUS_UPDATE_AVAILABLE, |
| 680 | kUpdateNoticeUnspecified); |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 681 | } else if (type == DownloadAction::StaticType()) { |
Gilad Arnold | 1ebd813 | 2012-03-05 10:19:29 -0800 | [diff] [blame] | 682 | SetStatusAndNotify(UPDATE_STATUS_FINALIZING, kUpdateNoticeUnspecified); |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 683 | } |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | // Stop updating. An attempt will be made to record status to the disk |
| 687 | // so that updates can be resumed later. |
| 688 | void UpdateAttempter::Terminate() { |
| 689 | // TODO(adlr): implement this method. |
| 690 | NOTIMPLEMENTED(); |
| 691 | } |
| 692 | |
| 693 | // Try to resume from a previously Terminate()d update. |
| 694 | void UpdateAttempter::ResumeUpdating() { |
| 695 | // TODO(adlr): implement this method. |
| 696 | NOTIMPLEMENTED(); |
| 697 | } |
| 698 | |
Darin Petkov | 9d911fa | 2010-08-19 09:36:08 -0700 | [diff] [blame] | 699 | void UpdateAttempter::SetDownloadStatus(bool active) { |
| 700 | download_active_ = active; |
| 701 | LOG(INFO) << "Download status: " << (active ? "active" : "inactive"); |
| 702 | } |
| 703 | |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 704 | void UpdateAttempter::BytesReceived(uint64_t bytes_received, uint64_t total) { |
Darin Petkov | 9d911fa | 2010-08-19 09:36:08 -0700 | [diff] [blame] | 705 | if (!download_active_) { |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 706 | LOG(ERROR) << "BytesReceived called while not downloading."; |
| 707 | return; |
| 708 | } |
Darin Petkov | af18305 | 2010-08-23 12:07:13 -0700 | [diff] [blame] | 709 | double progress = static_cast<double>(bytes_received) / |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 710 | static_cast<double>(total); |
Darin Petkov | af18305 | 2010-08-23 12:07:13 -0700 | [diff] [blame] | 711 | // Self throttle based on progress. Also send notifications if |
| 712 | // progress is too slow. |
| 713 | const double kDeltaPercent = 0.01; // 1% |
| 714 | if (status_ != UPDATE_STATUS_DOWNLOADING || |
| 715 | bytes_received == total || |
| 716 | progress - download_progress_ >= kDeltaPercent || |
| 717 | TimeTicks::Now() - last_notify_time_ >= TimeDelta::FromSeconds(10)) { |
| 718 | download_progress_ = progress; |
Gilad Arnold | 1ebd813 | 2012-03-05 10:19:29 -0800 | [diff] [blame] | 719 | SetStatusAndNotify(UPDATE_STATUS_DOWNLOADING, kUpdateNoticeUnspecified); |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 720 | } |
| 721 | } |
| 722 | |
Jay Srinivasan | c1ba09a | 2012-08-14 14:15:57 -0700 | [diff] [blame] | 723 | bool UpdateAttempter::ResetStatus() { |
| 724 | LOG(INFO) << "Attempting to reset state from " |
| 725 | << UpdateStatusToString(status_) << " to UPDATE_STATUS_IDLE"; |
| 726 | |
| 727 | switch (status_) { |
| 728 | case UPDATE_STATUS_IDLE: |
| 729 | // no-op. |
| 730 | return true; |
| 731 | |
| 732 | case UPDATE_STATUS_UPDATED_NEED_REBOOT: { |
| 733 | status_ = UPDATE_STATUS_IDLE; |
| 734 | LOG(INFO) << "Reset Successful"; |
| 735 | |
| 736 | // also remove the reboot marker so that if the machine is rebooted |
| 737 | // after resetting to idle state, it doesn't go back to |
| 738 | // UPDATE_STATUS_UPDATED_NEED_REBOOT state. |
| 739 | const FilePath kUpdateCompletedMarkerPath(kUpdateCompletedMarker); |
| 740 | return file_util::Delete(kUpdateCompletedMarkerPath, false); |
| 741 | } |
| 742 | |
| 743 | default: |
| 744 | LOG(ERROR) << "Reset not allowed in this state."; |
| 745 | return false; |
| 746 | } |
| 747 | } |
| 748 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 749 | bool UpdateAttempter::GetStatus(int64_t* last_checked_time, |
| 750 | double* progress, |
Gilad Arnold | 28e2f39 | 2012-02-09 14:36:46 -0800 | [diff] [blame] | 751 | string* current_operation, |
| 752 | string* new_version, |
Jay Srinivasan | 51dcf26 | 2012-09-13 17:24:32 -0700 | [diff] [blame] | 753 | int64_t* new_payload_size) { |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 754 | *last_checked_time = last_checked_time_; |
| 755 | *progress = download_progress_; |
| 756 | *current_operation = UpdateStatusToString(status_); |
| 757 | *new_version = new_version_; |
Jay Srinivasan | 51dcf26 | 2012-09-13 17:24:32 -0700 | [diff] [blame] | 758 | *new_payload_size = new_payload_size_; |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 759 | return true; |
| 760 | } |
| 761 | |
Andrew de los Reyes | 6dbf30a | 2011-04-19 10:58:16 -0700 | [diff] [blame] | 762 | void UpdateAttempter::UpdateBootFlags() { |
Darin Petkov | 58dd134 | 2011-05-06 12:05:13 -0700 | [diff] [blame] | 763 | if (update_boot_flags_running_) { |
| 764 | LOG(INFO) << "Update boot flags running, nothing to do."; |
Andrew de los Reyes | 6dbf30a | 2011-04-19 10:58:16 -0700 | [diff] [blame] | 765 | return; |
| 766 | } |
Darin Petkov | 58dd134 | 2011-05-06 12:05:13 -0700 | [diff] [blame] | 767 | if (updated_boot_flags_) { |
| 768 | LOG(INFO) << "Already updated boot flags. Skipping."; |
| 769 | if (start_action_processor_) { |
| 770 | ScheduleProcessingStart(); |
| 771 | } |
| 772 | return; |
| 773 | } |
| 774 | // This is purely best effort. Failures should be logged by Subprocess. Run |
| 775 | // the script asynchronously to avoid blocking the event loop regardless of |
| 776 | // the script runtime. |
| 777 | update_boot_flags_running_ = true; |
| 778 | LOG(INFO) << "Updating boot flags..."; |
Andrew de los Reyes | 6dbf30a | 2011-04-19 10:58:16 -0700 | [diff] [blame] | 779 | vector<string> cmd(1, "/usr/sbin/chromeos-setgoodkernel"); |
Darin Petkov | 58dd134 | 2011-05-06 12:05:13 -0700 | [diff] [blame] | 780 | if (!Subprocess::Get().Exec(cmd, StaticCompleteUpdateBootFlags, this)) { |
| 781 | CompleteUpdateBootFlags(1); |
| 782 | } |
| 783 | } |
| 784 | |
| 785 | void UpdateAttempter::CompleteUpdateBootFlags(int return_code) { |
| 786 | update_boot_flags_running_ = false; |
Andrew de los Reyes | 6dbf30a | 2011-04-19 10:58:16 -0700 | [diff] [blame] | 787 | updated_boot_flags_ = true; |
Darin Petkov | 58dd134 | 2011-05-06 12:05:13 -0700 | [diff] [blame] | 788 | if (start_action_processor_) { |
| 789 | ScheduleProcessingStart(); |
| 790 | } |
| 791 | } |
| 792 | |
| 793 | void UpdateAttempter::StaticCompleteUpdateBootFlags( |
| 794 | int return_code, |
Gilad Arnold | 28e2f39 | 2012-02-09 14:36:46 -0800 | [diff] [blame] | 795 | const string& output, |
Darin Petkov | 58dd134 | 2011-05-06 12:05:13 -0700 | [diff] [blame] | 796 | void* p) { |
| 797 | reinterpret_cast<UpdateAttempter*>(p)->CompleteUpdateBootFlags(return_code); |
Andrew de los Reyes | 6dbf30a | 2011-04-19 10:58:16 -0700 | [diff] [blame] | 798 | } |
| 799 | |
Darin Petkov | 61635a9 | 2011-05-18 16:20:36 -0700 | [diff] [blame] | 800 | void UpdateAttempter::BroadcastStatus() { |
| 801 | if (!dbus_service_) { |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 802 | return; |
Darin Petkov | 61635a9 | 2011-05-18 16:20:36 -0700 | [diff] [blame] | 803 | } |
Darin Petkov | af18305 | 2010-08-23 12:07:13 -0700 | [diff] [blame] | 804 | last_notify_time_ = TimeTicks::Now(); |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 805 | update_engine_service_emit_status_update( |
| 806 | dbus_service_, |
| 807 | last_checked_time_, |
| 808 | download_progress_, |
| 809 | UpdateStatusToString(status_), |
| 810 | new_version_.c_str(), |
Jay Srinivasan | 51dcf26 | 2012-09-13 17:24:32 -0700 | [diff] [blame] | 811 | new_payload_size_); |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 812 | } |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 813 | |
Gilad Arnold | 1ebd813 | 2012-03-05 10:19:29 -0800 | [diff] [blame] | 814 | void UpdateAttempter::SetStatusAndNotify(UpdateStatus status, |
| 815 | UpdateNotice notice) { |
Darin Petkov | 61635a9 | 2011-05-18 16:20:36 -0700 | [diff] [blame] | 816 | status_ = status; |
| 817 | if (update_check_scheduler_) { |
Gilad Arnold | 1ebd813 | 2012-03-05 10:19:29 -0800 | [diff] [blame] | 818 | update_check_scheduler_->SetUpdateStatus(status_, notice); |
Darin Petkov | 61635a9 | 2011-05-18 16:20:36 -0700 | [diff] [blame] | 819 | } |
| 820 | BroadcastStatus(); |
| 821 | } |
| 822 | |
Darin Petkov | 777dbfa | 2010-07-20 15:03:37 -0700 | [diff] [blame] | 823 | void UpdateAttempter::CreatePendingErrorEvent(AbstractAction* action, |
| 824 | ActionExitCode code) { |
Darin Petkov | 09f96c3 | 2010-07-20 09:24:57 -0700 | [diff] [blame] | 825 | if (error_event_.get()) { |
| 826 | // This shouldn't really happen. |
| 827 | LOG(WARNING) << "There's already an existing pending error event."; |
| 828 | return; |
| 829 | } |
Darin Petkov | 777dbfa | 2010-07-20 15:03:37 -0700 | [diff] [blame] | 830 | |
Darin Petkov | abc7bc0 | 2011-02-23 14:39:43 -0800 | [diff] [blame] | 831 | // For now assume that a generic Omaha response action failure means that |
| 832 | // there's no update so don't send an event. Also, double check that the |
| 833 | // failure has not occurred while sending an error event -- in which case |
| 834 | // don't schedule another. This shouldn't really happen but just in case... |
| 835 | if ((action->Type() == OmahaResponseHandlerAction::StaticType() && |
| 836 | code == kActionCodeError) || |
Darin Petkov | 777dbfa | 2010-07-20 15:03:37 -0700 | [diff] [blame] | 837 | status_ == UPDATE_STATUS_REPORTING_ERROR_EVENT) { |
| 838 | return; |
| 839 | } |
| 840 | |
Jay Srinivasan | 56d5aa4 | 2012-03-26 14:27:59 -0700 | [diff] [blame] | 841 | // Classify the code to generate the appropriate result so that |
| 842 | // the Borgmon charts show up the results correctly. |
| 843 | // Do this before calling GetErrorCodeForAction which could potentially |
| 844 | // augment the bit representation of code and thus cause no matches for |
| 845 | // the switch cases below. |
| 846 | OmahaEvent::Result event_result; |
| 847 | switch (code) { |
| 848 | case kActionCodeOmahaUpdateIgnoredPerPolicy: |
| 849 | case kActionCodeOmahaUpdateDeferredPerPolicy: |
| 850 | event_result = OmahaEvent::kResultUpdateDeferred; |
| 851 | break; |
| 852 | default: |
| 853 | event_result = OmahaEvent::kResultError; |
| 854 | break; |
| 855 | } |
| 856 | |
Darin Petkov | 777dbfa | 2010-07-20 15:03:37 -0700 | [diff] [blame] | 857 | code = GetErrorCodeForAction(action, code); |
Andrew de los Reyes | c1d5c93 | 2011-04-20 17:15:47 -0700 | [diff] [blame] | 858 | fake_update_success_ = code == kActionCodePostinstallBootedFromFirmwareB; |
Darin Petkov | 18c7bce | 2011-06-16 14:07:00 -0700 | [diff] [blame] | 859 | |
| 860 | // Apply the bit modifiers to the error code. |
| 861 | if (!utils::IsNormalBootMode()) { |
| 862 | code = static_cast<ActionExitCode>(code | kActionCodeBootModeFlag); |
| 863 | } |
| 864 | if (response_handler_action_.get() && |
| 865 | response_handler_action_->install_plan().is_resume) { |
| 866 | code = static_cast<ActionExitCode>(code | kActionCodeResumedFlag); |
| 867 | } |
Jay Srinivasan | 56d5aa4 | 2012-03-26 14:27:59 -0700 | [diff] [blame] | 868 | |
Darin Petkov | 09f96c3 | 2010-07-20 09:24:57 -0700 | [diff] [blame] | 869 | error_event_.reset(new OmahaEvent(OmahaEvent::kTypeUpdateComplete, |
Jay Srinivasan | 56d5aa4 | 2012-03-26 14:27:59 -0700 | [diff] [blame] | 870 | event_result, |
Darin Petkov | 09f96c3 | 2010-07-20 09:24:57 -0700 | [diff] [blame] | 871 | code)); |
| 872 | } |
| 873 | |
| 874 | bool UpdateAttempter::ScheduleErrorEventAction() { |
| 875 | if (error_event_.get() == NULL) |
| 876 | return false; |
| 877 | |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 878 | LOG(ERROR) << "Update failed."; |
| 879 | system_state_->payload_state()->UpdateFailed(error_event_->error_code); |
| 880 | |
| 881 | LOG(INFO) << "Reporting the error event"; |
Jay Srinivasan | edce283 | 2012-10-24 18:57:47 -0700 | [diff] [blame] | 882 | utils::SendErrorCodeToUma(system_state_->metrics_lib(), |
Jay Srinivasan | f057205 | 2012-10-23 18:12:56 -0700 | [diff] [blame] | 883 | error_event_->error_code); |
Darin Petkov | 09f96c3 | 2010-07-20 09:24:57 -0700 | [diff] [blame] | 884 | shared_ptr<OmahaRequestAction> error_event_action( |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 885 | new OmahaRequestAction(system_state_, |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 886 | &omaha_request_params_, |
Darin Petkov | 09f96c3 | 2010-07-20 09:24:57 -0700 | [diff] [blame] | 887 | error_event_.release(), // Pass ownership. |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 888 | new LibcurlHttpFetcher(GetProxyResolver(), |
Gilad Arnold | 7c04e76 | 2012-05-23 10:54:02 -0700 | [diff] [blame] | 889 | system_state_, |
| 890 | is_test_mode_), |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 891 | false)); |
Darin Petkov | 09f96c3 | 2010-07-20 09:24:57 -0700 | [diff] [blame] | 892 | actions_.push_back(shared_ptr<AbstractAction>(error_event_action)); |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 893 | processor_->EnqueueAction(error_event_action.get()); |
Gilad Arnold | 1ebd813 | 2012-03-05 10:19:29 -0800 | [diff] [blame] | 894 | SetStatusAndNotify(UPDATE_STATUS_REPORTING_ERROR_EVENT, |
| 895 | kUpdateNoticeUnspecified); |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 896 | processor_->StartProcessing(); |
Darin Petkov | 09f96c3 | 2010-07-20 09:24:57 -0700 | [diff] [blame] | 897 | return true; |
| 898 | } |
| 899 | |
Chris Sosa | 4f8ee27 | 2012-11-30 13:01:54 -0800 | [diff] [blame] | 900 | void UpdateAttempter::SetCpuShares(utils::CpuShares shares) { |
| 901 | if (shares_ == shares) { |
Darin Petkov | c6c135c | 2010-08-11 13:36:18 -0700 | [diff] [blame] | 902 | return; |
| 903 | } |
Chris Sosa | 4f8ee27 | 2012-11-30 13:01:54 -0800 | [diff] [blame] | 904 | if (utils::SetCpuShares(shares)) { |
| 905 | shares_ = shares; |
| 906 | LOG(INFO) << "CPU shares = " << shares_; |
Darin Petkov | c6c135c | 2010-08-11 13:36:18 -0700 | [diff] [blame] | 907 | } |
| 908 | } |
| 909 | |
Chris Sosa | 4f8ee27 | 2012-11-30 13:01:54 -0800 | [diff] [blame] | 910 | void UpdateAttempter::SetupCpuSharesManagement() { |
| 911 | if (manage_shares_source_) { |
| 912 | LOG(ERROR) << "Cpu shares timeout source hasn't been destroyed."; |
| 913 | CleanupCpuSharesManagement(); |
Darin Petkov | c6c135c | 2010-08-11 13:36:18 -0700 | [diff] [blame] | 914 | } |
Chris Sosa | 4f8ee27 | 2012-11-30 13:01:54 -0800 | [diff] [blame] | 915 | const int kCpuSharesTimeout = 2 * 60 * 60; // 2 hours |
| 916 | manage_shares_source_ = g_timeout_source_new_seconds(kCpuSharesTimeout); |
| 917 | g_source_set_callback(manage_shares_source_, |
| 918 | StaticManageCpuSharesCallback, |
Darin Petkov | c6c135c | 2010-08-11 13:36:18 -0700 | [diff] [blame] | 919 | this, |
| 920 | NULL); |
Chris Sosa | 4f8ee27 | 2012-11-30 13:01:54 -0800 | [diff] [blame] | 921 | g_source_attach(manage_shares_source_, NULL); |
| 922 | SetCpuShares(utils::kCpuSharesLow); |
Darin Petkov | c6c135c | 2010-08-11 13:36:18 -0700 | [diff] [blame] | 923 | } |
| 924 | |
Chris Sosa | 4f8ee27 | 2012-11-30 13:01:54 -0800 | [diff] [blame] | 925 | void UpdateAttempter::CleanupCpuSharesManagement() { |
| 926 | if (manage_shares_source_) { |
| 927 | g_source_destroy(manage_shares_source_); |
| 928 | manage_shares_source_ = NULL; |
Darin Petkov | c6c135c | 2010-08-11 13:36:18 -0700 | [diff] [blame] | 929 | } |
Chris Sosa | 4f8ee27 | 2012-11-30 13:01:54 -0800 | [diff] [blame] | 930 | SetCpuShares(utils::kCpuSharesNormal); |
Darin Petkov | c6c135c | 2010-08-11 13:36:18 -0700 | [diff] [blame] | 931 | } |
| 932 | |
Chris Sosa | 4f8ee27 | 2012-11-30 13:01:54 -0800 | [diff] [blame] | 933 | gboolean UpdateAttempter::StaticManageCpuSharesCallback(gpointer data) { |
| 934 | return reinterpret_cast<UpdateAttempter*>(data)->ManageCpuSharesCallback(); |
Darin Petkov | c6c135c | 2010-08-11 13:36:18 -0700 | [diff] [blame] | 935 | } |
| 936 | |
Darin Petkov | e6ef2f8 | 2011-03-07 17:31:11 -0800 | [diff] [blame] | 937 | gboolean UpdateAttempter::StaticStartProcessing(gpointer data) { |
| 938 | reinterpret_cast<UpdateAttempter*>(data)->processor_->StartProcessing(); |
| 939 | return FALSE; // Don't call this callback again. |
| 940 | } |
| 941 | |
Darin Petkov | 58dd134 | 2011-05-06 12:05:13 -0700 | [diff] [blame] | 942 | void UpdateAttempter::ScheduleProcessingStart() { |
| 943 | LOG(INFO) << "Scheduling an action processor start."; |
| 944 | start_action_processor_ = false; |
| 945 | g_idle_add(&StaticStartProcessing, this); |
| 946 | } |
| 947 | |
Chris Sosa | 4f8ee27 | 2012-11-30 13:01:54 -0800 | [diff] [blame] | 948 | bool UpdateAttempter::ManageCpuSharesCallback() { |
| 949 | SetCpuShares(utils::kCpuSharesNormal); |
| 950 | manage_shares_source_ = NULL; |
Darin Petkov | f622ef7 | 2010-10-26 13:49:24 -0700 | [diff] [blame] | 951 | return false; // Destroy the timeout source. |
Darin Petkov | c6c135c | 2010-08-11 13:36:18 -0700 | [diff] [blame] | 952 | } |
| 953 | |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 954 | void UpdateAttempter::DisableDeltaUpdateIfNeeded() { |
| 955 | int64_t delta_failures; |
| 956 | if (omaha_request_params_.delta_okay && |
| 957 | prefs_->GetInt64(kPrefsDeltaUpdateFailures, &delta_failures) && |
| 958 | delta_failures >= kMaxDeltaUpdateFailures) { |
| 959 | LOG(WARNING) << "Too many delta update failures, forcing full update."; |
| 960 | omaha_request_params_.delta_okay = false; |
| 961 | } |
| 962 | } |
| 963 | |
| 964 | void UpdateAttempter::MarkDeltaUpdateFailure() { |
Darin Petkov | 2dd0109 | 2010-10-08 15:43:05 -0700 | [diff] [blame] | 965 | // Don't try to resume a failed delta update. |
| 966 | DeltaPerformer::ResetUpdateProgress(prefs_, false); |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 967 | int64_t delta_failures; |
| 968 | if (!prefs_->GetInt64(kPrefsDeltaUpdateFailures, &delta_failures) || |
| 969 | delta_failures < 0) { |
| 970 | delta_failures = 0; |
| 971 | } |
| 972 | prefs_->SetInt64(kPrefsDeltaUpdateFailures, ++delta_failures); |
| 973 | } |
| 974 | |
Darin Petkov | 9b23057 | 2010-10-08 10:20:09 -0700 | [diff] [blame] | 975 | void UpdateAttempter::SetupDownload() { |
Gilad Arnold | 9bedeb5 | 2011-11-17 16:19:57 -0800 | [diff] [blame] | 976 | MultiRangeHttpFetcher* fetcher = |
| 977 | dynamic_cast<MultiRangeHttpFetcher*>(download_action_->http_fetcher()); |
Andrew de los Reyes | 819fef2 | 2010-12-17 11:33:58 -0800 | [diff] [blame] | 978 | fetcher->ClearRanges(); |
Darin Petkov | 9b23057 | 2010-10-08 10:20:09 -0700 | [diff] [blame] | 979 | if (response_handler_action_->install_plan().is_resume) { |
Darin Petkov | b21ce5d | 2010-10-21 16:03:05 -0700 | [diff] [blame] | 980 | // Resuming an update so fetch the update manifest metadata first. |
Darin Petkov | 9b23057 | 2010-10-08 10:20:09 -0700 | [diff] [blame] | 981 | int64_t manifest_metadata_size = 0; |
| 982 | prefs_->GetInt64(kPrefsManifestMetadataSize, &manifest_metadata_size); |
Andrew de los Reyes | 819fef2 | 2010-12-17 11:33:58 -0800 | [diff] [blame] | 983 | fetcher->AddRange(0, manifest_metadata_size); |
Darin Petkov | b21ce5d | 2010-10-21 16:03:05 -0700 | [diff] [blame] | 984 | // If there're remaining unprocessed data blobs, fetch them. Be careful not |
| 985 | // to request data beyond the end of the payload to avoid 416 HTTP response |
| 986 | // error codes. |
Darin Petkov | 9b23057 | 2010-10-08 10:20:09 -0700 | [diff] [blame] | 987 | int64_t next_data_offset = 0; |
| 988 | prefs_->GetInt64(kPrefsUpdateStateNextDataOffset, &next_data_offset); |
Darin Petkov | b21ce5d | 2010-10-21 16:03:05 -0700 | [diff] [blame] | 989 | uint64_t resume_offset = manifest_metadata_size + next_data_offset; |
Jay Srinivasan | 51dcf26 | 2012-09-13 17:24:32 -0700 | [diff] [blame] | 990 | if (resume_offset < response_handler_action_->install_plan().payload_size) { |
Gilad Arnold | e4ad250 | 2011-12-29 17:08:54 -0800 | [diff] [blame] | 991 | fetcher->AddRange(resume_offset); |
Darin Petkov | b21ce5d | 2010-10-21 16:03:05 -0700 | [diff] [blame] | 992 | } |
Darin Petkov | 9b23057 | 2010-10-08 10:20:09 -0700 | [diff] [blame] | 993 | } else { |
Gilad Arnold | e4ad250 | 2011-12-29 17:08:54 -0800 | [diff] [blame] | 994 | fetcher->AddRange(0); |
Darin Petkov | 9b23057 | 2010-10-08 10:20:09 -0700 | [diff] [blame] | 995 | } |
Darin Petkov | 9b23057 | 2010-10-08 10:20:09 -0700 | [diff] [blame] | 996 | } |
| 997 | |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 998 | void UpdateAttempter::PingOmaha() { |
Thieu Le | d88a857 | 2011-05-26 09:09:19 -0700 | [diff] [blame] | 999 | if (!processor_->IsRunning()) { |
| 1000 | shared_ptr<OmahaRequestAction> ping_action( |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 1001 | new OmahaRequestAction(system_state_, |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 1002 | &omaha_request_params_, |
Thieu Le | d88a857 | 2011-05-26 09:09:19 -0700 | [diff] [blame] | 1003 | NULL, |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 1004 | new LibcurlHttpFetcher(GetProxyResolver(), |
Gilad Arnold | 7c04e76 | 2012-05-23 10:54:02 -0700 | [diff] [blame] | 1005 | system_state_, |
| 1006 | is_test_mode_), |
Thieu Le | d88a857 | 2011-05-26 09:09:19 -0700 | [diff] [blame] | 1007 | true)); |
| 1008 | actions_.push_back(shared_ptr<OmahaRequestAction>(ping_action)); |
| 1009 | processor_->set_delegate(NULL); |
| 1010 | processor_->EnqueueAction(ping_action.get()); |
| 1011 | // Call StartProcessing() synchronously here to avoid any race conditions |
| 1012 | // caused by multiple outstanding ping Omaha requests. If we call |
| 1013 | // StartProcessing() asynchronously, the device can be suspended before we |
| 1014 | // get a chance to callback to StartProcessing(). When the device resumes |
| 1015 | // (assuming the device sleeps longer than the next update check period), |
| 1016 | // StartProcessing() is called back and at the same time, the next update |
| 1017 | // check is fired which eventually invokes StartProcessing(). A crash |
| 1018 | // can occur because StartProcessing() checks to make sure that the |
| 1019 | // processor is idle which it isn't due to the two concurrent ping Omaha |
| 1020 | // requests. |
| 1021 | processor_->StartProcessing(); |
| 1022 | } else { |
Darin Petkov | 58dd134 | 2011-05-06 12:05:13 -0700 | [diff] [blame] | 1023 | LOG(WARNING) << "Action processor running, Omaha ping suppressed."; |
Darin Petkov | 58dd134 | 2011-05-06 12:05:13 -0700 | [diff] [blame] | 1024 | } |
Thieu Le | d88a857 | 2011-05-26 09:09:19 -0700 | [diff] [blame] | 1025 | |
| 1026 | // Update the status which will schedule the next update check |
Gilad Arnold | 1ebd813 | 2012-03-05 10:19:29 -0800 | [diff] [blame] | 1027 | SetStatusAndNotify(UPDATE_STATUS_UPDATED_NEED_REBOOT, |
| 1028 | kUpdateNoticeUnspecified); |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 1029 | } |
| 1030 | |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 1031 | |
| 1032 | bool UpdateAttempter::DecrementUpdateCheckCount() { |
| 1033 | int64 update_check_count_value; |
| 1034 | |
| 1035 | if (!prefs_->Exists(kPrefsUpdateCheckCount)) { |
| 1036 | // This file does not exist. This means we haven't started our update |
| 1037 | // check count down yet, so nothing more to do. This file will be created |
| 1038 | // later when we first satisfy the wall-clock-based-wait period. |
| 1039 | LOG(INFO) << "No existing update check count. That's normal."; |
| 1040 | return true; |
| 1041 | } |
| 1042 | |
| 1043 | if (prefs_->GetInt64(kPrefsUpdateCheckCount, &update_check_count_value)) { |
| 1044 | // Only if we're able to read a proper integer value, then go ahead |
| 1045 | // and decrement and write back the result in the same file, if needed. |
| 1046 | LOG(INFO) << "Update check count = " << update_check_count_value; |
| 1047 | |
| 1048 | if (update_check_count_value == 0) { |
| 1049 | // It could be 0, if, for some reason, the file didn't get deleted |
| 1050 | // when we set our status to waiting for reboot. so we just leave it |
| 1051 | // as is so that we can prevent another update_check wait for this client. |
| 1052 | LOG(INFO) << "Not decrementing update check count as it's already 0."; |
| 1053 | return true; |
| 1054 | } |
| 1055 | |
| 1056 | if (update_check_count_value > 0) |
| 1057 | update_check_count_value--; |
| 1058 | else |
| 1059 | update_check_count_value = 0; |
| 1060 | |
| 1061 | // Write out the new value of update_check_count_value. |
| 1062 | if (prefs_->SetInt64(kPrefsUpdateCheckCount, update_check_count_value)) { |
| 1063 | // We successfully wrote out te new value, so enable the |
| 1064 | // update check based wait. |
| 1065 | LOG(INFO) << "New update check count = " << update_check_count_value; |
| 1066 | return true; |
| 1067 | } |
| 1068 | } |
| 1069 | |
| 1070 | LOG(INFO) << "Deleting update check count state due to read/write errors."; |
| 1071 | |
| 1072 | // We cannot read/write to the file, so disable the update check based wait |
| 1073 | // so that we don't get stuck in this OS version by any chance (which could |
| 1074 | // happen if there's some bug that causes to read/write incorrectly). |
| 1075 | // Also attempt to delete the file to do our best effort to cleanup. |
| 1076 | prefs_->Delete(kPrefsUpdateCheckCount); |
| 1077 | return false; |
| 1078 | } |
| 1079 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 1080 | } // namespace chromeos_update_engine |