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 |
11 #include <time.h> | 11 #include <time.h> |
12 | 12 |
13 #include <tr1/memory> | 13 #include <tr1/memory> |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 #include <glib.h> | 16 #include <glib.h> |
17 #include "update_engine/dbus_service.h" | 17 #include "update_engine/dbus_service.h" |
18 #include "update_engine/download_action.h" | 18 #include "update_engine/download_action.h" |
19 #include "update_engine/filesystem_copier_action.h" | 19 #include "update_engine/filesystem_copier_action.h" |
20 #include "update_engine/libcurl_http_fetcher.h" | 20 #include "update_engine/libcurl_http_fetcher.h" |
| 21 #include "update_engine/omaha_request_action.h" |
21 #include "update_engine/omaha_request_prep_action.h" | 22 #include "update_engine/omaha_request_prep_action.h" |
22 #include "update_engine/omaha_response_handler_action.h" | 23 #include "update_engine/omaha_response_handler_action.h" |
23 #include "update_engine/postinstall_runner_action.h" | 24 #include "update_engine/postinstall_runner_action.h" |
24 #include "update_engine/set_bootable_flag_action.h" | 25 #include "update_engine/set_bootable_flag_action.h" |
25 #include "update_engine/update_check_action.h" | |
26 | 26 |
27 using std::tr1::shared_ptr; | 27 using std::tr1::shared_ptr; |
28 using std::string; | 28 using std::string; |
29 using std::vector; | 29 using std::vector; |
30 | 30 |
31 namespace chromeos_update_engine { | 31 namespace chromeos_update_engine { |
32 | 32 |
33 const char* kUpdateCompletedMarker = "/tmp/update_engine_autoupdate_completed"; | 33 const char* kUpdateCompletedMarker = "/tmp/update_engine_autoupdate_completed"; |
34 | 34 |
35 namespace { | 35 namespace { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // Update in progress. Do nothing | 95 // Update in progress. Do nothing |
96 return; | 96 return; |
97 } | 97 } |
98 full_update_ = force_full_update; | 98 full_update_ = force_full_update; |
99 CHECK(!processor_.IsRunning()); | 99 CHECK(!processor_.IsRunning()); |
100 processor_.set_delegate(this); | 100 processor_.set_delegate(this); |
101 | 101 |
102 // Actions: | 102 // Actions: |
103 shared_ptr<OmahaRequestPrepAction> request_prep_action( | 103 shared_ptr<OmahaRequestPrepAction> request_prep_action( |
104 new OmahaRequestPrepAction(force_full_update)); | 104 new OmahaRequestPrepAction(force_full_update)); |
105 shared_ptr<UpdateCheckAction> update_check_action( | 105 shared_ptr<OmahaRequestAction> update_check_action( |
106 new UpdateCheckAction(new LibcurlHttpFetcher)); | 106 new OmahaRequestAction(new LibcurlHttpFetcher)); |
107 shared_ptr<OmahaResponseHandlerAction> response_handler_action( | 107 shared_ptr<OmahaResponseHandlerAction> response_handler_action( |
108 new OmahaResponseHandlerAction); | 108 new OmahaResponseHandlerAction); |
109 shared_ptr<FilesystemCopierAction> filesystem_copier_action( | 109 shared_ptr<FilesystemCopierAction> filesystem_copier_action( |
110 new FilesystemCopierAction(false)); | 110 new FilesystemCopierAction(false)); |
111 shared_ptr<FilesystemCopierAction> kernel_filesystem_copier_action( | 111 shared_ptr<FilesystemCopierAction> kernel_filesystem_copier_action( |
112 new FilesystemCopierAction(true)); | 112 new FilesystemCopierAction(true)); |
113 shared_ptr<DownloadAction> download_action( | 113 shared_ptr<DownloadAction> download_action( |
114 new DownloadAction(new LibcurlHttpFetcher)); | 114 new DownloadAction(new LibcurlHttpFetcher)); |
115 shared_ptr<PostinstallRunnerAction> postinstall_runner_action_precommit( | 115 shared_ptr<PostinstallRunnerAction> postinstall_runner_action_precommit( |
116 new PostinstallRunnerAction(true)); | 116 new PostinstallRunnerAction(true)); |
117 shared_ptr<SetBootableFlagAction> set_bootable_flag_action( | 117 shared_ptr<SetBootableFlagAction> set_bootable_flag_action( |
118 new SetBootableFlagAction); | 118 new SetBootableFlagAction); |
119 shared_ptr<PostinstallRunnerAction> postinstall_runner_action_postcommit( | 119 shared_ptr<PostinstallRunnerAction> postinstall_runner_action_postcommit( |
120 new PostinstallRunnerAction(false)); | 120 new PostinstallRunnerAction(false)); |
121 | 121 |
122 download_action->set_delegate(this); | 122 download_action->set_delegate(this); |
123 response_handler_action_ = response_handler_action; | 123 response_handler_action_ = response_handler_action; |
124 | 124 |
125 actions_.push_back(shared_ptr<AbstractAction>(request_prep_action)); | 125 actions_.push_back(shared_ptr<AbstractAction>(request_prep_action)); |
126 actions_.push_back(shared_ptr<AbstractAction>(update_check_action)); | 126 actions_.push_back(shared_ptr<AbstractAction>(update_check_action)); |
127 actions_.push_back(shared_ptr<AbstractAction>(response_handler_action)); | 127 actions_.push_back(shared_ptr<AbstractAction>(response_handler_action)); |
128 actions_.push_back(shared_ptr<AbstractAction>(filesystem_copier_action)); | 128 actions_.push_back(shared_ptr<AbstractAction>(filesystem_copier_action)); |
129 actions_.push_back(shared_ptr<AbstractAction>( | 129 actions_.push_back(shared_ptr<AbstractAction>( |
130 kernel_filesystem_copier_action)); | 130 kernel_filesystem_copier_action)); |
131 actions_.push_back(shared_ptr<AbstractAction>(download_action)); | 131 actions_.push_back(shared_ptr<AbstractAction>(download_action)); |
132 actions_.push_back(shared_ptr<AbstractAction>( | 132 actions_.push_back(shared_ptr<AbstractAction>( |
133 postinstall_runner_action_precommit)); | 133 postinstall_runner_action_precommit)); |
134 actions_.push_back(shared_ptr<AbstractAction>(set_bootable_flag_action)); | 134 actions_.push_back(shared_ptr<AbstractAction>(set_bootable_flag_action)); |
135 actions_.push_back(shared_ptr<AbstractAction>( | 135 actions_.push_back(shared_ptr<AbstractAction>( |
136 postinstall_runner_action_postcommit)); | 136 postinstall_runner_action_postcommit)); |
137 | 137 |
138 // Enqueue the actions | 138 // Enqueue the actions |
139 for (vector<shared_ptr<AbstractAction> >::iterator it = actions_.begin(); | 139 for (vector<shared_ptr<AbstractAction> >::iterator it = actions_.begin(); |
140 it != actions_.end(); ++it) { | 140 it != actions_.end(); ++it) { |
141 processor_.EnqueueAction(it->get()); | 141 processor_.EnqueueAction(it->get()); |
142 } | 142 } |
143 | 143 |
144 // Bond them together. We have to use the leaf-types when calling | 144 // Bond them together. We have to use the leaf-types when calling |
145 // BondActions(). | 145 // BondActions(). |
146 BondActions(request_prep_action.get(), | 146 BondActions(request_prep_action.get(), |
147 update_check_action.get()); | 147 update_check_action.get()); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 // Reset download progress regardless of whether or not the download action | 202 // Reset download progress regardless of whether or not the download action |
203 // succeeded. | 203 // succeeded. |
204 const string type = action->Type(); | 204 const string type = action->Type(); |
205 if (type == DownloadAction::StaticType()) | 205 if (type == DownloadAction::StaticType()) |
206 download_progress_ = 0.0; | 206 download_progress_ = 0.0; |
207 if (!success) | 207 if (!success) |
208 return; | 208 return; |
209 // Find out which action completed. | 209 // Find out which action completed. |
210 if (type == OmahaResponseHandlerAction::StaticType()) { | 210 if (type == OmahaResponseHandlerAction::StaticType()) { |
211 SetStatusAndNotify(UPDATE_STATUS_DOWNLOADING); | 211 SetStatusAndNotify(UPDATE_STATUS_DOWNLOADING); |
212 OmahaResponseHandlerAction* omaha_response_handler_action = | 212 OmahaResponseHandlerAction* omaha_response_handler_action = |
213 dynamic_cast<OmahaResponseHandlerAction*>(action); | 213 dynamic_cast<OmahaResponseHandlerAction*>(action); |
214 CHECK(omaha_response_handler_action); | 214 CHECK(omaha_response_handler_action); |
215 const InstallPlan& plan = omaha_response_handler_action->install_plan(); | 215 const InstallPlan& plan = omaha_response_handler_action->install_plan(); |
216 last_checked_time_ = time(NULL); | 216 last_checked_time_ = time(NULL); |
217 // TODO(adlr): put version in InstallPlan | 217 // TODO(adlr): put version in InstallPlan |
218 new_version_ = "0.0.0.0"; | 218 new_version_ = "0.0.0.0"; |
219 new_size_ = plan.size; | 219 new_size_ = plan.size; |
220 } else if (type == DownloadAction::StaticType()) { | 220 } else if (type == DownloadAction::StaticType()) { |
221 SetStatusAndNotify(UPDATE_STATUS_FINALIZING); | 221 SetStatusAndNotify(UPDATE_STATUS_FINALIZING); |
222 } | 222 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 update_engine_service_emit_status_update( | 274 update_engine_service_emit_status_update( |
275 dbus_service_, | 275 dbus_service_, |
276 last_checked_time_, | 276 last_checked_time_, |
277 download_progress_, | 277 download_progress_, |
278 UpdateStatusToString(status_), | 278 UpdateStatusToString(status_), |
279 new_version_.c_str(), | 279 new_version_.c_str(), |
280 new_size_); | 280 new_size_); |
281 } | 281 } |
282 | 282 |
283 } // namespace chromeos_update_engine | 283 } // namespace chromeos_update_engine |
OLD | NEW |