Turn OmahaRequestPrepAction into OmahaRequestDeviceParams.
Pass the params to OmahaRequestAction's ctor. This simplifies a bit
executing as well as testing of OmahaRequestAction and testing of
OmahaRequestDeviceParams. It also allows us to initialize the params
once per update attempt and use them for all OmahaRequestActions.
BUG=560
TEST=unit tests, gmerged on device and forced an update through dev server,
inspected logs.
Review URL: http://codereview.chromium.org/2836053
diff --git a/update_attempter.cc b/update_attempter.cc
index f034b0b..1c32ff4 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -19,7 +19,7 @@
#include "update_engine/filesystem_copier_action.h"
#include "update_engine/libcurl_http_fetcher.h"
#include "update_engine/omaha_request_action.h"
-#include "update_engine/omaha_request_prep_action.h"
+#include "update_engine/omaha_request_params.h"
#include "update_engine/omaha_response_handler_action.h"
#include "update_engine/postinstall_runner_action.h"
#include "update_engine/set_bootable_flag_action.h"
@@ -85,7 +85,7 @@
}
}
-void UpdateAttempter::Update(bool force_full_update) {
+void UpdateAttempter::Update() {
if (status_ == UPDATE_STATUS_UPDATED_NEED_REBOOT) {
LOG(INFO) << "Not updating b/c we already updated and we're waiting for "
<< "reboot";
@@ -95,15 +95,18 @@
// Update in progress. Do nothing
return;
}
- full_update_ = force_full_update;
+ if (!omaha_request_params_.Init()) {
+ LOG(ERROR) << "Unable to initialize Omaha request device params.";
+ return;
+ }
CHECK(!processor_.IsRunning());
processor_.set_delegate(this);
// Actions:
- shared_ptr<OmahaRequestPrepAction> update_check_prep_action(
- new OmahaRequestPrepAction(force_full_update));
shared_ptr<OmahaRequestAction> update_check_action(
- new OmahaRequestAction(NULL, new LibcurlHttpFetcher));
+ new OmahaRequestAction(omaha_request_params_,
+ NULL,
+ new LibcurlHttpFetcher));
shared_ptr<OmahaResponseHandlerAction> response_handler_action(
new OmahaResponseHandlerAction);
shared_ptr<FilesystemCopierAction> filesystem_copier_action(
@@ -118,10 +121,9 @@
new SetBootableFlagAction);
shared_ptr<PostinstallRunnerAction> postinstall_runner_action_postcommit(
new PostinstallRunnerAction(false));
- shared_ptr<OmahaRequestPrepAction> install_success_prep_action(
- new OmahaRequestPrepAction(false));
shared_ptr<OmahaRequestAction> install_success_action(
- new OmahaRequestAction(new OmahaEvent(OmahaEvent::kTypeInstallComplete,
+ new OmahaRequestAction(omaha_request_params_,
+ new OmahaEvent(OmahaEvent::kTypeInstallComplete,
OmahaEvent::kResultSuccess,
0),
new LibcurlHttpFetcher));
@@ -129,7 +131,6 @@
download_action->set_delegate(this);
response_handler_action_ = response_handler_action;
- actions_.push_back(shared_ptr<AbstractAction>(update_check_prep_action));
actions_.push_back(shared_ptr<AbstractAction>(update_check_action));
actions_.push_back(shared_ptr<AbstractAction>(response_handler_action));
actions_.push_back(shared_ptr<AbstractAction>(filesystem_copier_action));
@@ -141,7 +142,6 @@
actions_.push_back(shared_ptr<AbstractAction>(set_bootable_flag_action));
actions_.push_back(shared_ptr<AbstractAction>(
postinstall_runner_action_postcommit));
- actions_.push_back(shared_ptr<AbstractAction>(install_success_prep_action));
actions_.push_back(shared_ptr<AbstractAction>(install_success_action));
// Enqueue the actions
@@ -152,8 +152,6 @@
// Bond them together. We have to use the leaf-types when calling
// BondActions().
- BondActions(update_check_prep_action.get(),
- update_check_action.get());
BondActions(update_check_action.get(),
response_handler_action.get());
BondActions(response_handler_action.get(),
@@ -168,8 +166,6 @@
set_bootable_flag_action.get());
BondActions(set_bootable_flag_action.get(),
postinstall_runner_action_postcommit.get());
- BondActions(install_success_prep_action.get(),
- install_success_action.get());
SetStatusAndNotify(UPDATE_STATUS_CHECKING_FOR_UPDATE);
processor_.StartProcessing();
@@ -181,7 +177,7 @@
<< UpdateStatusToString(status_) << ", so not checking.";
return;
}
- Update(false);
+ Update();
}
// Delegate methods: