Chromium Code Reviews| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 | 121 |
| 122 UpdateAttempter::~UpdateAttempter() { | 122 UpdateAttempter::~UpdateAttempter() { |
| 123 CleanupPriorityManagement(); | 123 CleanupPriorityManagement(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void UpdateAttempter::Update(const std::string& app_version, | 126 void UpdateAttempter::Update(const std::string& app_version, |
| 127 const std::string& omaha_url, | 127 const std::string& omaha_url, |
| 128 bool obey_proxies) { | 128 bool obey_proxies) { |
| 129 chrome_proxy_resolver_.Init(); | 129 chrome_proxy_resolver_.Init(); |
| 130 if (status_ == UPDATE_STATUS_UPDATED_NEED_REBOOT) { | 130 if (status_ == UPDATE_STATUS_UPDATED_NEED_REBOOT) { |
| 131 // Although we have applied an update, we still want to ping Omaha | |
| 132 // to ensure the number of active statistics is accurate. | |
| 131 LOG(INFO) << "Not updating b/c we already updated and we're waiting for " | 133 LOG(INFO) << "Not updating b/c we already updated and we're waiting for " |
| 132 << "reboot"; | 134 << "reboot, we'll ping Omaha instead"; |
| 135 PingOmaha(); | |
| 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; |
| 140 if (!omaha_request_params_.Init(app_version, omaha_url)) { | 143 if (!omaha_request_params_.Init(app_version, omaha_url)) { |
| 141 LOG(ERROR) << "Unable to initialize Omaha request device params."; | 144 LOG(ERROR) << "Unable to initialize Omaha request device params."; |
| 142 return; | 145 return; |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 prefs_->GetInt64(kPrefsUpdateStateNextDataOffset, &next_data_offset); | 598 prefs_->GetInt64(kPrefsUpdateStateNextDataOffset, &next_data_offset); |
| 596 uint64_t resume_offset = manifest_metadata_size + next_data_offset; | 599 uint64_t resume_offset = manifest_metadata_size + next_data_offset; |
| 597 if (resume_offset < response_handler_action_->install_plan().size) { | 600 if (resume_offset < response_handler_action_->install_plan().size) { |
| 598 fetcher->AddRange(resume_offset, -1); | 601 fetcher->AddRange(resume_offset, -1); |
| 599 } | 602 } |
| 600 } else { | 603 } else { |
| 601 fetcher->AddRange(0, -1); | 604 fetcher->AddRange(0, -1); |
| 602 } | 605 } |
| 603 } | 606 } |
| 604 | 607 |
| 608 void UpdateAttempter::PingOmaha() { | |
| 609 shared_ptr<OmahaRequestAction> ping_action( | |
| 610 new OmahaRequestAction(prefs_, | |
| 611 omaha_request_params_, | |
| 612 NULL, | |
| 613 new LibcurlHttpFetcher(GetProxyResolver()), | |
| 614 true)); | |
| 615 actions_.push_back(shared_ptr<OmahaRequestAction>(ping_action)); | |
| 616 CHECK(!processor_->IsRunning()); | |
| 617 processor_->set_delegate(NULL); | |
| 618 processor_->EnqueueAction(ping_action.get()); | |
| 619 processor_->StartProcessing(); | |
|
adlr
2011/04/15 22:04:51
the other thing that starts processing uses g_idle
thieule
2011/04/15 23:32:57
Done.
| |
| 620 SetStatusAndNotify(UPDATE_STATUS_UPDATED_NEED_REBOOT); | |
| 621 } | |
| 622 | |
| 605 } // namespace chromeos_update_engine | 623 } // namespace chromeos_update_engine |
| OLD | NEW |