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 #include "update_engine/update_attempter.h" | 5 #include "update_engine/update_attempter.h" |
6 | 6 |
7 // From 'man clock_gettime': feature test macro: _POSIX_C_SOURCE >= 199309L | 7 // From 'man clock_gettime': feature test macro: _POSIX_C_SOURCE >= 199309L |
8 #ifndef _POSIX_C_SOURCE | 8 #ifndef _POSIX_C_SOURCE |
9 #define _POSIX_C_SOURCE 199309L | 9 #define _POSIX_C_SOURCE 199309L |
10 #endif // _POSIX_C_SOURCE | 10 #endif // _POSIX_C_SOURCE |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "update_engine/dbus_service.h" | 21 #include "update_engine/dbus_service.h" |
22 #include "update_engine/download_action.h" | 22 #include "update_engine/download_action.h" |
23 #include "update_engine/filesystem_copier_action.h" | 23 #include "update_engine/filesystem_copier_action.h" |
24 #include "update_engine/libcurl_http_fetcher.h" | 24 #include "update_engine/libcurl_http_fetcher.h" |
25 #include "update_engine/multi_range_http_fetcher.h" | 25 #include "update_engine/multi_range_http_fetcher.h" |
26 #include "update_engine/omaha_request_action.h" | 26 #include "update_engine/omaha_request_action.h" |
27 #include "update_engine/omaha_request_params.h" | 27 #include "update_engine/omaha_request_params.h" |
28 #include "update_engine/omaha_response_handler_action.h" | 28 #include "update_engine/omaha_response_handler_action.h" |
29 #include "update_engine/postinstall_runner_action.h" | 29 #include "update_engine/postinstall_runner_action.h" |
30 #include "update_engine/prefs_interface.h" | 30 #include "update_engine/prefs_interface.h" |
| 31 #include "update_engine/subprocess.h" |
31 #include "update_engine/update_check_scheduler.h" | 32 #include "update_engine/update_check_scheduler.h" |
32 | 33 |
33 using base::TimeDelta; | 34 using base::TimeDelta; |
34 using base::TimeTicks; | 35 using base::TimeTicks; |
35 using google::protobuf::NewPermanentCallback; | 36 using google::protobuf::NewPermanentCallback; |
36 using std::make_pair; | 37 using std::make_pair; |
37 using std::tr1::shared_ptr; | 38 using std::tr1::shared_ptr; |
38 using std::string; | 39 using std::string; |
39 using std::vector; | 40 using std::vector; |
40 | 41 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 manage_priority_source_(NULL), | 108 manage_priority_source_(NULL), |
108 download_active_(false), | 109 download_active_(false), |
109 status_(UPDATE_STATUS_IDLE), | 110 status_(UPDATE_STATUS_IDLE), |
110 download_progress_(0.0), | 111 download_progress_(0.0), |
111 last_checked_time_(0), | 112 last_checked_time_(0), |
112 new_version_("0.0.0.0"), | 113 new_version_("0.0.0.0"), |
113 new_size_(0), | 114 new_size_(0), |
114 is_full_update_(false), | 115 is_full_update_(false), |
115 proxy_manual_checks_(0), | 116 proxy_manual_checks_(0), |
116 obeying_proxies_(true), | 117 obeying_proxies_(true), |
117 chrome_proxy_resolver_(dbus_iface) { | 118 chrome_proxy_resolver_(dbus_iface), |
| 119 updated_boot_flags_(false) { |
118 if (utils::FileExists(kUpdateCompletedMarker)) | 120 if (utils::FileExists(kUpdateCompletedMarker)) |
119 status_ = UPDATE_STATUS_UPDATED_NEED_REBOOT; | 121 status_ = UPDATE_STATUS_UPDATED_NEED_REBOOT; |
120 } | 122 } |
121 | 123 |
122 UpdateAttempter::~UpdateAttempter() { | 124 UpdateAttempter::~UpdateAttempter() { |
123 CleanupPriorityManagement(); | 125 CleanupPriorityManagement(); |
124 } | 126 } |
125 | 127 |
126 void UpdateAttempter::Update(const std::string& app_version, | 128 void UpdateAttempter::Update(const std::string& app_version, |
127 const std::string& omaha_url, | 129 const std::string& omaha_url, |
128 bool obey_proxies) { | 130 bool obey_proxies) { |
129 chrome_proxy_resolver_.Init(); | 131 chrome_proxy_resolver_.Init(); |
| 132 UpdateBootFlags(); // Just in case we didn't do this yet. |
130 if (status_ == UPDATE_STATUS_UPDATED_NEED_REBOOT) { | 133 if (status_ == UPDATE_STATUS_UPDATED_NEED_REBOOT) { |
131 LOG(INFO) << "Not updating b/c we already updated and we're waiting for " | 134 LOG(INFO) << "Not updating b/c we already updated and we're waiting for " |
132 << "reboot"; | 135 << "reboot"; |
133 return; | 136 return; |
134 } | 137 } |
135 if (status_ != UPDATE_STATUS_IDLE) { | 138 if (status_ != UPDATE_STATUS_IDLE) { |
136 // Update in progress. Do nothing | 139 // Update in progress. Do nothing |
137 return; | 140 return; |
138 } | 141 } |
139 http_response_code_ = 0; | 142 http_response_code_ = 0; |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 std::string* new_version, | 447 std::string* new_version, |
445 int64_t* new_size) { | 448 int64_t* new_size) { |
446 *last_checked_time = last_checked_time_; | 449 *last_checked_time = last_checked_time_; |
447 *progress = download_progress_; | 450 *progress = download_progress_; |
448 *current_operation = UpdateStatusToString(status_); | 451 *current_operation = UpdateStatusToString(status_); |
449 *new_version = new_version_; | 452 *new_version = new_version_; |
450 *new_size = new_size_; | 453 *new_size = new_size_; |
451 return true; | 454 return true; |
452 } | 455 } |
453 | 456 |
| 457 void UpdateAttempter::UpdateBootFlags() { |
| 458 if (updated_boot_flags_) { |
| 459 LOG(INFO) << "Already updated boot flags. Skipping."; |
| 460 return; |
| 461 } |
| 462 // This is purely best effort. Failures should be logged by Subprocess. |
| 463 int unused = 0; |
| 464 vector<string> cmd(1, "/usr/sbin/chromeos-setgoodkernel"); |
| 465 Subprocess::SynchronousExec(cmd, &unused); |
| 466 updated_boot_flags_ = true; |
| 467 return; |
| 468 } |
| 469 |
454 void UpdateAttempter::SetStatusAndNotify(UpdateStatus status) { | 470 void UpdateAttempter::SetStatusAndNotify(UpdateStatus status) { |
455 status_ = status; | 471 status_ = status; |
456 if (update_check_scheduler_) { | 472 if (update_check_scheduler_) { |
457 update_check_scheduler_->SetUpdateStatus(status_); | 473 update_check_scheduler_->SetUpdateStatus(status_); |
458 } | 474 } |
459 if (!dbus_service_) | 475 if (!dbus_service_) |
460 return; | 476 return; |
461 last_notify_time_ = TimeTicks::Now(); | 477 last_notify_time_ = TimeTicks::Now(); |
462 update_engine_service_emit_status_update( | 478 update_engine_service_emit_status_update( |
463 dbus_service_, | 479 dbus_service_, |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 uint64_t resume_offset = manifest_metadata_size + next_data_offset; | 612 uint64_t resume_offset = manifest_metadata_size + next_data_offset; |
597 if (resume_offset < response_handler_action_->install_plan().size) { | 613 if (resume_offset < response_handler_action_->install_plan().size) { |
598 fetcher->AddRange(resume_offset, -1); | 614 fetcher->AddRange(resume_offset, -1); |
599 } | 615 } |
600 } else { | 616 } else { |
601 fetcher->AddRange(0, -1); | 617 fetcher->AddRange(0, -1); |
602 } | 618 } |
603 } | 619 } |
604 | 620 |
605 } // namespace chromeos_update_engine | 621 } // namespace chromeos_update_engine |
OLD | NEW |