Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1252)

Unified Diff: update_attempter.cc

Issue 2819059: Narrow down to one generic error per action. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: Rename SwitchToActionSpecificCode to GetErrorCodeForAction. Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « update_attempter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: update_attempter.cc
diff --git a/update_attempter.cc b/update_attempter.cc
index ee1cf00f7bd64ac6abe7cd12f135ddb039d903e5..5cf32e4f69cf06e18343122c518cbe3f840d9141 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -90,6 +90,30 @@ const char* UpdateStatusToString(UpdateStatus status) {
}
}
+// Turns a generic kActionCodeError to a generic error code specific
+// to |action| (e.g., kActionCodeFilesystemCopierError). If |code| is
+// not kActionCodeError, or the action is not matched, returns |code|
+// unchanged.
+ActionExitCode GetErrorCodeForAction(AbstractAction* action,
+ ActionExitCode code) {
+ if (code != kActionCodeError)
+ return code;
+
+ const string type = action->Type();
+ if (type == OmahaRequestAction::StaticType())
+ return kActionCodeOmahaRequestError;
+ if (type == OmahaResponseHandlerAction::StaticType())
+ return kActionCodeOmahaResponseHandlerError;
+ if (type == FilesystemCopierAction::StaticType())
+ return kActionCodeFilesystemCopierError;
+ if (type == PostinstallRunnerAction::StaticType())
+ return kActionCodePostinstallRunnerError;
+ if (type == SetBootableFlagAction::StaticType())
+ return kActionCodeSetBootableFlagError;
+
+ return code;
+}
+
void UpdateAttempter::Update() {
if (status_ == UPDATE_STATUS_UPDATED_NEED_REBOOT) {
LOG(INFO) << "Not updating b/c we already updated and we're waiting for "
@@ -246,16 +270,8 @@ void UpdateAttempter::ActionCompleted(ActionProcessor* processor,
if (type == DownloadAction::StaticType())
download_progress_ = 0.0;
if (code != kActionCodeSuccess) {
- // On failure, schedule an error event to be sent to Omaha. For
- // now assume that Omaha response action failure means that
- // there's no update so don't send an event. Also, double check
- // that the failure has not occurred while sending an error event
- // -- in which case don't schedule another. This shouldn't really
- // happen but just in case...
- if (type != OmahaResponseHandlerAction::StaticType() &&
- status_ != UPDATE_STATUS_REPORTING_ERROR_EVENT) {
- CreatePendingErrorEvent(code);
- }
+ // On failure, schedule an error event to be sent to Omaha.
+ CreatePendingErrorEvent(action, code);
return;
}
// Find out which action completed.
@@ -332,12 +348,25 @@ void UpdateAttempter::SetStatusAndNotify(UpdateStatus status) {
new_size_);
}
-void UpdateAttempter::CreatePendingErrorEvent(ActionExitCode code) {
+void UpdateAttempter::CreatePendingErrorEvent(AbstractAction* action,
+ ActionExitCode code) {
if (error_event_.get()) {
// This shouldn't really happen.
LOG(WARNING) << "There's already an existing pending error event.";
return;
}
+
+ // For now assume that Omaha response action failure means that
+ // there's no update so don't send an event. Also, double check that
+ // the failure has not occurred while sending an error event -- in
+ // which case don't schedule another. This shouldn't really happen
+ // but just in case...
+ if (action->Type() == OmahaResponseHandlerAction::StaticType() ||
+ status_ == UPDATE_STATUS_REPORTING_ERROR_EVENT) {
+ return;
+ }
+
+ code = GetErrorCodeForAction(action, code);
error_event_.reset(new OmahaEvent(OmahaEvent::kTypeUpdateComplete,
OmahaEvent::kResultError,
code));
« no previous file with comments | « update_attempter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698