Rename ActionExitCode to ErrorCode
Nowadays ActionExitCode is used throughout the codebase so use a more
generic name to reflect this.
BUG=chromium:216507
TEST=unit tests pass
Change-Id: I23d1d7e2676443251dbc42ed137fd018aadfa8a3
Reviewed-on: https://gerrit.chromium.org/gerrit/49512
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
diff --git a/action_processor.cc b/action_processor.cc
index 0d8c046..d4e5cc4 100644
--- a/action_processor.cc
+++ b/action_processor.cc
@@ -54,7 +54,7 @@
}
void ActionProcessor::ActionComplete(AbstractAction* actionptr,
- ActionExitCode code) {
+ ErrorCode code) {
CHECK_EQ(actionptr, current_action_);
if (delegate_)
delegate_->ActionCompleted(this, actionptr, code);
@@ -64,7 +64,7 @@
if (actions_.empty()) {
LOG(INFO) << "ActionProcessor::ActionComplete: finished last action of"
" type " << old_type;
- } else if (code != kActionCodeSuccess) {
+ } else if (code != kErrorCodeSuccess) {
LOG(INFO) << "ActionProcessor::ActionComplete: " << old_type
<< " action failed. Aborting processing.";
actions_.clear();
diff --git a/action_processor.h b/action_processor.h
index 38d63ae..696afd4 100644
--- a/action_processor.h
+++ b/action_processor.h
@@ -9,6 +9,8 @@
#include "base/basictypes.h"
+#include "update_engine/error_code.h"
+
// The structure of these classes (Action, ActionPipe, ActionProcessor, etc.)
// is based on the KSAction* classes from the Google Update Engine code at
// http://code.google.com/p/update-engine/ . The author of this file sends
@@ -21,101 +23,6 @@
namespace chromeos_update_engine {
-// Action exit codes.
-enum ActionExitCode {
- kActionCodeSuccess = 0,
- kActionCodeError = 1,
- kActionCodeOmahaRequestError = 2,
- kActionCodeOmahaResponseHandlerError = 3,
- kActionCodeFilesystemCopierError = 4,
- kActionCodePostinstallRunnerError = 5,
- kActionCodeSetBootableFlagError = 6, // TODO(petkov): Unused. Recycle?
- kActionCodeInstallDeviceOpenError = 7,
- kActionCodeKernelDeviceOpenError = 8,
- kActionCodeDownloadTransferError = 9,
- kActionCodePayloadHashMismatchError = 10,
- kActionCodePayloadSizeMismatchError = 11,
- kActionCodeDownloadPayloadVerificationError = 12,
- kActionCodeDownloadNewPartitionInfoError = 13,
- kActionCodeDownloadWriteError = 14,
- kActionCodeNewRootfsVerificationError = 15,
- kActionCodeNewKernelVerificationError = 16,
- kActionCodeSignedDeltaPayloadExpectedError = 17,
- kActionCodeDownloadPayloadPubKeyVerificationError = 18,
- kActionCodePostinstallBootedFromFirmwareB = 19,
- kActionCodeDownloadStateInitializationError = 20,
- kActionCodeDownloadInvalidMetadataMagicString = 21,
- kActionCodeDownloadSignatureMissingInManifest = 22,
- kActionCodeDownloadManifestParseError = 23,
- kActionCodeDownloadMetadataSignatureError = 24,
- kActionCodeDownloadMetadataSignatureVerificationError = 25,
- kActionCodeDownloadMetadataSignatureMismatch = 26,
- kActionCodeDownloadOperationHashVerificationError = 27,
- kActionCodeDownloadOperationExecutionError = 28,
- kActionCodeDownloadOperationHashMismatch = 29,
- kActionCodeOmahaRequestEmptyResponseError = 30,
- kActionCodeOmahaRequestXMLParseError = 31,
- kActionCodeDownloadInvalidMetadataSize = 32,
- kActionCodeDownloadInvalidMetadataSignature = 33,
- kActionCodeOmahaResponseInvalid = 34,
- kActionCodeOmahaUpdateIgnoredPerPolicy = 35,
- kActionCodeOmahaUpdateDeferredPerPolicy = 36,
- kActionCodeOmahaErrorInHTTPResponse = 37,
- kActionCodeDownloadOperationHashMissingError = 38,
- kActionCodeDownloadMetadataSignatureMissingError = 39,
- kActionCodeOmahaUpdateDeferredForBackoff = 40,
- kActionCodePostinstallPowerwashError = 41,
- kActionCodeUpdateCanceledByChannelChange = 42,
-
- // Note: When adding new error codes, please remember to add the
- // error into one of the buckets in PayloadState::UpdateFailed method so
- // that the retries across URLs and the payload backoff mechanism work
- // correctly for those new error codes.
-
- // Any code above this is sent to both Omaha and UMA as-is, except
- // kActionCodeOmahaErrorInHTTPResponse (see error code 2000 for more details).
- // Codes/flags below this line is sent only to Omaha and not to UMA.
-
- // kActionCodeUmaReportedMax is not an error code per se, it's just the count
- // of the number of enums above. Add any new errors above this line if you
- // want them to show up on UMA. Stuff below this line will not be sent to UMA
- // but is used for other errors that are sent to Omaha. We don't assign any
- // particular value for this enum so that it's just one more than the last
- // one above and thus always represents the correct count of UMA metrics
- // buckets, even when new enums are added above this line in future. See
- // utils::SendErrorCodeToUma on how this enum is used.
- kActionCodeUmaReportedMax,
-
- // use the 2xxx range to encode HTTP errors. These errors are available in
- // Dremel with the individual granularity. But for UMA purposes, all these
- // errors are aggregated into one: kActionCodeOmahaErrorInHTTPResponse.
- kActionCodeOmahaRequestHTTPResponseBase = 2000, // + HTTP response code
-
- // TODO(jaysri): Move out all the bit masks into separate constants
- // outside the enum as part of fixing bug 34369.
- // Bit flags. Remember to update the mask below for new bits.
-
- // Set if boot mode not normal.
- kActionCodeDevModeFlag = 1 << 31,
-
- // Set if resuming an interruped update.
- kActionCodeResumedFlag = 1 << 30,
-
- // Set if using a dev/test image as opposed to an MP-signed image.
- kActionCodeTestImageFlag = 1 << 29,
-
- // Set if using devserver or Omaha sandbox (using crosh autest).
- kActionCodeTestOmahaUrlFlag = 1 << 28,
-
- // Mask that indicates bit positions that are used to indicate special flags
- // that are embedded in the error code to provide additional context about
- // the system in which the error was encountered.
- kSpecialFlags = (kActionCodeDevModeFlag |
- kActionCodeResumedFlag |
- kActionCodeTestImageFlag |
- kActionCodeTestOmahaUrlFlag)
-};
-
class AbstractAction;
class ActionProcessorDelegate;
@@ -153,7 +60,7 @@
}
// Called by an action to notify processor that it's done. Caller passes self.
- void ActionComplete(AbstractAction* actionptr, ActionExitCode code);
+ void ActionComplete(AbstractAction* actionptr, ErrorCode code);
private:
// Actions that have not yet begun processing, in the order in which
@@ -177,7 +84,7 @@
// to the ActionProcessor is passed. |code| is set to the exit code of the
// last completed action.
virtual void ProcessingDone(const ActionProcessor* processor,
- ActionExitCode code) {}
+ ErrorCode code) {}
// Called when processing has stopped. Does not mean that all Actions have
// completed. If/when all Actions complete, ProcessingDone() will be called.
@@ -187,7 +94,7 @@
// or otherwise.
virtual void ActionCompleted(ActionProcessor* processor,
AbstractAction* action,
- ActionExitCode code) {}
+ ErrorCode code) {}
};
} // namespace chromeos_update_engine
diff --git a/action_processor_unittest.cc b/action_processor_unittest.cc
index 20a79af..20bded6 100644
--- a/action_processor_unittest.cc
+++ b/action_processor_unittest.cc
@@ -33,7 +33,7 @@
void PerformAction() {}
void CompleteAction() {
ASSERT_TRUE(processor());
- processor()->ActionComplete(this, kActionCodeSuccess);
+ processor()->ActionComplete(this, kErrorCodeSuccess);
}
string Type() const { return "ActionProcessorTestAction"; }
};
@@ -66,10 +66,10 @@
processing_done_called_(false),
processing_stopped_called_(false),
action_completed_called_(false),
- action_exit_code_(kActionCodeError) {}
+ action_exit_code_(kErrorCodeError) {}
virtual void ProcessingDone(const ActionProcessor* processor,
- ActionExitCode code) {
+ ErrorCode code) {
EXPECT_EQ(processor_, processor);
EXPECT_FALSE(processing_done_called_);
processing_done_called_ = true;
@@ -81,7 +81,7 @@
}
virtual void ActionCompleted(ActionProcessor* processor,
AbstractAction* action,
- ActionExitCode code) {
+ ErrorCode code) {
EXPECT_EQ(processor_, processor);
EXPECT_FALSE(action_completed_called_);
action_completed_called_ = true;
@@ -92,7 +92,7 @@
bool processing_done_called_;
bool processing_stopped_called_;
bool action_completed_called_;
- ActionExitCode action_exit_code_;
+ ErrorCode action_exit_code_;
};
} // namespace {}
diff --git a/action_unittest.cc b/action_unittest.cc
index af0e130..e09967f 100644
--- a/action_unittest.cc
+++ b/action_unittest.cc
@@ -33,7 +33,7 @@
void PerformAction() {}
void CompleteAction() {
ASSERT_TRUE(processor());
- processor()->ActionComplete(this, kActionCodeSuccess);
+ processor()->ActionComplete(this, kErrorCodeSuccess);
}
string Type() const { return "ActionTestAction"; }
};
diff --git a/delta_performer.cc b/delta_performer.cc
index ae1f7e5..940bfa5 100644
--- a/delta_performer.cc
+++ b/delta_performer.cc
@@ -262,8 +262,8 @@
const std::vector<char>& payload,
DeltaArchiveManifest* manifest,
uint64_t* metadata_size,
- ActionExitCode* error) {
- *error = kActionCodeSuccess;
+ ErrorCode* error) {
+ *error = kErrorCodeSuccess;
// manifest_offset is the byte offset where the manifest protobuf begins.
const uint64_t manifest_offset = GetManifestOffset();
@@ -275,7 +275,7 @@
// Validate the magic string.
if (memcmp(payload.data(), kDeltaMagic, strlen(kDeltaMagic)) != 0) {
LOG(ERROR) << "Bad payload format -- invalid delta magic.";
- *error = kActionCodeDownloadInvalidMetadataMagicString;
+ *error = kErrorCodeDownloadInvalidMetadataMagicString;
return kMetadataParseError;
}
@@ -304,7 +304,7 @@
LOG(ERROR) << "Mandatory metadata size in Omaha response ("
<< install_plan_->metadata_size << ") is missing/incorrect."
<< ", Actual = " << *metadata_size;
- *error = kActionCodeDownloadInvalidMetadataSize;
+ *error = kErrorCodeDownloadInvalidMetadataSize;
return kMetadataParseError;
}
}
@@ -328,13 +328,13 @@
<< install_plan_->metadata_size
<< ") in Omaha response as validation is not mandatory. "
<< "Trusting metadata size in payload = " << *metadata_size;
- SendUmaStat(kActionCodeDownloadInvalidMetadataSize);
+ SendUmaStat(kErrorCodeDownloadInvalidMetadataSize);
}
// We have the full metadata in |payload|. Verify its integrity
// and authenticity based on the information we have in Omaha response.
*error = ValidateMetadataSignature(&payload[0], *metadata_size);
- if (*error != kActionCodeSuccess) {
+ if (*error != kErrorCodeSuccess) {
if (install_plan_->hash_checks_mandatory) {
LOG(ERROR) << "Mandatory metadata signature validation failed";
return kMetadataParseError;
@@ -343,14 +343,14 @@
// For non-mandatory cases, just send a UMA stat.
LOG(WARNING) << "Ignoring metadata signature validation failures";
SendUmaStat(*error);
- *error = kActionCodeSuccess;
+ *error = kErrorCodeSuccess;
}
// The metadata in |payload| is deemed valid. So, it's now safe to
// parse the protobuf.
if (!manifest->ParseFromArray(&payload[manifest_offset], manifest_size)) {
LOG(ERROR) << "Unable to parse manifest in update file.";
- *error = kActionCodeDownloadManifestParseError;
+ *error = kErrorCodeDownloadManifestParseError;
return kMetadataParseError;
}
return kMetadataParseSuccess;
@@ -361,8 +361,8 @@
// were written, or false on any error, regardless of progress
// and stores an action exit code in |error|.
bool DeltaPerformer::Write(const void* bytes, size_t count,
- ActionExitCode *error) {
- *error = kActionCodeSuccess;
+ ErrorCode *error) {
+ *error = kErrorCodeSuccess;
const char* c_bytes = reinterpret_cast<const char*>(bytes);
buffer_.insert(buffer_.end(), c_bytes, c_bytes + count);
@@ -393,7 +393,7 @@
LogPartitionInfo(manifest_);
if (!PrimeUpdateState()) {
- *error = kActionCodeDownloadStateInitializationError;
+ *error = kErrorCodeDownloadStateInitializationError;
LOG(ERROR) << "Unable to prime the update state.";
return false;
}
@@ -437,7 +437,7 @@
// called. Otherwise, we might be failing operations before even if there
// isn't sufficient data to compute the proper hash.
*error = ValidateOperationHash(op);
- if (*error != kActionCodeSuccess) {
+ if (*error != kErrorCodeSuccess) {
if (install_plan_->hash_checks_mandatory) {
LOG(ERROR) << "Mandatory operation hash check failed";
return false;
@@ -446,7 +446,7 @@
// For non-mandatory cases, just send a UMA stat.
LOG(WARNING) << "Ignoring operation validation errors";
SendUmaStat(*error);
- *error = kActionCodeSuccess;
+ *error = kErrorCodeSuccess;
}
}
@@ -459,21 +459,21 @@
if (!PerformReplaceOperation(op, is_kernel_partition)) {
LOG(ERROR) << "Failed to perform replace operation "
<< next_operation_num_;
- *error = kActionCodeDownloadOperationExecutionError;
+ *error = kErrorCodeDownloadOperationExecutionError;
return false;
}
} else if (op.type() == DeltaArchiveManifest_InstallOperation_Type_MOVE) {
if (!PerformMoveOperation(op, is_kernel_partition)) {
LOG(ERROR) << "Failed to perform move operation "
<< next_operation_num_;
- *error = kActionCodeDownloadOperationExecutionError;
+ *error = kErrorCodeDownloadOperationExecutionError;
return false;
}
} else if (op.type() == DeltaArchiveManifest_InstallOperation_Type_BSDIFF) {
if (!PerformBsdiffOperation(op, is_kernel_partition)) {
LOG(ERROR) << "Failed to perform bsdiff operation "
<< next_operation_num_;
- *error = kActionCodeDownloadOperationExecutionError;
+ *error = kErrorCodeDownloadOperationExecutionError;
return false;
}
}
@@ -772,19 +772,19 @@
return true;
}
-ActionExitCode DeltaPerformer::ValidateMetadataSignature(
+ErrorCode DeltaPerformer::ValidateMetadataSignature(
const char* metadata, uint64_t metadata_size) {
if (install_plan_->metadata_signature.empty()) {
if (install_plan_->hash_checks_mandatory) {
LOG(ERROR) << "Missing mandatory metadata signature in Omaha response";
- return kActionCodeDownloadMetadataSignatureMissingError;
+ return kErrorCodeDownloadMetadataSignatureMissingError;
}
// For non-mandatory cases, just send a UMA stat.
LOG(WARNING) << "Cannot validate metadata as the signature is empty";
- SendUmaStat(kActionCodeDownloadMetadataSignatureMissingError);
- return kActionCodeSuccess;
+ SendUmaStat(kErrorCodeDownloadMetadataSignatureMissingError);
+ return kErrorCodeSuccess;
}
// Convert base64-encoded signature to raw bytes.
@@ -793,7 +793,7 @@
&metadata_signature)) {
LOG(ERROR) << "Unable to decode base64 metadata signature: "
<< install_plan_->metadata_signature;
- return kActionCodeDownloadMetadataSignatureError;
+ return kErrorCodeDownloadMetadataSignatureError;
}
vector<char> expected_metadata_hash;
@@ -801,21 +801,21 @@
public_key_path_,
&expected_metadata_hash)) {
LOG(ERROR) << "Unable to compute expected hash from metadata signature";
- return kActionCodeDownloadMetadataSignatureError;
+ return kErrorCodeDownloadMetadataSignatureError;
}
OmahaHashCalculator metadata_hasher;
metadata_hasher.Update(metadata, metadata_size);
if (!metadata_hasher.Finalize()) {
LOG(ERROR) << "Unable to compute actual hash of manifest";
- return kActionCodeDownloadMetadataSignatureVerificationError;
+ return kErrorCodeDownloadMetadataSignatureVerificationError;
}
vector<char> calculated_metadata_hash = metadata_hasher.raw_hash();
PayloadSigner::PadRSA2048SHA256Hash(&calculated_metadata_hash);
if (calculated_metadata_hash.empty()) {
LOG(ERROR) << "Computed actual hash of metadata is empty.";
- return kActionCodeDownloadMetadataSignatureVerificationError;
+ return kErrorCodeDownloadMetadataSignatureVerificationError;
}
if (calculated_metadata_hash != expected_metadata_hash) {
@@ -823,14 +823,14 @@
utils::HexDumpVector(expected_metadata_hash);
LOG(ERROR) << "Calculated hash = ";
utils::HexDumpVector(calculated_metadata_hash);
- return kActionCodeDownloadMetadataSignatureMismatch;
+ return kErrorCodeDownloadMetadataSignatureMismatch;
}
LOG(INFO) << "Manifest signature matches expected value in Omaha response";
- return kActionCodeSuccess;
+ return kErrorCodeSuccess;
}
-ActionExitCode DeltaPerformer::ValidateOperationHash(
+ErrorCode DeltaPerformer::ValidateOperationHash(
const DeltaArchiveManifest_InstallOperation& operation) {
if (!operation.data_sha256_hash().size()) {
@@ -839,7 +839,7 @@
// either. So, these operations are always considered validated since the
// metadata that contains all the non-data-blob portions of the operation
// has already been validated. This is true for both HTTP and HTTPS cases.
- return kActionCodeSuccess;
+ return kErrorCodeSuccess;
}
// No hash is present for an operation that has data blobs. This shouldn't
@@ -859,15 +859,15 @@
if (install_plan_->hash_checks_mandatory) {
LOG(ERROR) << "Missing mandatory operation hash for operation "
<< next_operation_num_ + 1;
- return kActionCodeDownloadOperationHashMissingError;
+ return kErrorCodeDownloadOperationHashMissingError;
}
// For non-mandatory cases, just send a UMA stat.
LOG(WARNING) << "Cannot validate operation " << next_operation_num_ + 1
<< " as there's no operation hash in manifest";
- SendUmaStat(kActionCodeDownloadOperationHashMissingError);
+ SendUmaStat(kErrorCodeDownloadOperationHashMissingError);
}
- return kActionCodeSuccess;
+ return kErrorCodeSuccess;
}
vector<char> expected_op_hash;
@@ -880,7 +880,7 @@
if (!operation_hasher.Finalize()) {
LOG(ERROR) << "Unable to compute actual hash of operation "
<< next_operation_num_;
- return kActionCodeDownloadOperationHashVerificationError;
+ return kErrorCodeDownloadOperationHashVerificationError;
}
vector<char> calculated_op_hash = operation_hasher.raw_hash();
@@ -891,10 +891,10 @@
LOG(ERROR) << "Calculated hash over " << operation.data_length()
<< " bytes at offset: " << operation.data_offset() << " = ";
utils::HexDumpVector(calculated_op_hash);
- return kActionCodeDownloadOperationHashMismatch;
+ return kErrorCodeDownloadOperationHashMismatch;
}
- return kActionCodeSuccess;
+ return kErrorCodeSuccess;
}
#define TEST_AND_RETURN_VAL(_retval, _condition) \
@@ -905,44 +905,44 @@
} \
} while (0);
-ActionExitCode DeltaPerformer::VerifyPayload(
+ErrorCode DeltaPerformer::VerifyPayload(
const std::string& update_check_response_hash,
const uint64_t update_check_response_size) {
LOG(INFO) << "Verifying delta payload using public key: " << public_key_path_;
// Verifies the download size.
- TEST_AND_RETURN_VAL(kActionCodePayloadSizeMismatchError,
+ TEST_AND_RETURN_VAL(kErrorCodePayloadSizeMismatchError,
update_check_response_size ==
manifest_metadata_size_ + buffer_offset_);
// Verifies the payload hash.
const string& payload_hash_data = hash_calculator_.hash();
- TEST_AND_RETURN_VAL(kActionCodeDownloadPayloadVerificationError,
+ TEST_AND_RETURN_VAL(kErrorCodeDownloadPayloadVerificationError,
!payload_hash_data.empty());
- TEST_AND_RETURN_VAL(kActionCodePayloadHashMismatchError,
+ TEST_AND_RETURN_VAL(kErrorCodePayloadHashMismatchError,
payload_hash_data == update_check_response_hash);
// Verifies the signed payload hash.
if (!utils::FileExists(public_key_path_.c_str())) {
LOG(WARNING) << "Not verifying signed delta payload -- missing public key.";
- return kActionCodeSuccess;
+ return kErrorCodeSuccess;
}
- TEST_AND_RETURN_VAL(kActionCodeSignedDeltaPayloadExpectedError,
+ TEST_AND_RETURN_VAL(kErrorCodeSignedDeltaPayloadExpectedError,
!signatures_message_data_.empty());
vector<char> signed_hash_data;
- TEST_AND_RETURN_VAL(kActionCodeDownloadPayloadPubKeyVerificationError,
+ TEST_AND_RETURN_VAL(kErrorCodeDownloadPayloadPubKeyVerificationError,
PayloadSigner::VerifySignature(
signatures_message_data_,
public_key_path_,
&signed_hash_data));
OmahaHashCalculator signed_hasher;
- TEST_AND_RETURN_VAL(kActionCodeDownloadPayloadPubKeyVerificationError,
+ TEST_AND_RETURN_VAL(kErrorCodeDownloadPayloadPubKeyVerificationError,
signed_hasher.SetContext(signed_hash_context_));
- TEST_AND_RETURN_VAL(kActionCodeDownloadPayloadPubKeyVerificationError,
+ TEST_AND_RETURN_VAL(kErrorCodeDownloadPayloadPubKeyVerificationError,
signed_hasher.Finalize());
vector<char> hash_data = signed_hasher.raw_hash();
PayloadSigner::PadRSA2048SHA256Hash(&hash_data);
- TEST_AND_RETURN_VAL(kActionCodeDownloadPayloadPubKeyVerificationError,
+ TEST_AND_RETURN_VAL(kErrorCodeDownloadPayloadPubKeyVerificationError,
!hash_data.empty());
if (hash_data != signed_hash_data) {
LOG(ERROR) << "Public key verification failed, thus update failed. "
@@ -950,7 +950,7 @@
utils::HexDumpVector(signed_hash_data);
LOG(ERROR) << "Computed Signature:";
utils::HexDumpVector(hash_data);
- return kActionCodeDownloadPayloadPubKeyVerificationError;
+ return kErrorCodeDownloadPayloadPubKeyVerificationError;
}
// At this point, we are guaranteed to have downloaded a full payload, i.e
@@ -960,7 +960,7 @@
// indicate that to the payload state so that AU can backoff appropriately.
system_state_->payload_state()->DownloadComplete();
- return kActionCodeSuccess;
+ return kErrorCodeSuccess;
}
bool DeltaPerformer::GetNewPartitionInfo(uint64_t* kernel_size,
@@ -1198,7 +1198,7 @@
return true;
}
-void DeltaPerformer::SendUmaStat(ActionExitCode code) {
+void DeltaPerformer::SendUmaStat(ErrorCode code) {
utils::SendErrorCodeToUma(system_state_, code);
}
diff --git a/delta_performer.h b/delta_performer.h
index 8370b81..1f8f5cb 100644
--- a/delta_performer.h
+++ b/delta_performer.h
@@ -85,13 +85,13 @@
// FileWriter's Write implementation where caller doesn't care about
// error codes.
bool Write(const void* bytes, size_t count) {
- ActionExitCode error;
+ ErrorCode error;
return Write(bytes, count, &error);
}
// FileWriter's Write implementation that returns a more specific |error| code
// in case of failures in Write operation.
- bool Write(const void* bytes, size_t count, ActionExitCode *error);
+ bool Write(const void* bytes, size_t count, ErrorCode *error);
// Wrapper around close. Returns 0 on success or -errno on error.
// Closes both 'path' given to Open() and the kernel path.
@@ -99,12 +99,12 @@
// Verifies the downloaded payload against the signed hash included in the
// payload, against the update check hash (which is in base64 format) and
- // size using the public key and returns kActionCodeSuccess on success, an
+ // size using the public key and returns kErrorCodeSuccess on success, an
// error code on failure. This method should be called after closing the
// stream. Note this method skips the signed hash check if the public key is
- // unavailable; it returns kActionCodeSignedDeltaPayloadExpectedError if the
+ // unavailable; it returns kErrorCodeSignedDeltaPayloadExpectedError if the
// public key is available but the delta payload doesn't include a signature.
- ActionExitCode VerifyPayload(const std::string& update_check_response_hash,
+ ErrorCode VerifyPayload(const std::string& update_check_response_hash,
const uint64_t update_check_response_size);
// Reads from the update manifest the expected sizes and hashes of the target
@@ -154,7 +154,7 @@
const std::vector<char>& payload,
DeltaArchiveManifest* manifest,
uint64_t* metadata_size,
- ActionExitCode* error);
+ ErrorCode* error);
void set_public_key_path(const std::string& public_key_path) {
public_key_path_ = public_key_path;
@@ -195,19 +195,19 @@
// Validates that the hash of the blobs corresponding to the given |operation|
// matches what's specified in the manifest in the payload.
- // Returns kActionCodeSuccess on match or a suitable error code otherwise.
- ActionExitCode ValidateOperationHash(
+ // Returns kErrorCodeSuccess on match or a suitable error code otherwise.
+ ErrorCode ValidateOperationHash(
const DeltaArchiveManifest_InstallOperation& operation);
// Interprets the given |protobuf| as a DeltaArchiveManifest protocol buffer
// of the given protobuf_length and verifies that the signed hash of the
// metadata matches what's specified in the install plan from Omaha.
- // Returns kActionCodeSuccess on match or a suitable error code otherwise.
+ // Returns kErrorCodeSuccess on match or a suitable error code otherwise.
// This method must be called before any part of the |protobuf| is parsed
// so that a man-in-the-middle attack on the SSL connection to the payload
// server doesn't exploit any vulnerability in the code that parses the
// protocol buffer.
- ActionExitCode ValidateMetadataSignature(const char* protobuf,
+ ErrorCode ValidateMetadataSignature(const char* protobuf,
uint64_t protobuf_length);
// Returns true on success.
@@ -244,7 +244,7 @@
bool PrimeUpdateState();
// Sends UMA statistics for the given error code.
- void SendUmaStat(ActionExitCode code);
+ void SendUmaStat(ErrorCode code);
// Update Engine preference store.
PrefsInterface* prefs_;
diff --git a/delta_performer_unittest.cc b/delta_performer_unittest.cc
index 83f3863..57c16e7 100644
--- a/delta_performer_unittest.cc
+++ b/delta_performer_unittest.cc
@@ -558,7 +558,7 @@
EXPECT_EQ(0, (*performer)->Open(state->a_img.c_str(), 0, 0));
EXPECT_TRUE((*performer)->OpenKernel(state->old_kernel.c_str()));
- ActionExitCode expected_error, actual_error;
+ ErrorCode expected_error, actual_error;
bool continue_writing;
switch(op_hash_test) {
case kInvalidOperationData: {
@@ -567,7 +567,7 @@
int some_offset = state->metadata_size + 300;
LOG(INFO) << "Tampered value at offset: " << some_offset;
state->delta[some_offset]++;
- expected_error = kActionCodeDownloadOperationHashMismatch;
+ expected_error = kErrorCodeDownloadOperationHashMismatch;
continue_writing = false;
break;
}
@@ -575,7 +575,7 @@
case kValidOperationData:
default:
// no change.
- expected_error = kActionCodeSuccess;
+ expected_error = kErrorCodeSuccess;
continue_writing = true;
break;
}
@@ -588,7 +588,7 @@
count,
&actual_error));
// Normally write_succeeded should be true every time and
- // actual_error should be kActionCodeSuccess. If so, continue the loop.
+ // actual_error should be kErrorCodeSuccess. If so, continue the loop.
// But if we seeded an operation hash error above, then write_succeeded
// will be false. The failure may happen at any operation n. So, all
// Writes until n-1 should succeed and the nth operation will fail with
@@ -603,7 +603,7 @@
}
}
- EXPECT_EQ(kActionCodeSuccess, actual_error);
+ EXPECT_EQ(kErrorCodeSuccess, actual_error);
}
// If we had continued all the way through, Close should succeed.
@@ -617,13 +617,13 @@
void VerifyPayloadResult(DeltaPerformer* performer,
DeltaState* state,
- ActionExitCode expected_result) {
+ ErrorCode expected_result) {
if (!performer) {
EXPECT_TRUE(!"Skipping payload verification since performer is NULL.");
return;
}
- int expected_times = (expected_result == kActionCodeSuccess) ? 1 : 0;
+ int expected_times = (expected_result == kErrorCodeSuccess) ? 1 : 0;
EXPECT_CALL(*(state->mock_system_state.mock_payload_state()),
DownloadComplete()).Times(expected_times);
@@ -634,7 +634,7 @@
state->delta.size()));
LOG(INFO) << "Verified payload.";
- if (expected_result != kActionCodeSuccess) {
+ if (expected_result != kErrorCodeSuccess) {
// no need to verify new partition if VerifyPayload failed.
return;
}
@@ -672,13 +672,13 @@
void VerifyPayload(DeltaPerformer* performer,
DeltaState* state,
SignatureTest signature_test) {
- ActionExitCode expected_result = kActionCodeSuccess;
+ ErrorCode expected_result = kErrorCodeSuccess;
switch (signature_test) {
case kSignatureNone:
- expected_result = kActionCodeSignedDeltaPayloadExpectedError;
+ expected_result = kErrorCodeSignedDeltaPayloadExpectedError;
break;
case kSignatureGeneratedShellBadKey:
- expected_result = kActionCodeDownloadPayloadPubKeyVerificationError;
+ expected_result = kErrorCodeDownloadPayloadPubKeyVerificationError;
break;
default: break; // appease gcc
}
@@ -727,7 +727,7 @@
EXPECT_TRUE(performer.Write(&version, 8));
install_plan.metadata_size = expected_metadata_size;
- ActionExitCode error_code;
+ ErrorCode error_code;
// When filling in size in manifest, exclude the size of the 20-byte header.
uint64_t size_in_manifest = htobe64(actual_metadata_size - 20);
bool result = performer.Write(&size_in_manifest, 8, &error_code);
@@ -736,7 +736,7 @@
EXPECT_TRUE(result);
} else {
EXPECT_FALSE(result);
- EXPECT_EQ(kActionCodeDownloadInvalidMetadataSize, error_code);
+ EXPECT_EQ(kErrorCodeDownloadInvalidMetadataSize, error_code);
}
EXPECT_LT(performer.Close(), 0);
@@ -771,20 +771,20 @@
install_plan.metadata_size = state.metadata_size;
DeltaPerformer::MetadataParseResult expected_result, actual_result;
- ActionExitCode expected_error, actual_error;
+ ErrorCode expected_error, actual_error;
// Fill up the metadata signature in install plan according to the test.
switch (metadata_signature_test) {
case kEmptyMetadataSignature:
install_plan.metadata_signature.clear();
expected_result = DeltaPerformer::kMetadataParseError;
- expected_error = kActionCodeDownloadMetadataSignatureMissingError;
+ expected_error = kErrorCodeDownloadMetadataSignatureMissingError;
break;
case kInvalidMetadataSignature:
install_plan.metadata_signature = kBogusMetadataSignature1;
expected_result = DeltaPerformer::kMetadataParseError;
- expected_error = kActionCodeDownloadMetadataSignatureMismatch;
+ expected_error = kErrorCodeDownloadMetadataSignatureMismatch;
break;
case kValidMetadataSignature:
@@ -799,14 +799,14 @@
&install_plan.metadata_signature));
EXPECT_FALSE(install_plan.metadata_signature.empty());
expected_result = DeltaPerformer::kMetadataParseSuccess;
- expected_error = kActionCodeSuccess;
+ expected_error = kErrorCodeSuccess;
break;
}
// Ignore the expected result/error if hash checks are not mandatory.
if (!hash_checks_mandatory) {
expected_result = DeltaPerformer::kMetadataParseSuccess;
- expected_error = kActionCodeSuccess;
+ expected_error = kErrorCodeSuccess;
}
// Create the delta performer object.
@@ -826,7 +826,7 @@
// Init actual_error with an invalid value so that we make sure
// ParsePayloadMetadata properly populates it in all cases.
- actual_error = kActionCodeUmaReportedMax;
+ actual_error = kErrorCodeUmaReportedMax;
actual_result = delta_performer.ParsePayloadMetadata(payload, &manifest,
&parsed_metadata_size, &actual_error);
diff --git a/download_action.cc b/download_action.cc
index 1ee3a8e..da6b1fc 100644
--- a/download_action.cc
+++ b/download_action.cc
@@ -27,7 +27,7 @@
system_state_(system_state),
http_fetcher_(http_fetcher),
writer_(NULL),
- code_(kActionCodeSuccess),
+ code_(kErrorCodeSuccess),
delegate_(NULL),
bytes_received_(0) {}
@@ -57,7 +57,7 @@
if (rc < 0) {
LOG(ERROR) << "Unable to open output file " << install_plan_.install_path;
// report error to processor
- processor_->ActionComplete(this, kActionCodeInstallDeviceOpenError);
+ processor_->ActionComplete(this, kErrorCodeInstallDeviceOpenError);
return;
}
if (delta_performer_.get() &&
@@ -66,7 +66,7 @@
LOG(ERROR) << "Unable to open kernel file "
<< install_plan_.kernel_install_path.c_str();
writer_->Close();
- processor_->ActionComplete(this, kActionCodeKernelDeviceOpenError);
+ processor_->ActionComplete(this, kErrorCodeKernelDeviceOpenError);
return;
}
if (delegate_) {
@@ -117,12 +117,12 @@
if (delegate_) {
delegate_->SetDownloadStatus(false); // Set to inactive.
}
- ActionExitCode code =
- successful ? kActionCodeSuccess : kActionCodeDownloadTransferError;
- if (code == kActionCodeSuccess && delta_performer_.get()) {
+ ErrorCode code =
+ successful ? kErrorCodeSuccess : kErrorCodeDownloadTransferError;
+ if (code == kErrorCodeSuccess && delta_performer_.get()) {
code = delta_performer_->VerifyPayload(install_plan_.payload_hash,
install_plan_.payload_size);
- if (code != kActionCodeSuccess) {
+ if (code != kErrorCodeSuccess) {
LOG(ERROR) << "Download of " << install_plan_.download_url
<< " failed due to payload verification error.";
} else if (!delta_performer_->GetNewPartitionInfo(
@@ -131,18 +131,18 @@
&install_plan_.rootfs_size,
&install_plan_.rootfs_hash)) {
LOG(ERROR) << "Unable to get new partition hash info.";
- code = kActionCodeDownloadNewPartitionInfoError;
+ code = kErrorCodeDownloadNewPartitionInfoError;
}
}
// Write the path to the output pipe if we're successful.
- if (code == kActionCodeSuccess && HasOutputPipe())
+ if (code == kErrorCodeSuccess && HasOutputPipe())
SetOutputObject(install_plan_);
processor_->ActionComplete(this, code);
}
void DownloadAction::TransferTerminated(HttpFetcher *fetcher) {
- if (code_ != kActionCodeSuccess) {
+ if (code_ != kErrorCodeSuccess) {
processor_->ActionComplete(this, code_);
}
}
diff --git a/download_action.h b/download_action.h
index 6e334f6..318ece8 100644
--- a/download_action.h
+++ b/download_action.h
@@ -114,7 +114,7 @@
// Used by TransferTerminated to figure if this action terminated itself or
// was terminated by the action processor.
- ActionExitCode code_;
+ ErrorCode code_;
// For reporting status to outsiders
DownloadActionDelegate* delegate_;
diff --git a/download_action_unittest.cc b/download_action_unittest.cc
index 657155b..3911d55 100644
--- a/download_action_unittest.cc
+++ b/download_action_unittest.cc
@@ -36,7 +36,7 @@
class DownloadActionTestProcessorDelegate : public ActionProcessorDelegate {
public:
- explicit DownloadActionTestProcessorDelegate(ActionExitCode expected_code)
+ explicit DownloadActionTestProcessorDelegate(ErrorCode expected_code)
: loop_(NULL),
processing_done_called_(false),
expected_code_(expected_code) {}
@@ -44,12 +44,12 @@
EXPECT_TRUE(processing_done_called_);
}
virtual void ProcessingDone(const ActionProcessor* processor,
- ActionExitCode code) {
+ ErrorCode code) {
ASSERT_TRUE(loop_);
g_main_loop_quit(loop_);
vector<char> found_data;
ASSERT_TRUE(utils::ReadFile(path_, &found_data));
- if (expected_code_ != kActionCodeDownloadWriteError) {
+ if (expected_code_ != kErrorCodeDownloadWriteError) {
ASSERT_EQ(expected_data_.size(), found_data.size());
for (unsigned i = 0; i < expected_data_.size(); i++) {
EXPECT_EQ(expected_data_[i], found_data[i]);
@@ -60,12 +60,12 @@
virtual void ActionCompleted(ActionProcessor* processor,
AbstractAction* action,
- ActionExitCode code) {
+ ErrorCode code) {
const string type = action->Type();
if (type == DownloadAction::StaticType()) {
EXPECT_EQ(expected_code_, code);
} else {
- EXPECT_EQ(kActionCodeSuccess, code);
+ EXPECT_EQ(kErrorCodeSuccess, code);
}
}
@@ -73,7 +73,7 @@
string path_;
vector<char> expected_data_;
bool processing_done_called_;
- ActionExitCode expected_code_;
+ ErrorCode expected_code_;
};
class TestDirectFileWriter : public DirectFileWriter {
@@ -159,9 +159,9 @@
EXPECT_CALL(download_delegate, BytesReceived(_, _)).Times(AtLeast(1));
EXPECT_CALL(download_delegate, SetDownloadStatus(false)).Times(1);
}
- ActionExitCode expected_code = kActionCodeSuccess;
+ ErrorCode expected_code = kErrorCodeSuccess;
if (fail_write > 0)
- expected_code = kActionCodeDownloadWriteError;
+ expected_code = kErrorCodeDownloadWriteError;
DownloadActionTestProcessorDelegate delegate(expected_code);
delegate.loop_ = loop;
delegate.expected_data_ = vector<char>(data.begin() + 1, data.end());
@@ -320,7 +320,7 @@
ASSERT_TRUE(HasInputObject());
EXPECT_TRUE(expected_input_object_ == GetInputObject());
ASSERT_TRUE(processor());
- processor()->ActionComplete(this, kActionCodeSuccess);
+ processor()->ActionComplete(this, kErrorCodeSuccess);
}
string Type() const { return "DownloadActionTestAction"; }
InstallPlan expected_input_object_;
@@ -333,7 +333,7 @@
// only by the test PassObjectOutTest.
class PassObjectOutTestProcessorDelegate : public ActionProcessorDelegate {
public:
- void ProcessingDone(const ActionProcessor* processor, ActionExitCode code) {
+ void ProcessingDone(const ActionProcessor* processor, ErrorCode code) {
ASSERT_TRUE(loop_);
g_main_loop_quit(loop_);
}
diff --git a/error_code.h b/error_code.h
new file mode 100644
index 0000000..db023f7
--- /dev/null
+++ b/error_code.h
@@ -0,0 +1,107 @@
+// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_ERROR_CODE_H__
+#define CHROMEOS_PLATFORM_UPDATE_ENGINE_ERROR_CODE_H__
+
+namespace chromeos_update_engine {
+
+// Action exit codes.
+enum ErrorCode {
+ kErrorCodeSuccess = 0,
+ kErrorCodeError = 1,
+ kErrorCodeOmahaRequestError = 2,
+ kErrorCodeOmahaResponseHandlerError = 3,
+ kErrorCodeFilesystemCopierError = 4,
+ kErrorCodePostinstallRunnerError = 5,
+ kErrorCodeSetBootableFlagError = 6, // TODO(petkov): Unused. Recycle?
+ kErrorCodeInstallDeviceOpenError = 7,
+ kErrorCodeKernelDeviceOpenError = 8,
+ kErrorCodeDownloadTransferError = 9,
+ kErrorCodePayloadHashMismatchError = 10,
+ kErrorCodePayloadSizeMismatchError = 11,
+ kErrorCodeDownloadPayloadVerificationError = 12,
+ kErrorCodeDownloadNewPartitionInfoError = 13,
+ kErrorCodeDownloadWriteError = 14,
+ kErrorCodeNewRootfsVerificationError = 15,
+ kErrorCodeNewKernelVerificationError = 16,
+ kErrorCodeSignedDeltaPayloadExpectedError = 17,
+ kErrorCodeDownloadPayloadPubKeyVerificationError = 18,
+ kErrorCodePostinstallBootedFromFirmwareB = 19,
+ kErrorCodeDownloadStateInitializationError = 20,
+ kErrorCodeDownloadInvalidMetadataMagicString = 21,
+ kErrorCodeDownloadSignatureMissingInManifest = 22,
+ kErrorCodeDownloadManifestParseError = 23,
+ kErrorCodeDownloadMetadataSignatureError = 24,
+ kErrorCodeDownloadMetadataSignatureVerificationError = 25,
+ kErrorCodeDownloadMetadataSignatureMismatch = 26,
+ kErrorCodeDownloadOperationHashVerificationError = 27,
+ kErrorCodeDownloadOperationExecutionError = 28,
+ kErrorCodeDownloadOperationHashMismatch = 29,
+ kErrorCodeOmahaRequestEmptyResponseError = 30,
+ kErrorCodeOmahaRequestXMLParseError = 31,
+ kErrorCodeDownloadInvalidMetadataSize = 32,
+ kErrorCodeDownloadInvalidMetadataSignature = 33,
+ kErrorCodeOmahaResponseInvalid = 34,
+ kErrorCodeOmahaUpdateIgnoredPerPolicy = 35,
+ kErrorCodeOmahaUpdateDeferredPerPolicy = 36,
+ kErrorCodeOmahaErrorInHTTPResponse = 37,
+ kErrorCodeDownloadOperationHashMissingError = 38,
+ kErrorCodeDownloadMetadataSignatureMissingError = 39,
+ kErrorCodeOmahaUpdateDeferredForBackoff = 40,
+ kErrorCodePostinstallPowerwashError = 41,
+ kErrorCodeUpdateCanceledByChannelChange = 42,
+
+ // Note: When adding new error codes, please remember to add the
+ // error into one of the buckets in PayloadState::UpdateFailed method so
+ // that the retries across URLs and the payload backoff mechanism work
+ // correctly for those new error codes.
+
+ // Any code above this is sent to both Omaha and UMA as-is, except
+ // kErrorCodeOmahaErrorInHTTPResponse (see error code 2000 for more details).
+ // Codes/flags below this line is sent only to Omaha and not to UMA.
+
+ // kErrorCodeUmaReportedMax is not an error code per se, it's just the count
+ // of the number of enums above. Add any new errors above this line if you
+ // want them to show up on UMA. Stuff below this line will not be sent to UMA
+ // but is used for other errors that are sent to Omaha. We don't assign any
+ // particular value for this enum so that it's just one more than the last
+ // one above and thus always represents the correct count of UMA metrics
+ // buckets, even when new enums are added above this line in future. See
+ // utils::SendErrorCodeToUma on how this enum is used.
+ kErrorCodeUmaReportedMax,
+
+ // use the 2xxx range to encode HTTP errors. These errors are available in
+ // Dremel with the individual granularity. But for UMA purposes, all these
+ // errors are aggregated into one: kErrorCodeOmahaErrorInHTTPResponse.
+ kErrorCodeOmahaRequestHTTPResponseBase = 2000, // + HTTP response code
+
+ // TODO(jaysri): Move out all the bit masks into separate constants
+ // outside the enum as part of fixing bug 34369.
+ // Bit flags. Remember to update the mask below for new bits.
+
+ // Set if boot mode not normal.
+ kErrorCodeDevModeFlag = 1 << 31,
+
+ // Set if resuming an interruped update.
+ kErrorCodeResumedFlag = 1 << 30,
+
+ // Set if using a dev/test image as opposed to an MP-signed image.
+ kErrorCodeTestImageFlag = 1 << 29,
+
+ // Set if using devserver or Omaha sandbox (using crosh autest).
+ kErrorCodeTestOmahaUrlFlag = 1 << 28,
+
+ // Mask that indicates bit positions that are used to indicate special flags
+ // that are embedded in the error code to provide additional context about
+ // the system in which the error was encountered.
+ kErrorCodeSpecialFlags = (kErrorCodeDevModeFlag |
+ kErrorCodeResumedFlag |
+ kErrorCodeTestImageFlag |
+ kErrorCodeTestOmahaUrlFlag)
+};
+
+} // namespace chromeos_update_engine
+
+#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_ACTION_PROCESSOR_H__
diff --git a/file_writer.h b/file_writer.h
index b9b45e8..57d0498 100644
--- a/file_writer.h
+++ b/file_writer.h
@@ -38,8 +38,8 @@
// can override if they wish to return more specific error codes.
virtual bool Write(const void* bytes,
size_t count,
- ActionExitCode* error) {
- *error = kActionCodeDownloadWriteError;
+ ErrorCode* error) {
+ *error = kErrorCodeDownloadWriteError;
return Write(bytes, count);
}
diff --git a/filesystem_copier_action.cc b/filesystem_copier_action.cc
index 1561f93..7024b67 100644
--- a/filesystem_copier_action.cc
+++ b/filesystem_copier_action.cc
@@ -73,7 +73,7 @@
// No copy or hash verification needed. Done!
if (HasOutputPipe())
SetOutputObject(install_plan_);
- abort_action_completer.set_code(kActionCodeSuccess);
+ abort_action_completer.set_code(kErrorCodeSuccess);
return;
}
@@ -132,7 +132,7 @@
return (src_stream_ != NULL);
}
-void FilesystemCopierAction::Cleanup(ActionExitCode code) {
+void FilesystemCopierAction::Cleanup(ErrorCode code) {
for (int i = 0; i < 2; i++) {
g_object_unref(canceller_[i]);
canceller_[i] = NULL;
@@ -145,7 +145,7 @@
}
if (cancelled_)
return;
- if (code == kActionCodeSuccess && HasOutputPipe())
+ if (code == kErrorCodeSuccess && HasOutputPipe())
SetOutputObject(install_plan_);
processor_->ActionComplete(this, code);
}
@@ -244,7 +244,7 @@
}
if (failed_ || cancelled_) {
if (!reading && !writing) {
- Cleanup(kActionCodeError);
+ Cleanup(kErrorCodeError);
}
return;
}
@@ -278,18 +278,18 @@
}
if (!reading && !writing) {
// We're done!
- ActionExitCode code = kActionCodeSuccess;
+ ErrorCode code = kErrorCodeSuccess;
if (hasher_.Finalize()) {
LOG(INFO) << "Hash: " << hasher_.hash();
if (verify_hash_) {
if (copying_kernel_install_path_) {
if (install_plan_.kernel_hash != hasher_.raw_hash()) {
- code = kActionCodeNewKernelVerificationError;
+ code = kErrorCodeNewKernelVerificationError;
LOG(ERROR) << "New kernel verification failed.";
}
} else {
if (install_plan_.rootfs_hash != hasher_.raw_hash()) {
- code = kActionCodeNewRootfsVerificationError;
+ code = kErrorCodeNewRootfsVerificationError;
LOG(ERROR) << "New rootfs verification failed.";
}
}
@@ -302,7 +302,7 @@
}
} else {
LOG(ERROR) << "Unable to finalize the hash.";
- code = kActionCodeError;
+ code = kErrorCodeError;
}
Cleanup(code);
}
diff --git a/filesystem_copier_action.h b/filesystem_copier_action.h
index 366ae40..acbdd05 100644
--- a/filesystem_copier_action.h
+++ b/filesystem_copier_action.h
@@ -91,7 +91,7 @@
// Cleans up all the variables we use for async operations and tells the
// ActionProcessor we're done w/ |code| as passed in. |cancelled_| should be
// true if TerminateProcessing() was called.
- void Cleanup(ActionExitCode code);
+ void Cleanup(ErrorCode code);
// Determine, if possible, the source file system size to avoid copying the
// whole partition. Currently this supports only the root file system assuming
diff --git a/filesystem_copier_action_unittest.cc b/filesystem_copier_action_unittest.cc
index bf44c4f..3ffed88 100644
--- a/filesystem_copier_action_unittest.cc
+++ b/filesystem_copier_action_unittest.cc
@@ -45,7 +45,7 @@
public:
FilesystemCopierActionTestDelegate(GMainLoop* loop,
FilesystemCopierAction* action)
- : loop_(loop), action_(action), ran_(false), code_(kActionCodeError) {}
+ : loop_(loop), action_(action), ran_(false), code_(kErrorCodeError) {}
void ExitMainLoop() {
GMainContext* context = g_main_loop_get_context(loop_);
// We cannot use g_main_context_pending() alone to determine if it is safe
@@ -58,7 +58,7 @@
}
g_main_loop_quit(loop_);
}
- void ProcessingDone(const ActionProcessor* processor, ActionExitCode code) {
+ void ProcessingDone(const ActionProcessor* processor, ErrorCode code) {
ExitMainLoop();
}
void ProcessingStopped(const ActionProcessor* processor) {
@@ -66,19 +66,19 @@
}
void ActionCompleted(ActionProcessor* processor,
AbstractAction* action,
- ActionExitCode code) {
+ ErrorCode code) {
if (action->Type() == FilesystemCopierAction::StaticType()) {
ran_ = true;
code_ = code;
}
}
bool ran() const { return ran_; }
- ActionExitCode code() const { return code_; }
+ ErrorCode code() const { return code_; }
private:
GMainLoop* loop_;
FilesystemCopierAction* action_;
bool ran_;
- ActionExitCode code_;
+ ErrorCode code_;
};
struct StartProcessorCallbackArgs {
@@ -229,18 +229,18 @@
success = success && is_delegate_ran;
}
if (run_out_of_space || terminate_early) {
- EXPECT_EQ(kActionCodeError, delegate.code());
- return (kActionCodeError == delegate.code());
+ EXPECT_EQ(kErrorCodeError, delegate.code());
+ return (kErrorCodeError == delegate.code());
}
if (verify_hash == 2) {
- ActionExitCode expected_exit_code =
+ ErrorCode expected_exit_code =
(use_kernel_partition ?
- kActionCodeNewKernelVerificationError :
- kActionCodeNewRootfsVerificationError);
+ kErrorCodeNewKernelVerificationError :
+ kErrorCodeNewRootfsVerificationError);
EXPECT_EQ(expected_exit_code, delegate.code());
return (expected_exit_code == delegate.code());
}
- EXPECT_EQ(kActionCodeSuccess, delegate.code());
+ EXPECT_EQ(kErrorCodeSuccess, delegate.code());
// Make sure everything in the out_image is there
vector<char> a_out;
@@ -273,7 +273,7 @@
public:
void ActionCompleted(ActionProcessor* processor,
AbstractAction* action,
- ActionExitCode code) {
+ ErrorCode code) {
if (action->Type() == FilesystemCopierAction::StaticType()) {
ran_ = true;
code_ = code;
@@ -281,7 +281,7 @@
}
GMainLoop *loop_;
bool ran_;
- ActionExitCode code_;
+ ErrorCode code_;
};
TEST_F(FilesystemCopierActionTest, MissingInputObjectTest) {
@@ -300,7 +300,7 @@
processor.StartProcessing();
EXPECT_FALSE(processor.IsRunning());
EXPECT_TRUE(delegate.ran_);
- EXPECT_EQ(kActionCodeError, delegate.code_);
+ EXPECT_EQ(kErrorCodeError, delegate.code_);
}
TEST_F(FilesystemCopierActionTest, ResumeTest) {
@@ -325,7 +325,7 @@
processor.StartProcessing();
EXPECT_FALSE(processor.IsRunning());
EXPECT_TRUE(delegate.ran_);
- EXPECT_EQ(kActionCodeSuccess, delegate.code_);
+ EXPECT_EQ(kErrorCodeSuccess, delegate.code_);
EXPECT_EQ(kUrl, collector_action.object().download_url);
}
@@ -356,7 +356,7 @@
processor.StartProcessing();
EXPECT_FALSE(processor.IsRunning());
EXPECT_TRUE(delegate.ran_);
- EXPECT_EQ(kActionCodeError, delegate.code_);
+ EXPECT_EQ(kErrorCodeError, delegate.code_);
}
TEST_F(FilesystemCopierActionTest, RunAsRootVerifyHashTest) {
diff --git a/integration_unittest.cc b/integration_unittest.cc
index e54c0e2..af5fee4 100644
--- a/integration_unittest.cc
+++ b/integration_unittest.cc
@@ -42,16 +42,16 @@
EXPECT_TRUE(processing_done_called_);
}
virtual void ProcessingDone(const ActionProcessor* processor,
- ActionExitCode code) {
+ ErrorCode code) {
processing_done_called_ = true;
g_main_loop_quit(loop_);
}
virtual void ActionCompleted(ActionProcessor* processor,
AbstractAction* action,
- ActionExitCode code) {
+ ErrorCode code) {
// make sure actions always succeed
- EXPECT_EQ(kActionCodeSuccess, code);
+ EXPECT_EQ(kErrorCodeSuccess, code);
// Swap in the device path for PostinstallRunnerAction with a loop device
if (action->Type() == InstallAction::StaticType()) {
diff --git a/mock_payload_state.h b/mock_payload_state.h
index 88578b5..65d99da 100644
--- a/mock_payload_state.h
+++ b/mock_payload_state.h
@@ -24,7 +24,7 @@
MOCK_METHOD0(UpdateResumed, void());
MOCK_METHOD0(UpdateRestarted, void());
MOCK_METHOD0(UpdateSucceeded, void());
- MOCK_METHOD1(UpdateFailed, void(ActionExitCode error));
+ MOCK_METHOD1(UpdateFailed, void(ErrorCode error));
MOCK_METHOD0(ShouldBackoffDownload, bool());
// Getters.
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index 6d2ade4..f2c5c6b 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -327,7 +327,7 @@
if (ping_only_ &&
!ShouldPing(ping_active_days_) &&
!ShouldPing(ping_roll_call_days_)) {
- processor_->ActionComplete(this, kActionCodeSuccess);
+ processor_->ActionComplete(this, kErrorCodeSuccess);
return;
}
string request_post(GetRequestXml(event_.get(),
@@ -448,7 +448,7 @@
scoped_ptr_malloc<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
xpath_nodeset(GetNodeSet(doc, ConstXMLStr(kUpdatecheckNodeXpath)));
if (!xpath_nodeset.get()) {
- completer->set_code(kActionCodeOmahaResponseInvalid);
+ completer->set_code(kErrorCodeOmahaResponseInvalid);
return false;
}
@@ -490,7 +490,7 @@
output_object->update_exists = true;
SetOutputObject(*output_object);
- completer->set_code(kActionCodeSuccess);
+ completer->set_code(kErrorCodeSuccess);
return true;
}
@@ -501,7 +501,7 @@
// Get status.
if (!xmlHasProp(update_check_node, ConstXMLStr("status"))) {
LOG(ERROR) << "Omaha Response missing status";
- completer->set_code(kActionCodeOmahaResponseInvalid);
+ completer->set_code(kErrorCodeOmahaResponseInvalid);
return false;
}
@@ -510,13 +510,13 @@
LOG(INFO) << "No update.";
output_object->update_exists = false;
SetOutputObject(*output_object);
- completer->set_code(kActionCodeSuccess);
+ completer->set_code(kErrorCodeSuccess);
return false;
}
if (status != "ok") {
LOG(ERROR) << "Unknown Omaha response status: " << status;
- completer->set_code(kActionCodeOmahaResponseInvalid);
+ completer->set_code(kErrorCodeOmahaResponseInvalid);
return false;
}
@@ -532,7 +532,7 @@
scoped_ptr_malloc<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
xpath_nodeset(GetNodeSet(doc, ConstXMLStr(kUpdateUrlNodeXPath)));
if (!xpath_nodeset.get()) {
- completer->set_code(kActionCodeOmahaResponseInvalid);
+ completer->set_code(kErrorCodeOmahaResponseInvalid);
return false;
}
@@ -548,7 +548,7 @@
const string codebase(XmlGetProperty(url_node, "codebase"));
if (codebase.empty()) {
LOG(ERROR) << "Omaha Response URL has empty codebase";
- completer->set_code(kActionCodeOmahaResponseInvalid);
+ completer->set_code(kErrorCodeOmahaResponseInvalid);
return false;
}
output_object->payload_urls.push_back(codebase);
@@ -567,7 +567,7 @@
scoped_ptr_malloc<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
xpath_nodeset(GetNodeSet(doc, ConstXMLStr(kPackageNodeXPath)));
if (!xpath_nodeset.get()) {
- completer->set_code(kActionCodeOmahaResponseInvalid);
+ completer->set_code(kErrorCodeOmahaResponseInvalid);
return false;
}
@@ -586,7 +586,7 @@
LOG(INFO) << "Omaha Response package name = " << package_name;
if (package_name.empty()) {
LOG(ERROR) << "Omaha Response has empty package name";
- completer->set_code(kActionCodeOmahaResponseInvalid);
+ completer->set_code(kErrorCodeOmahaResponseInvalid);
return false;
}
@@ -602,7 +602,7 @@
off_t size = ParseInt(XmlGetProperty(package_node, "size"));
if (size <= 0) {
LOG(ERROR) << "Omaha Response has invalid payload size: " << size;
- completer->set_code(kActionCodeOmahaResponseInvalid);
+ completer->set_code(kErrorCodeOmahaResponseInvalid);
return false;
}
output_object->size = size;
@@ -622,7 +622,7 @@
scoped_ptr_malloc<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
xpath_nodeset(GetNodeSet(doc, ConstXMLStr(kActionNodeXPath)));
if (!xpath_nodeset.get()) {
- completer->set_code(kActionCodeOmahaResponseInvalid);
+ completer->set_code(kErrorCodeOmahaResponseInvalid);
return false;
}
@@ -647,14 +647,14 @@
if (!pie_action_node) {
LOG(ERROR) << "Omaha Response has no postinstall event action";
- completer->set_code(kActionCodeOmahaResponseInvalid);
+ completer->set_code(kErrorCodeOmahaResponseInvalid);
return false;
}
output_object->hash = XmlGetProperty(pie_action_node, kTagSha256);
if (output_object->hash.empty()) {
LOG(ERROR) << "Omaha Response has empty sha256 value";
- completer->set_code(kActionCodeOmahaResponseInvalid);
+ completer->set_code(kErrorCodeOmahaResponseInvalid);
return false;
}
@@ -701,7 +701,7 @@
LOG(INFO) << "Signalling Crash Reporter.";
utils::ScheduleCrashReporterUpload();
}
- completer.set_code(kActionCodeSuccess);
+ completer.set_code(kErrorCodeSuccess);
return;
}
@@ -712,8 +712,8 @@
if (code < 0 || code >= 1000) {
code = 999;
}
- completer.set_code(static_cast<ActionExitCode>(
- kActionCodeOmahaRequestHTTPResponseBase + code));
+ completer.set_code(static_cast<ErrorCode>(
+ kErrorCodeOmahaRequestHTTPResponseBase + code));
return;
}
@@ -723,8 +723,8 @@
if (!doc.get()) {
LOG(ERROR) << "Omaha response not valid XML";
completer.set_code(response_buffer_.empty() ?
- kActionCodeOmahaRequestEmptyResponseError :
- kActionCodeOmahaRequestXMLParseError);
+ kErrorCodeOmahaRequestEmptyResponseError :
+ kErrorCodeOmahaRequestXMLParseError);
return;
}
@@ -741,7 +741,7 @@
if (!HasOutputPipe()) {
// Just set success to whether or not the http transfer succeeded,
// which must be true at this point in the code.
- completer.set_code(kActionCodeSuccess);
+ completer.set_code(kErrorCodeSuccess);
return;
}
@@ -752,7 +752,7 @@
if (params_->update_disabled()) {
LOG(INFO) << "Ignoring Omaha updates as updates are disabled by policy.";
output_object.update_exists = false;
- completer.set_code(kActionCodeOmahaUpdateIgnoredPerPolicy);
+ completer.set_code(kErrorCodeOmahaUpdateIgnoredPerPolicy);
// Note: We could technically delete the UpdateFirstSeenAt state here.
// If we do, it'll mean a device has to restart the UpdateFirstSeenAt
// and thus help scattering take effect when the AU is turned on again.
@@ -766,7 +766,7 @@
if (ShouldDeferDownload(&output_object)) {
output_object.update_exists = false;
LOG(INFO) << "Ignoring Omaha updates as updates are deferred by policy.";
- completer.set_code(kActionCodeOmahaUpdateDeferredPerPolicy);
+ completer.set_code(kErrorCodeOmahaUpdateDeferredPerPolicy);
return;
}
@@ -783,7 +783,7 @@
output_object.update_exists = false;
LOG(INFO) << "Ignoring Omaha updates in order to backoff our retry "
"attempts";
- completer.set_code(kActionCodeOmahaUpdateDeferredForBackoff);
+ completer.set_code(kErrorCodeOmahaUpdateDeferredForBackoff);
return;
}
}
diff --git a/omaha_request_action.h b/omaha_request_action.h
index 528ce19..7a4d3f2 100644
--- a/omaha_request_action.h
+++ b/omaha_request_action.h
@@ -54,19 +54,19 @@
OmahaEvent()
: type(kTypeUnknown),
result(kResultError),
- error_code(kActionCodeError) {}
+ error_code(kErrorCodeError) {}
explicit OmahaEvent(Type in_type)
: type(in_type),
result(kResultSuccess),
- error_code(kActionCodeSuccess) {}
- OmahaEvent(Type in_type, Result in_result, ActionExitCode in_error_code)
+ error_code(kErrorCodeSuccess) {}
+ OmahaEvent(Type in_type, Result in_result, ErrorCode in_error_code)
: type(in_type),
result(in_result),
error_code(in_error_code) {}
Type type;
Result result;
- ActionExitCode error_code;
+ ErrorCode error_code;
};
class NoneType;
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index c3a3f1b..8ae951e 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -130,26 +130,26 @@
public:
OmahaRequestActionTestProcessorDelegate()
: loop_(NULL),
- expected_code_(kActionCodeSuccess) {}
+ expected_code_(kErrorCodeSuccess) {}
virtual ~OmahaRequestActionTestProcessorDelegate() {
}
virtual void ProcessingDone(const ActionProcessor* processor,
- ActionExitCode code) {
+ ErrorCode code) {
ASSERT_TRUE(loop_);
g_main_loop_quit(loop_);
}
virtual void ActionCompleted(ActionProcessor* processor,
AbstractAction* action,
- ActionExitCode code) {
+ ErrorCode code) {
// make sure actions always succeed
if (action->Type() == OmahaRequestAction::StaticType())
EXPECT_EQ(expected_code_, code);
else
- EXPECT_EQ(kActionCodeSuccess, code);
+ EXPECT_EQ(kErrorCodeSuccess, code);
}
GMainLoop *loop_;
- ActionExitCode expected_code_;
+ ErrorCode expected_code_;
};
gboolean StartProcessorInRunLoop(gpointer data) {
@@ -178,7 +178,7 @@
has_input_object_ = HasInputObject();
if (has_input_object_)
omaha_response_ = GetInputObject();
- processor_->ActionComplete(this, kActionCodeSuccess);
+ processor_->ActionComplete(this, kErrorCodeSuccess);
}
// Should never be called
void TerminateProcessing() {
@@ -204,7 +204,7 @@
const string& http_response,
int fail_http_response_code,
bool ping_only,
- ActionExitCode expected_code,
+ ErrorCode expected_code,
OmahaResponse* out_response,
vector<char>* out_post_data) {
GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE);
@@ -279,7 +279,7 @@
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
false, // ping_only
- kActionCodeSuccess,
+ kErrorCodeSuccess,
&response,
NULL));
EXPECT_FALSE(response.update_exists);
@@ -302,7 +302,7 @@
"20101020"), // deadline
-1,
false, // ping_only
- kActionCodeSuccess,
+ kErrorCodeSuccess,
&response,
NULL));
EXPECT_TRUE(response.update_exists);
@@ -335,7 +335,7 @@
""), // deadline
-1,
false, // ping_only
- kActionCodeOmahaUpdateIgnoredPerPolicy,
+ kErrorCodeOmahaUpdateIgnoredPerPolicy,
&response,
NULL));
EXPECT_FALSE(response.update_exists);
@@ -351,7 +351,7 @@
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
false, // ping_only
- kActionCodeSuccess,
+ kErrorCodeSuccess,
&response,
NULL));
EXPECT_FALSE(response.update_exists);
@@ -389,7 +389,7 @@
"7"), // max days to scatter
-1,
false, // ping_only
- kActionCodeOmahaUpdateDeferredPerPolicy,
+ kErrorCodeOmahaUpdateDeferredPerPolicy,
&response,
NULL));
EXPECT_FALSE(response.update_exists);
@@ -430,7 +430,7 @@
"7"), // max days to scatter
-1,
false, // ping_only
- kActionCodeSuccess,
+ kErrorCodeSuccess,
&response,
NULL));
EXPECT_TRUE(response.update_exists);
@@ -471,7 +471,7 @@
"0"), // max days to scatter
-1,
false, // ping_only
- kActionCodeSuccess,
+ kErrorCodeSuccess,
&response,
NULL));
EXPECT_TRUE(response.update_exists);
@@ -513,7 +513,7 @@
"7"), // max days to scatter
-1,
false, // ping_only
- kActionCodeSuccess,
+ kErrorCodeSuccess,
&response,
NULL));
@@ -558,7 +558,7 @@
"7"), // max days to scatter
-1,
false, // ping_only
- kActionCodeOmahaUpdateDeferredPerPolicy,
+ kErrorCodeOmahaUpdateDeferredPerPolicy,
&response,
NULL));
@@ -605,7 +605,7 @@
"7"), // max days to scatter
-1,
false, // ping_only
- kActionCodeOmahaUpdateDeferredPerPolicy,
+ kErrorCodeOmahaUpdateDeferredPerPolicy,
&response,
NULL));
@@ -650,7 +650,7 @@
"invalid xml>",
-1,
false, // ping_only
- kActionCodeOmahaRequestXMLParseError,
+ kErrorCodeOmahaRequestXMLParseError,
&response,
NULL));
EXPECT_FALSE(response.update_exists);
@@ -664,7 +664,7 @@
"",
-1,
false, // ping_only
- kActionCodeOmahaRequestEmptyResponseError,
+ kErrorCodeOmahaRequestEmptyResponseError,
&response,
NULL));
EXPECT_FALSE(response.update_exists);
@@ -682,7 +682,7 @@
"<updatecheck/></app></response>",
-1,
false, // ping_only
- kActionCodeOmahaResponseInvalid,
+ kErrorCodeOmahaResponseInvalid,
&response,
NULL));
EXPECT_FALSE(response.update_exists);
@@ -700,7 +700,7 @@
"<updatecheck status=\"InvalidStatusTest\"/></app></response>",
-1,
false, // ping_only
- kActionCodeOmahaResponseInvalid,
+ kErrorCodeOmahaResponseInvalid,
&response,
NULL));
EXPECT_FALSE(response.update_exists);
@@ -718,7 +718,7 @@
"</app></response>",
-1,
false, // ping_only
- kActionCodeOmahaResponseInvalid,
+ kErrorCodeOmahaResponseInvalid,
&response,
NULL));
EXPECT_FALSE(response.update_exists);
@@ -751,7 +751,7 @@
input_response,
-1,
false, // ping_only
- kActionCodeSuccess,
+ kErrorCodeSuccess,
&response,
NULL));
EXPECT_TRUE(response.update_exists);
@@ -839,7 +839,7 @@
"invalid xml>",
-1,
false, // ping_only
- kActionCodeOmahaRequestXMLParseError,
+ kErrorCodeOmahaRequestXMLParseError,
&response,
&post_data));
// convert post_data to string
@@ -871,7 +871,7 @@
"<20110101"), // deadline
-1,
false, // ping_only
- kActionCodeSuccess,
+ kErrorCodeSuccess,
&response,
NULL));
@@ -898,7 +898,7 @@
"deadline"),
-1,
false, // ping_only
- kActionCodeSuccess,
+ kErrorCodeSuccess,
&response,
NULL));
@@ -916,7 +916,7 @@
"invalid xml>",
-1,
false, // ping_only
- kActionCodeOmahaRequestXMLParseError,
+ kErrorCodeOmahaRequestXMLParseError,
NULL, // response
&post_data));
// convert post_data to string
@@ -943,7 +943,7 @@
"invalid xml>",
-1,
false, // ping_only
- kActionCodeOmahaRequestXMLParseError,
+ kErrorCodeOmahaRequestXMLParseError,
NULL, // response
&post_data));
// convert post_data to string
@@ -978,7 +978,7 @@
TestEvent(kDefaultTestParams,
new OmahaEvent(OmahaEvent::kTypeDownloadComplete,
OmahaEvent::kResultError,
- kActionCodeError),
+ kErrorCodeError),
"invalid xml>",
&post_data);
// convert post_data to string
@@ -988,7 +988,7 @@
"errorcode=\"%d\"></event>\n",
OmahaEvent::kTypeDownloadComplete,
OmahaEvent::kResultError,
- kActionCodeError);
+ kErrorCodeError);
EXPECT_NE(post_str.find(expected_event), string::npos);
EXPECT_EQ(post_str.find("updatecheck"), string::npos);
}
@@ -1045,7 +1045,7 @@
"invalid xml>",
-1,
false, // ping_only
- kActionCodeOmahaRequestXMLParseError,
+ kErrorCodeOmahaRequestXMLParseError,
NULL,
&post_data));
// convert post_data to string
@@ -1082,7 +1082,7 @@
"invalid xml>",
-1,
false, // ping_only
- kActionCodeOmahaRequestXMLParseError,
+ kErrorCodeOmahaRequestXMLParseError,
NULL,
&post_data));
// convert post_data to string
@@ -1098,19 +1098,19 @@
OmahaEvent default_event;
EXPECT_EQ(OmahaEvent::kTypeUnknown, default_event.type);
EXPECT_EQ(OmahaEvent::kResultError, default_event.result);
- EXPECT_EQ(kActionCodeError, default_event.error_code);
+ EXPECT_EQ(kErrorCodeError, default_event.error_code);
OmahaEvent success_event(OmahaEvent::kTypeUpdateDownloadStarted);
EXPECT_EQ(OmahaEvent::kTypeUpdateDownloadStarted, success_event.type);
EXPECT_EQ(OmahaEvent::kResultSuccess, success_event.result);
- EXPECT_EQ(kActionCodeSuccess, success_event.error_code);
+ EXPECT_EQ(kErrorCodeSuccess, success_event.error_code);
OmahaEvent error_event(OmahaEvent::kTypeUpdateDownloadFinished,
OmahaEvent::kResultError,
- kActionCodeError);
+ kErrorCodeError);
EXPECT_EQ(OmahaEvent::kTypeUpdateDownloadFinished, error_event.type);
EXPECT_EQ(OmahaEvent::kResultError, error_event.result);
- EXPECT_EQ(kActionCodeError, error_event.error_code);
+ EXPECT_EQ(kErrorCodeError, error_event.error_code);
}
TEST(OmahaRequestActionTest, PingTest) {
@@ -1132,7 +1132,7 @@
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
ping_only,
- kActionCodeSuccess,
+ kErrorCodeSuccess,
NULL,
&post_data));
string post_str(&post_data[0], post_data.size());
@@ -1164,7 +1164,7 @@
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
false, // ping_only
- kActionCodeSuccess,
+ kErrorCodeSuccess,
NULL,
&post_data));
string post_str(&post_data[0], post_data.size());
@@ -1188,7 +1188,7 @@
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
false, // ping_only
- kActionCodeSuccess,
+ kErrorCodeSuccess,
NULL,
&post_data));
string post_str(&post_data[0], post_data.size());
@@ -1213,7 +1213,7 @@
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
false, // ping_only
- kActionCodeSuccess,
+ kErrorCodeSuccess,
NULL,
&post_data));
string post_str(&post_data[0], post_data.size());
@@ -1237,7 +1237,7 @@
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
true, // ping_only
- kActionCodeSuccess,
+ kErrorCodeSuccess,
NULL,
&post_data));
EXPECT_EQ(post_data.size(), 0);
@@ -1265,7 +1265,7 @@
"<updatecheck status=\"noupdate\"/></app></response>",
-1,
false, // ping_only
- kActionCodeSuccess,
+ kErrorCodeSuccess,
NULL,
&post_data));
string post_str(&post_data[0], post_data.size());
@@ -1297,7 +1297,7 @@
"<updatecheck status=\"noupdate\"/></app></response>",
-1,
false, // ping_only
- kActionCodeSuccess,
+ kErrorCodeSuccess,
NULL,
NULL));
}
@@ -1315,7 +1315,7 @@
"<updatecheck status=\"noupdate\"/></app></response>",
-1,
false, // ping_only
- kActionCodeSuccess,
+ kErrorCodeSuccess,
NULL,
NULL));
}
@@ -1333,7 +1333,7 @@
"<updatecheck status=\"noupdate\"/></app></response>",
-1,
false, // ping_only
- kActionCodeSuccess,
+ kErrorCodeSuccess,
NULL,
NULL));
}
@@ -1345,7 +1345,7 @@
"invalid xml>",
-1,
false, // ping_only
- kActionCodeOmahaRequestXMLParseError,
+ kErrorCodeOmahaRequestXMLParseError,
NULL, // response
&post_data));
// convert post_data to string
@@ -1362,8 +1362,8 @@
"",
501,
false, // ping_only
- static_cast<ActionExitCode>(
- kActionCodeOmahaRequestHTTPResponseBase + 501),
+ static_cast<ErrorCode>(
+ kErrorCodeOmahaRequestHTTPResponseBase + 501),
&response,
NULL));
EXPECT_FALSE(response.update_exists);
@@ -1377,8 +1377,8 @@
"",
1500,
false, // ping_only
- static_cast<ActionExitCode>(
- kActionCodeOmahaRequestHTTPResponseBase + 999),
+ static_cast<ErrorCode>(
+ kErrorCodeOmahaRequestHTTPResponseBase + 999),
&response,
NULL));
EXPECT_FALSE(response.update_exists);
@@ -1416,7 +1416,7 @@
"7"), // max days to scatter
-1,
false, // ping_only
- kActionCodeOmahaUpdateDeferredPerPolicy,
+ kErrorCodeOmahaUpdateDeferredPerPolicy,
&response,
NULL));
@@ -1463,7 +1463,7 @@
"7"), // max days to scatter
-1,
false, // ping_only
- kActionCodeSuccess,
+ kErrorCodeSuccess,
&response,
NULL));
@@ -1504,7 +1504,7 @@
"invalid xml>",
-1,
false, // ping_only
- kActionCodeOmahaRequestXMLParseError,
+ kErrorCodeOmahaRequestXMLParseError,
NULL, // response
&post_data));
// convert post_data to string
@@ -1543,7 +1543,7 @@
"invalid xml>",
-1,
false, // ping_only
- kActionCodeOmahaRequestXMLParseError,
+ kErrorCodeOmahaRequestXMLParseError,
NULL, // response
&post_data));
// convert post_data to string
diff --git a/omaha_response_handler_action.cc b/omaha_response_handler_action.cc
index f494aa0..ad6a087 100644
--- a/omaha_response_handler_action.cc
+++ b/omaha_response_handler_action.cc
@@ -94,7 +94,7 @@
response.deadline.size());
chmod(kDeadlineFile, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
- completer.set_code(kActionCodeSuccess);
+ completer.set_code(kErrorCodeSuccess);
}
bool OmahaResponseHandlerAction::GetInstallDev(const std::string& boot_dev,
diff --git a/omaha_response_handler_action_unittest.cc b/omaha_response_handler_action_unittest.cc
index cb27f82..15a1f06 100644
--- a/omaha_response_handler_action_unittest.cc
+++ b/omaha_response_handler_action_unittest.cc
@@ -35,17 +35,17 @@
: public ActionProcessorDelegate {
public:
OmahaResponseHandlerActionProcessorDelegate()
- : code_(kActionCodeError),
+ : code_(kErrorCodeError),
code_set_(false) {}
void ActionCompleted(ActionProcessor* processor,
AbstractAction* action,
- ActionExitCode code) {
+ ErrorCode code) {
if (action->Type() == OmahaResponseHandlerAction::StaticType()) {
code_ = code;
code_set_ = true;
}
}
- ActionExitCode code_;
+ ErrorCode code_;
bool code_set_;
};
@@ -91,7 +91,7 @@
if (out)
*out = collector_action.object();
EXPECT_TRUE(delegate.code_set_);
- return delegate.code_ == kActionCodeSuccess;
+ return delegate.code_ == kErrorCodeSuccess;
}
bool OmahaResponseHandlerActionTest::DoTest(const OmahaResponse& in,
diff --git a/payload_signer.cc b/payload_signer.cc
index 26d63db..86114b2 100644
--- a/payload_signer.cc
+++ b/payload_signer.cc
@@ -164,7 +164,7 @@
// Loads the payload and parses the manifest.
TEST_AND_RETURN_FALSE(utils::ReadFile(payload_path, &payload));
LOG(INFO) << "Payload size: " << payload.size();
- ActionExitCode error = kActionCodeSuccess;
+ ErrorCode error = kErrorCodeSuccess;
InstallPlan install_plan;
DeltaPerformer delta_performer(NULL, NULL, &install_plan);
TEST_AND_RETURN_FALSE(delta_performer.ParsePayloadMetadata(
diff --git a/payload_state.cc b/payload_state.cc
index 390dd6a..31c4e42 100644
--- a/payload_state.cc
+++ b/payload_state.cc
@@ -147,8 +147,8 @@
ReportDurationMetrics();
}
-void PayloadState::UpdateFailed(ActionExitCode error) {
- ActionExitCode base_error = utils::GetBaseErrorCode(error);
+void PayloadState::UpdateFailed(ErrorCode error) {
+ ErrorCode base_error = utils::GetBaseErrorCode(error);
LOG(INFO) << "Updating payload state for error code: " << base_error
<< " (" << utils::CodeToString(base_error) << ")";
@@ -164,24 +164,24 @@
// the protocol used in the URL or entities in the communication channel
// (e.g. proxies). We should try the next available URL in the next update
// check to quickly recover from these errors.
- case kActionCodePayloadHashMismatchError:
- case kActionCodePayloadSizeMismatchError:
- case kActionCodeDownloadPayloadVerificationError:
- case kActionCodeDownloadPayloadPubKeyVerificationError:
- case kActionCodeSignedDeltaPayloadExpectedError:
- case kActionCodeDownloadInvalidMetadataMagicString:
- case kActionCodeDownloadSignatureMissingInManifest:
- case kActionCodeDownloadManifestParseError:
- case kActionCodeDownloadMetadataSignatureError:
- case kActionCodeDownloadMetadataSignatureVerificationError:
- case kActionCodeDownloadMetadataSignatureMismatch:
- case kActionCodeDownloadOperationHashVerificationError:
- case kActionCodeDownloadOperationExecutionError:
- case kActionCodeDownloadOperationHashMismatch:
- case kActionCodeDownloadInvalidMetadataSize:
- case kActionCodeDownloadInvalidMetadataSignature:
- case kActionCodeDownloadOperationHashMissingError:
- case kActionCodeDownloadMetadataSignatureMissingError:
+ case kErrorCodePayloadHashMismatchError:
+ case kErrorCodePayloadSizeMismatchError:
+ case kErrorCodeDownloadPayloadVerificationError:
+ case kErrorCodeDownloadPayloadPubKeyVerificationError:
+ case kErrorCodeSignedDeltaPayloadExpectedError:
+ case kErrorCodeDownloadInvalidMetadataMagicString:
+ case kErrorCodeDownloadSignatureMissingInManifest:
+ case kErrorCodeDownloadManifestParseError:
+ case kErrorCodeDownloadMetadataSignatureError:
+ case kErrorCodeDownloadMetadataSignatureVerificationError:
+ case kErrorCodeDownloadMetadataSignatureMismatch:
+ case kErrorCodeDownloadOperationHashVerificationError:
+ case kErrorCodeDownloadOperationExecutionError:
+ case kErrorCodeDownloadOperationHashMismatch:
+ case kErrorCodeDownloadInvalidMetadataSize:
+ case kErrorCodeDownloadInvalidMetadataSignature:
+ case kErrorCodeDownloadOperationHashMissingError:
+ case kErrorCodeDownloadMetadataSignatureMissingError:
IncrementUrlIndex();
break;
@@ -193,11 +193,11 @@
// (because download from a local server URL that appears earlier in a
// response is preferable than downloading from the next URL which could be
// a internet URL and thus could be more expensive).
- case kActionCodeError:
- case kActionCodeDownloadTransferError:
- case kActionCodeDownloadWriteError:
- case kActionCodeDownloadStateInitializationError:
- case kActionCodeOmahaErrorInHTTPResponse: // Aggregate code for HTTP errors.
+ case kErrorCodeError:
+ case kErrorCodeDownloadTransferError:
+ case kErrorCodeDownloadWriteError:
+ case kErrorCodeDownloadStateInitializationError:
+ case kErrorCodeOmahaErrorInHTTPResponse: // Aggregate code for HTTP errors.
IncrementFailureCount();
break;
@@ -210,36 +210,36 @@
// payload attempt number would have been incremented and would take care
// of the backoff at the next update check.
// In either case, there's no need to update URL index or failure count.
- case kActionCodeOmahaRequestError:
- case kActionCodeOmahaResponseHandlerError:
- case kActionCodePostinstallRunnerError:
- case kActionCodeFilesystemCopierError:
- case kActionCodeInstallDeviceOpenError:
- case kActionCodeKernelDeviceOpenError:
- case kActionCodeDownloadNewPartitionInfoError:
- case kActionCodeNewRootfsVerificationError:
- case kActionCodeNewKernelVerificationError:
- case kActionCodePostinstallBootedFromFirmwareB:
- case kActionCodeOmahaRequestEmptyResponseError:
- case kActionCodeOmahaRequestXMLParseError:
- case kActionCodeOmahaResponseInvalid:
- case kActionCodeOmahaUpdateIgnoredPerPolicy:
- case kActionCodeOmahaUpdateDeferredPerPolicy:
- case kActionCodeOmahaUpdateDeferredForBackoff:
- case kActionCodePostinstallPowerwashError:
- case kActionCodeUpdateCanceledByChannelChange:
+ case kErrorCodeOmahaRequestError:
+ case kErrorCodeOmahaResponseHandlerError:
+ case kErrorCodePostinstallRunnerError:
+ case kErrorCodeFilesystemCopierError:
+ case kErrorCodeInstallDeviceOpenError:
+ case kErrorCodeKernelDeviceOpenError:
+ case kErrorCodeDownloadNewPartitionInfoError:
+ case kErrorCodeNewRootfsVerificationError:
+ case kErrorCodeNewKernelVerificationError:
+ case kErrorCodePostinstallBootedFromFirmwareB:
+ case kErrorCodeOmahaRequestEmptyResponseError:
+ case kErrorCodeOmahaRequestXMLParseError:
+ case kErrorCodeOmahaResponseInvalid:
+ case kErrorCodeOmahaUpdateIgnoredPerPolicy:
+ case kErrorCodeOmahaUpdateDeferredPerPolicy:
+ case kErrorCodeOmahaUpdateDeferredForBackoff:
+ case kErrorCodePostinstallPowerwashError:
+ case kErrorCodeUpdateCanceledByChannelChange:
LOG(INFO) << "Not incrementing URL index or failure count for this error";
break;
- case kActionCodeSuccess: // success code
- case kActionCodeSetBootableFlagError: // unused
- case kActionCodeUmaReportedMax: // not an error code
- case kActionCodeOmahaRequestHTTPResponseBase: // aggregated already
- case kActionCodeDevModeFlag: // not an error code
- case kActionCodeResumedFlag: // not an error code
- case kActionCodeTestImageFlag: // not an error code
- case kActionCodeTestOmahaUrlFlag: // not an error code
- case kSpecialFlags: // not an error code
+ case kErrorCodeSuccess: // success code
+ case kErrorCodeSetBootableFlagError: // unused
+ case kErrorCodeUmaReportedMax: // not an error code
+ case kErrorCodeOmahaRequestHTTPResponseBase: // aggregated already
+ case kErrorCodeDevModeFlag: // not an error code
+ case kErrorCodeResumedFlag: // not an error code
+ case kErrorCodeTestImageFlag: // not an error code
+ case kErrorCodeTestOmahaUrlFlag: // not an error code
+ case kErrorCodeSpecialFlags: // not an error code
// These shouldn't happen. Enumerating these explicitly here so that we
// can let the compiler warn about new error codes that are added to
// action_processor.h but not added here.
diff --git a/payload_state.h b/payload_state.h
index b12e6b0..1b0899c 100644
--- a/payload_state.h
+++ b/payload_state.h
@@ -38,7 +38,7 @@
virtual void UpdateResumed();
virtual void UpdateRestarted();
virtual void UpdateSucceeded();
- virtual void UpdateFailed(ActionExitCode error);
+ virtual void UpdateFailed(ErrorCode error);
virtual bool ShouldBackoffDownload();
virtual inline std::string GetResponseSignature() {
diff --git a/payload_state_interface.h b/payload_state_interface.h
index e092290..205cb91 100644
--- a/payload_state_interface.h
+++ b/payload_state_interface.h
@@ -56,7 +56,7 @@
// This method should be called whenever an update attempt fails with the
// given error code. We use this notification to update the payload state
// depending on the type of the error that happened.
- virtual void UpdateFailed(ActionExitCode error) = 0;
+ virtual void UpdateFailed(ErrorCode error) = 0;
// Returns true if we should backoff the current download attempt.
// False otherwise.
diff --git a/payload_state_unittest.cc b/payload_state_unittest.cc
index 28017dc..f7688c2 100644
--- a/payload_state_unittest.cc
+++ b/payload_state_unittest.cc
@@ -73,13 +73,13 @@
class PayloadStateTest : public ::testing::Test { };
-TEST(PayloadStateTest, DidYouAddANewActionExitCode) {
- if (kActionCodeUmaReportedMax != 43) {
+TEST(PayloadStateTest, DidYouAddANewErrorCode) {
+ if (kErrorCodeUmaReportedMax != 43) {
LOG(ERROR) << "The following failure is intentional. If you added a new "
- << "ActionExitCode enum value, make sure to add it to the "
+ << "ErrorCode enum value, make sure to add it to the "
<< "PayloadState::UpdateFailed method and then update this test "
- << "to the new value of kActionCodeUmaReportedMax, which is "
- << kActionCodeUmaReportedMax;
+ << "to the new value of kErrorCodeUmaReportedMax, which is "
+ << kErrorCodeUmaReportedMax;
EXPECT_FALSE("Please see the log line above");
}
}
@@ -248,7 +248,7 @@
EXPECT_EQ(0, payload_state.GetUrlIndex());
// Verify that on the first error, the URL index advances to 1.
- ActionExitCode error = kActionCodeDownloadMetadataSignatureMismatch;
+ ErrorCode error = kErrorCodeDownloadMetadataSignatureMismatch;
payload_state.UpdateFailed(error);
EXPECT_EQ(1, payload_state.GetUrlIndex());
@@ -275,7 +275,7 @@
SetupPayloadStateWith2Urls("Hash5823", &payload_state, &response);
// Advance the URL index to 1 by faking an error.
- ActionExitCode error = kActionCodeDownloadMetadataSignatureMismatch;
+ ErrorCode error = kErrorCodeDownloadMetadataSignatureMismatch;
payload_state.UpdateFailed(error);
EXPECT_EQ(1, payload_state.GetUrlIndex());
EXPECT_EQ(1, payload_state.GetUrlSwitchCount());
@@ -345,21 +345,21 @@
SetupPayloadStateWith2Urls("Hash5873", &payload_state, &response);
// This should advance the URL index.
- payload_state.UpdateFailed(kActionCodeDownloadMetadataSignatureMismatch);
+ payload_state.UpdateFailed(kErrorCodeDownloadMetadataSignatureMismatch);
EXPECT_EQ(0, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(1, payload_state.GetUrlIndex());
EXPECT_EQ(0, payload_state.GetUrlFailureCount());
EXPECT_EQ(1, payload_state.GetUrlSwitchCount());
// This should advance the failure count only.
- payload_state.UpdateFailed(kActionCodeDownloadTransferError);
+ payload_state.UpdateFailed(kErrorCodeDownloadTransferError);
EXPECT_EQ(0, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(1, payload_state.GetUrlIndex());
EXPECT_EQ(1, payload_state.GetUrlFailureCount());
EXPECT_EQ(1, payload_state.GetUrlSwitchCount());
// This should advance the failure count only.
- payload_state.UpdateFailed(kActionCodeDownloadTransferError);
+ payload_state.UpdateFailed(kErrorCodeDownloadTransferError);
EXPECT_EQ(0, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(1, payload_state.GetUrlIndex());
EXPECT_EQ(2, payload_state.GetUrlFailureCount());
@@ -369,7 +369,7 @@
// max failure count and reset the failure count for the new URL index.
// This should also wrap around the URL index and thus cause the payload
// attempt number to be incremented.
- payload_state.UpdateFailed(kActionCodeDownloadTransferError);
+ payload_state.UpdateFailed(kErrorCodeDownloadTransferError);
EXPECT_EQ(1, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(0, payload_state.GetUrlIndex());
EXPECT_EQ(0, payload_state.GetUrlFailureCount());
@@ -377,7 +377,7 @@
EXPECT_TRUE(payload_state.ShouldBackoffDownload());
// This should advance the URL index.
- payload_state.UpdateFailed(kActionCodePayloadHashMismatchError);
+ payload_state.UpdateFailed(kErrorCodePayloadHashMismatchError);
EXPECT_EQ(1, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(1, payload_state.GetUrlIndex());
EXPECT_EQ(0, payload_state.GetUrlFailureCount());
@@ -386,7 +386,7 @@
// This should advance the URL index and payload attempt number due to
// wrap-around of URL index.
- payload_state.UpdateFailed(kActionCodeDownloadMetadataSignatureMissingError);
+ payload_state.UpdateFailed(kErrorCodeDownloadMetadataSignatureMissingError);
EXPECT_EQ(2, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(0, payload_state.GetUrlIndex());
EXPECT_EQ(0, payload_state.GetUrlFailureCount());
@@ -394,8 +394,8 @@
EXPECT_TRUE(payload_state.ShouldBackoffDownload());
// This HTTP error code should only increase the failure count.
- payload_state.UpdateFailed(static_cast<ActionExitCode>(
- kActionCodeOmahaRequestHTTPResponseBase + 404));
+ payload_state.UpdateFailed(static_cast<ErrorCode>(
+ kErrorCodeOmahaRequestHTTPResponseBase + 404));
EXPECT_EQ(2, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(0, payload_state.GetUrlIndex());
EXPECT_EQ(1, payload_state.GetUrlFailureCount());
@@ -466,8 +466,8 @@
// Generate enough events to advance URL index, failure count and
// payload attempt number all to 1.
payload_state.DownloadComplete();
- payload_state.UpdateFailed(kActionCodeDownloadMetadataSignatureMismatch);
- payload_state.UpdateFailed(kActionCodeDownloadTransferError);
+ payload_state.UpdateFailed(kErrorCodeDownloadMetadataSignatureMismatch);
+ payload_state.UpdateFailed(kErrorCodeDownloadTransferError);
EXPECT_EQ(1, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(1, payload_state.GetUrlIndex());
EXPECT_EQ(1, payload_state.GetUrlFailureCount());
@@ -522,8 +522,8 @@
// Simulate two failures (enough to cause payload backoff) and check
// again that we're ready to re-download without any backoff as this is
// a delta payload.
- payload_state.UpdateFailed(kActionCodeDownloadMetadataSignatureMismatch);
- payload_state.UpdateFailed(kActionCodeDownloadMetadataSignatureMismatch);
+ payload_state.UpdateFailed(kErrorCodeDownloadMetadataSignatureMismatch);
+ payload_state.UpdateFailed(kErrorCodeDownloadMetadataSignatureMismatch);
EXPECT_EQ(0, payload_state.GetUrlIndex());
EXPECT_EQ(0, payload_state.GetPayloadAttemptNumber());
EXPECT_FALSE(payload_state.ShouldBackoffDownload());
@@ -585,8 +585,8 @@
// Test again, this time by simulating two errors that would cause
// the payload attempt number to increment due to wrap around. And
// check that we are still ready to re-download without any backoff.
- payload_state.UpdateFailed(kActionCodeDownloadMetadataSignatureMismatch);
- payload_state.UpdateFailed(kActionCodeDownloadMetadataSignatureMismatch);
+ payload_state.UpdateFailed(kErrorCodeDownloadMetadataSignatureMismatch);
+ payload_state.UpdateFailed(kErrorCodeDownloadMetadataSignatureMismatch);
EXPECT_EQ(2, payload_state.GetPayloadAttemptNumber());
EXPECT_FALSE(payload_state.ShouldBackoffDownload());
}
@@ -618,7 +618,7 @@
payload_state.GetTotalBytesDownloaded(kDownloadSourceHttpsServer));
// Simulate an error that'll cause the url index to point to https.
- ActionExitCode error = kActionCodeDownloadMetadataSignatureMismatch;
+ ErrorCode error = kErrorCodeDownloadMetadataSignatureMismatch;
payload_state.UpdateFailed(error);
// Test that no new progress is made on HTTP and new progress is on HTTPs.
diff --git a/postinstall_runner_action.cc b/postinstall_runner_action.cc
index 802a2cd..20dfae9 100644
--- a/postinstall_runner_action.cc
+++ b/postinstall_runner_action.cc
@@ -59,7 +59,7 @@
if (utils::CreatePowerwashMarkerFile()) {
powerwash_marker_created_ = true;
} else {
- completer.set_code(kActionCodePostinstallPowerwashError);
+ completer.set_code(kErrorCodePostinstallPowerwashError);
return;
}
}
@@ -88,7 +88,7 @@
// This special return code means that we tried to update firmware,
// but couldn't because we booted from FW B, and we need to reboot
// to get back to FW A.
- completer.set_code(kActionCodePostinstallBootedFromFirmwareB);
+ completer.set_code(kErrorCodePostinstallBootedFromFirmwareB);
}
return;
}
@@ -100,7 +100,7 @@
if (HasOutputPipe())
SetOutputObject(install_plan);
- completer.set_code(kActionCodeSuccess);
+ completer.set_code(kErrorCodeSuccess);
}
void PostinstallRunnerAction::StaticCompletePostinstall(int return_code,
diff --git a/postinstall_runner_action_unittest.cc b/postinstall_runner_action_unittest.cc
index 85954dd..fdde180 100644
--- a/postinstall_runner_action_unittest.cc
+++ b/postinstall_runner_action_unittest.cc
@@ -44,23 +44,23 @@
public:
PostinstActionProcessorDelegate()
: loop_(NULL),
- code_(kActionCodeError),
+ code_(kErrorCodeError),
code_set_(false) {}
void ProcessingDone(const ActionProcessor* processor,
- ActionExitCode code) {
+ ErrorCode code) {
ASSERT_TRUE(loop_);
g_main_loop_quit(loop_);
}
void ActionCompleted(ActionProcessor* processor,
AbstractAction* action,
- ActionExitCode code) {
+ ErrorCode code) {
if (action->Type() == PostinstallRunnerAction::StaticType()) {
code_ = code;
code_set_ = true;
}
}
GMainLoop* loop_;
- ActionExitCode code_;
+ ErrorCode code_;
bool code_set_;
};
@@ -171,7 +171,7 @@
ASSERT_FALSE(processor.IsRunning());
EXPECT_TRUE(delegate.code_set_);
- EXPECT_EQ(should_succeed, delegate.code_ == kActionCodeSuccess);
+ EXPECT_EQ(should_succeed, delegate.code_ == kErrorCodeSuccess);
EXPECT_EQ(should_succeed, !collector_action.object().install_path.empty());
if (should_succeed)
EXPECT_TRUE(install_plan == collector_action.object());
@@ -187,7 +187,7 @@
}
if (err_code == 2)
- EXPECT_EQ(kActionCodePostinstallBootedFromFirmwareB, delegate.code_);
+ EXPECT_EQ(kErrorCodePostinstallBootedFromFirmwareB, delegate.code_);
struct stat stbuf;
int rc = lstat((string(cwd) + "/postinst_called").c_str(), &stbuf);
diff --git a/test_utils.h b/test_utils.h
index 30f1f89..e8f337d 100644
--- a/test_utils.h
+++ b/test_utils.h
@@ -195,7 +195,7 @@
if (this->HasOutputPipe()) {
this->SetOutputObject(out_obj_);
}
- this->processor_->ActionComplete(this, kActionCodeSuccess);
+ this->processor_->ActionComplete(this, kErrorCodeSuccess);
}
static std::string StaticType() { return "ObjectFeederAction"; }
std::string Type() const { return StaticType(); }
@@ -229,7 +229,7 @@
if (this->HasInputObject()) {
object_ = this->GetInputObject();
}
- this->processor_->ActionComplete(this, kActionCodeSuccess);
+ this->processor_->ActionComplete(this, kErrorCodeSuccess);
}
static std::string StaticType() { return "ObjectCollectorAction"; }
std::string Type() const { return StaticType(); }
diff --git a/update_attempter.cc b/update_attempter.cc
index 60276dd..3aa6a1e 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -82,24 +82,24 @@
}
}
-// 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|
+// Turns a generic kErrorCodeError to a generic error code specific
+// to |action| (e.g., kErrorCodeFilesystemCopierError). If |code| is
+// not kErrorCodeError, or the action is not matched, returns |code|
// unchanged.
-ActionExitCode GetErrorCodeForAction(AbstractAction* action,
- ActionExitCode code) {
- if (code != kActionCodeError)
+ErrorCode GetErrorCodeForAction(AbstractAction* action,
+ ErrorCode code) {
+ if (code != kErrorCodeError)
return code;
const string type = action->Type();
if (type == OmahaRequestAction::StaticType())
- return kActionCodeOmahaRequestError;
+ return kErrorCodeOmahaRequestError;
if (type == OmahaResponseHandlerAction::StaticType())
- return kActionCodeOmahaResponseHandlerError;
+ return kErrorCodeOmahaResponseHandlerError;
if (type == FilesystemCopierAction::StaticType())
- return kActionCodeFilesystemCopierError;
+ return kErrorCodeFilesystemCopierError;
if (type == PostinstallRunnerAction::StaticType())
- return kActionCodePostinstallRunnerError;
+ return kErrorCodePostinstallRunnerError;
return code;
}
@@ -573,7 +573,7 @@
// Delegate methods:
void UpdateAttempter::ProcessingDone(const ActionProcessor* processor,
- ActionExitCode code) {
+ ErrorCode code) {
CHECK(response_handler_action_);
LOG(INFO) << "Processing Done.";
actions_.clear();
@@ -597,7 +597,7 @@
"so requesting reboot from user.";
}
- if (code == kActionCodeSuccess) {
+ if (code == kErrorCodeSuccess) {
utils::WriteFile(kUpdateCompletedMarker, "", 0);
prefs_->SetInt64(kPrefsDeltaUpdateFailures, 0);
prefs_->SetString(kPrefsPreviousVersion,
@@ -649,7 +649,7 @@
// or otherwise.
void UpdateAttempter::ActionCompleted(ActionProcessor* processor,
AbstractAction* action,
- ActionExitCode code) {
+ ErrorCode code) {
// Reset download progress regardless of whether or not the download
// action succeeded. Also, get the response code from HTTP request
// actions (update download as well as the initial update check
@@ -673,12 +673,12 @@
}
}
}
- if (code != kActionCodeSuccess) {
+ if (code != kErrorCodeSuccess) {
// If the current state is at or past the download phase, count the failure
// in case a switch to full update becomes necessary. Ignore network
// transfer timeouts and failures.
if (status_ >= UPDATE_STATUS_DOWNLOADING &&
- code != kActionCodeDownloadTransferError) {
+ code != kErrorCodeDownloadTransferError) {
MarkDeltaUpdateFailure();
}
// On failure, schedule an error event to be sent to Omaha.
@@ -842,22 +842,22 @@
uint32_t flags = 0;
if (!utils::IsNormalBootMode())
- flags |= kActionCodeDevModeFlag;
+ flags |= kErrorCodeDevModeFlag;
if (response_handler_action_.get() &&
response_handler_action_->install_plan().is_resume)
- flags |= kActionCodeResumedFlag;
+ flags |= kErrorCodeResumedFlag;
if (!utils::IsOfficialBuild())
- flags |= kActionCodeTestImageFlag;
+ flags |= kErrorCodeTestImageFlag;
if (omaha_request_params_->update_url() != kProductionOmahaUrl)
- flags |= kActionCodeTestOmahaUrlFlag;
+ flags |= kErrorCodeTestOmahaUrlFlag;
return flags;
}
-bool UpdateAttempter::ShouldCancel(ActionExitCode* cancel_reason) {
+bool UpdateAttempter::ShouldCancel(ErrorCode* cancel_reason) {
// Check if the channel we're attempting to update to is the same as the
// target channel currently chosen by the user.
OmahaRequestParams* params = system_state_->request_params();
@@ -866,7 +866,7 @@
<< params->target_channel()
<< " is different from the download channel: "
<< params->download_channel();
- *cancel_reason = kActionCodeUpdateCanceledByChannelChange;
+ *cancel_reason = kErrorCodeUpdateCanceledByChannelChange;
return true;
}
@@ -883,7 +883,7 @@
}
void UpdateAttempter::CreatePendingErrorEvent(AbstractAction* action,
- ActionExitCode code) {
+ ErrorCode code) {
if (error_event_.get()) {
// This shouldn't really happen.
LOG(WARNING) << "There's already an existing pending error event.";
@@ -895,7 +895,7 @@
// 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() &&
- code == kActionCodeError) ||
+ code == kErrorCodeError) ||
status_ == UPDATE_STATUS_REPORTING_ERROR_EVENT) {
return;
}
@@ -907,9 +907,9 @@
// the switch cases below.
OmahaEvent::Result event_result;
switch (code) {
- case kActionCodeOmahaUpdateIgnoredPerPolicy:
- case kActionCodeOmahaUpdateDeferredPerPolicy:
- case kActionCodeOmahaUpdateDeferredForBackoff:
+ case kErrorCodeOmahaUpdateIgnoredPerPolicy:
+ case kErrorCodeOmahaUpdateDeferredPerPolicy:
+ case kErrorCodeOmahaUpdateDeferredForBackoff:
event_result = OmahaEvent::kResultUpdateDeferred;
break;
default:
@@ -918,10 +918,10 @@
}
code = GetErrorCodeForAction(action, code);
- fake_update_success_ = code == kActionCodePostinstallBootedFromFirmwareB;
+ fake_update_success_ = code == kErrorCodePostinstallBootedFromFirmwareB;
// Compute the final error code with all the bit flags to be sent to Omaha.
- code = static_cast<ActionExitCode>(code | GetErrorCodeFlags());
+ code = static_cast<ErrorCode>(code | GetErrorCodeFlags());
error_event_.reset(new OmahaEvent(OmahaEvent::kTypeUpdateComplete,
event_result,
code));
diff --git a/update_attempter.h b/update_attempter.h
index bcd730f..315e545 100644
--- a/update_attempter.h
+++ b/update_attempter.h
@@ -79,11 +79,11 @@
bool is_test_mode);
// ActionProcessorDelegate methods:
- void ProcessingDone(const ActionProcessor* processor, ActionExitCode code);
+ void ProcessingDone(const ActionProcessor* processor, ErrorCode code);
void ProcessingStopped(const ActionProcessor* processor);
void ActionCompleted(ActionProcessor* processor,
AbstractAction* action,
- ActionExitCode code);
+ ErrorCode code);
// Stop updating. An attempt will be made to record status to the disk
// so that updates can be resumed later.
@@ -153,7 +153,7 @@
// Broadcasts the current status over D-Bus.
void BroadcastStatus();
- // Returns the special flags to be added to ActionExitCode values based on the
+ // Returns the special flags to be added to ErrorCode values based on the
// parameters used in the current update attempt.
uint32_t GetErrorCodeFlags();
@@ -161,7 +161,7 @@
// current state of the system, in which case |cancel_reason| indicates the
// reason for the cancellation. False otherwise, in which case
// |cancel_reason| is untouched.
- bool ShouldCancel(ActionExitCode* cancel_reason);
+ bool ShouldCancel(ErrorCode* cancel_reason);
private:
// Update server URL for automated lab test.
@@ -191,7 +191,7 @@
// Creates an error event object in |error_event_| to be included in an
// OmahaRequestAction once the current action processor is done.
- void CreatePendingErrorEvent(AbstractAction* action, ActionExitCode code);
+ void CreatePendingErrorEvent(AbstractAction* action, ErrorCode code);
// If there's a pending error event allocated in |error_event_|, schedules an
// OmahaRequestAction with that event in the current processor, clears the
diff --git a/update_attempter_unittest.cc b/update_attempter_unittest.cc
index 042690f..ff3236c 100644
--- a/update_attempter_unittest.cc
+++ b/update_attempter_unittest.cc
@@ -116,7 +116,7 @@
fetcher->FailTransfer(503); // Sets the HTTP response code.
DownloadAction action(prefs_, NULL, fetcher.release());
EXPECT_CALL(*prefs_, GetInt64(kPrefsDeltaUpdateFailures, _)).Times(0);
- attempter_.ActionCompleted(NULL, &action, kActionCodeSuccess);
+ attempter_.ActionCompleted(NULL, &action, kErrorCodeSuccess);
EXPECT_EQ(503, attempter_.http_response_code());
EXPECT_EQ(UPDATE_STATUS_FINALIZING, attempter_.status());
ASSERT_TRUE(attempter_.error_event_.get() == NULL);
@@ -128,7 +128,7 @@
attempter_.status_ = UPDATE_STATUS_DOWNLOADING;
EXPECT_CALL(*prefs_, GetInt64(kPrefsDeltaUpdateFailures, _))
.WillOnce(Return(false));
- attempter_.ActionCompleted(NULL, &action, kActionCodeError);
+ attempter_.ActionCompleted(NULL, &action, kErrorCodeError);
ASSERT_TRUE(attempter_.error_event_.get() != NULL);
}
@@ -145,7 +145,7 @@
UpdateCheckScheduler scheduler(&attempter_, &mock_system_state_);
attempter_.set_update_check_scheduler(&scheduler);
EXPECT_CALL(*prefs_, GetInt64(kPrefsDeltaUpdateFailures, _)).Times(0);
- attempter_.ActionCompleted(NULL, &action, kActionCodeSuccess);
+ attempter_.ActionCompleted(NULL, &action, kErrorCodeSuccess);
EXPECT_EQ(500, attempter_.http_response_code());
EXPECT_EQ(UPDATE_STATUS_IDLE, attempter_.status());
EXPECT_EQ(234, scheduler.poll_interval());
@@ -162,31 +162,31 @@
}
TEST_F(UpdateAttempterTest, GetErrorCodeForActionTest) {
- extern ActionExitCode GetErrorCodeForAction(AbstractAction* action,
- ActionExitCode code);
- EXPECT_EQ(kActionCodeSuccess,
- GetErrorCodeForAction(NULL, kActionCodeSuccess));
+ extern ErrorCode GetErrorCodeForAction(AbstractAction* action,
+ ErrorCode code);
+ EXPECT_EQ(kErrorCodeSuccess,
+ GetErrorCodeForAction(NULL, kErrorCodeSuccess));
MockSystemState mock_system_state;
OmahaRequestAction omaha_request_action(&mock_system_state, NULL,
NULL, false);
- EXPECT_EQ(kActionCodeOmahaRequestError,
- GetErrorCodeForAction(&omaha_request_action, kActionCodeError));
+ EXPECT_EQ(kErrorCodeOmahaRequestError,
+ GetErrorCodeForAction(&omaha_request_action, kErrorCodeError));
OmahaResponseHandlerAction omaha_response_handler_action(&mock_system_state_);
- EXPECT_EQ(kActionCodeOmahaResponseHandlerError,
+ EXPECT_EQ(kErrorCodeOmahaResponseHandlerError,
GetErrorCodeForAction(&omaha_response_handler_action,
- kActionCodeError));
+ kErrorCodeError));
FilesystemCopierAction filesystem_copier_action(false, false);
- EXPECT_EQ(kActionCodeFilesystemCopierError,
- GetErrorCodeForAction(&filesystem_copier_action, kActionCodeError));
+ EXPECT_EQ(kErrorCodeFilesystemCopierError,
+ GetErrorCodeForAction(&filesystem_copier_action, kErrorCodeError));
PostinstallRunnerAction postinstall_runner_action;
- EXPECT_EQ(kActionCodePostinstallRunnerError,
+ EXPECT_EQ(kErrorCodePostinstallRunnerError,
GetErrorCodeForAction(&postinstall_runner_action,
- kActionCodeError));
+ kErrorCodeError));
ActionMock action_mock;
EXPECT_CALL(action_mock, Type()).Times(1).WillOnce(Return("ActionMock"));
- EXPECT_EQ(kActionCodeError,
- GetErrorCodeForAction(&action_mock, kActionCodeError));
+ EXPECT_EQ(kErrorCodeError,
+ GetErrorCodeForAction(&action_mock, kErrorCodeError));
}
TEST_F(UpdateAttempterTest, DisableDeltaUpdateIfNeededTest) {
@@ -250,7 +250,7 @@
OmahaRequestAction::StaticType())))
.Times(1);
EXPECT_CALL(*processor_, StartProcessing()).Times(1);
- ActionExitCode err = kActionCodeError;
+ ErrorCode err = kErrorCodeError;
EXPECT_CALL(*mock_system_state_.mock_payload_state(), UpdateFailed(err));
attempter_.error_event_.reset(new OmahaEvent(OmahaEvent::kTypeUpdateComplete,
OmahaEvent::kResultError,
@@ -427,12 +427,12 @@
TEST_F(UpdateAttempterTest, CreatePendingErrorEventTest) {
ActionMock action;
- const ActionExitCode kCode = kActionCodeDownloadTransferError;
+ const ErrorCode kCode = kErrorCodeDownloadTransferError;
attempter_.CreatePendingErrorEvent(&action, kCode);
ASSERT_TRUE(attempter_.error_event_.get() != NULL);
EXPECT_EQ(OmahaEvent::kTypeUpdateComplete, attempter_.error_event_->type);
EXPECT_EQ(OmahaEvent::kResultError, attempter_.error_event_->result);
- EXPECT_EQ(kCode | kActionCodeTestOmahaUrlFlag,
+ EXPECT_EQ(kCode | kErrorCodeTestOmahaUrlFlag,
attempter_.error_event_->error_code);
}
@@ -442,12 +442,12 @@
response_action->install_plan_.is_resume = true;
attempter_.response_handler_action_.reset(response_action);
ActionMock action;
- const ActionExitCode kCode = kActionCodeInstallDeviceOpenError;
+ const ErrorCode kCode = kErrorCodeInstallDeviceOpenError;
attempter_.CreatePendingErrorEvent(&action, kCode);
ASSERT_TRUE(attempter_.error_event_.get() != NULL);
EXPECT_EQ(OmahaEvent::kTypeUpdateComplete, attempter_.error_event_->type);
EXPECT_EQ(OmahaEvent::kResultError, attempter_.error_event_->result);
- EXPECT_EQ(kCode | kActionCodeResumedFlag | kActionCodeTestOmahaUrlFlag,
+ EXPECT_EQ(kCode | kErrorCodeResumedFlag | kErrorCodeTestOmahaUrlFlag,
attempter_.error_event_->error_code);
}
diff --git a/utils.cc b/utils.cc
index 3eb0679..be98a71 100644
--- a/utils.cc
+++ b/utils.cc
@@ -764,21 +764,21 @@
return "Unknown";
}
-ActionExitCode GetBaseErrorCode(ActionExitCode code) {
+ErrorCode GetBaseErrorCode(ErrorCode code) {
// Ignore the higher order bits in the code by applying the mask as
// we want the enumerations to be in the small contiguous range
- // with values less than kActionCodeUmaReportedMax.
- ActionExitCode base_code = static_cast<ActionExitCode>(code & ~kSpecialFlags);
+ // with values less than kErrorCodeUmaReportedMax.
+ ErrorCode base_code = static_cast<ErrorCode>(code & ~kErrorCodeSpecialFlags);
// Make additional adjustments required for UMA and error classification.
// TODO(jaysri): Move this logic to UeErrorCode.cc when we fix
// chromium-os:34369.
- if (base_code >= kActionCodeOmahaRequestHTTPResponseBase) {
+ if (base_code >= kErrorCodeOmahaRequestHTTPResponseBase) {
// Since we want to keep the enums to a small value, aggregate all HTTP
// errors into this one bucket for UMA and error classification purposes.
LOG(INFO) << "Converting error code " << base_code
- << " to kActionCodeOmahaErrorInHTTPResponse";
- base_code = kActionCodeOmahaErrorInHTTPResponse;
+ << " to kErrorCodeOmahaErrorInHTTPResponse";
+ base_code = kErrorCodeOmahaErrorInHTTPResponse;
}
return base_code;
@@ -788,13 +788,13 @@
// bits of the given code. Returns an empty string if none of those bits are
// set.
string GetFlagNames(uint32_t code) {
- uint32_t flags = code & kSpecialFlags;
+ uint32_t flags = code & kErrorCodeSpecialFlags;
string flag_names;
string separator = "";
for(size_t i = 0; i < sizeof(flags) * 8; i++) {
uint32_t flag = flags & (1 << i);
if (flag) {
- flag_names += separator + CodeToString(static_cast<ActionExitCode>(flag));
+ flag_names += separator + CodeToString(static_cast<ErrorCode>(flag));
separator = ", ";
}
}
@@ -802,15 +802,15 @@
return flag_names;
}
-void SendErrorCodeToUma(SystemState* system_state, ActionExitCode code) {
+void SendErrorCodeToUma(SystemState* system_state, ErrorCode code) {
if (!system_state)
return;
- ActionExitCode uma_error_code = GetBaseErrorCode(code);
+ ErrorCode uma_error_code = GetBaseErrorCode(code);
// If the code doesn't have flags computed already, compute them now based on
// the state of the current update attempt.
- uint32_t flags = code & kSpecialFlags;
+ uint32_t flags = code & kErrorCodeSpecialFlags;
if (!flags)
flags = system_state->update_attempter()->GetErrorCodeFlags();
@@ -818,7 +818,7 @@
// flag, as it's perfectly normal for production devices to resume their
// downloads and so we want to record those cases also in NormalErrorCodes
// bucket.
- string metric = (flags & ~kActionCodeResumedFlag) ?
+ string metric = (flags & ~kErrorCodeResumedFlag) ?
"Installer.DevModeErrorCodes" : "Installer.NormalErrorCodes";
LOG(INFO) << "Sending error code " << uma_error_code
@@ -828,114 +828,114 @@
system_state->metrics_lib()->SendEnumToUMA(metric,
uma_error_code,
- kActionCodeUmaReportedMax);
+ kErrorCodeUmaReportedMax);
}
-string CodeToString(ActionExitCode code) {
+string CodeToString(ErrorCode code) {
// If the given code has both parts (i.e. the error code part and the flags
// part) then strip off the flags part since the switch statement below
// has case statements only for the base error code or a single flag but
// doesn't support any combinations of those.
- if ((code & kSpecialFlags) && (code & ~kSpecialFlags))
- code = static_cast<ActionExitCode>(code & ~kSpecialFlags);
+ if ((code & kErrorCodeSpecialFlags) && (code & ~kErrorCodeSpecialFlags))
+ code = static_cast<ErrorCode>(code & ~kErrorCodeSpecialFlags);
switch (code) {
- case kActionCodeSuccess: return "kActionCodeSuccess";
- case kActionCodeError: return "kActionCodeError";
- case kActionCodeOmahaRequestError: return "kActionCodeOmahaRequestError";
- case kActionCodeOmahaResponseHandlerError:
- return "kActionCodeOmahaResponseHandlerError";
- case kActionCodeFilesystemCopierError:
- return "kActionCodeFilesystemCopierError";
- case kActionCodePostinstallRunnerError:
- return "kActionCodePostinstallRunnerError";
- case kActionCodeSetBootableFlagError:
- return "kActionCodeSetBootableFlagError";
- case kActionCodeInstallDeviceOpenError:
- return "kActionCodeInstallDeviceOpenError";
- case kActionCodeKernelDeviceOpenError:
- return "kActionCodeKernelDeviceOpenError";
- case kActionCodeDownloadTransferError:
- return "kActionCodeDownloadTransferError";
- case kActionCodePayloadHashMismatchError:
- return "kActionCodePayloadHashMismatchError";
- case kActionCodePayloadSizeMismatchError:
- return "kActionCodePayloadSizeMismatchError";
- case kActionCodeDownloadPayloadVerificationError:
- return "kActionCodeDownloadPayloadVerificationError";
- case kActionCodeDownloadNewPartitionInfoError:
- return "kActionCodeDownloadNewPartitionInfoError";
- case kActionCodeDownloadWriteError:
- return "kActionCodeDownloadWriteError";
- case kActionCodeNewRootfsVerificationError:
- return "kActionCodeNewRootfsVerificationError";
- case kActionCodeNewKernelVerificationError:
- return "kActionCodeNewKernelVerificationError";
- case kActionCodeSignedDeltaPayloadExpectedError:
- return "kActionCodeSignedDeltaPayloadExpectedError";
- case kActionCodeDownloadPayloadPubKeyVerificationError:
- return "kActionCodeDownloadPayloadPubKeyVerificationError";
- case kActionCodePostinstallBootedFromFirmwareB:
- return "kActionCodePostinstallBootedFromFirmwareB";
- case kActionCodeDownloadStateInitializationError:
- return "kActionCodeDownloadStateInitializationError";
- case kActionCodeDownloadInvalidMetadataMagicString:
- return "kActionCodeDownloadInvalidMetadataMagicString";
- case kActionCodeDownloadSignatureMissingInManifest:
- return "kActionCodeDownloadSignatureMissingInManifest";
- case kActionCodeDownloadManifestParseError:
- return "kActionCodeDownloadManifestParseError";
- case kActionCodeDownloadMetadataSignatureError:
- return "kActionCodeDownloadMetadataSignatureError";
- case kActionCodeDownloadMetadataSignatureVerificationError:
- return "kActionCodeDownloadMetadataSignatureVerificationError";
- case kActionCodeDownloadMetadataSignatureMismatch:
- return "kActionCodeDownloadMetadataSignatureMismatch";
- case kActionCodeDownloadOperationHashVerificationError:
- return "kActionCodeDownloadOperationHashVerificationError";
- case kActionCodeDownloadOperationExecutionError:
- return "kActionCodeDownloadOperationExecutionError";
- case kActionCodeDownloadOperationHashMismatch:
- return "kActionCodeDownloadOperationHashMismatch";
- case kActionCodeOmahaRequestEmptyResponseError:
- return "kActionCodeOmahaRequestEmptyResponseError";
- case kActionCodeOmahaRequestXMLParseError:
- return "kActionCodeOmahaRequestXMLParseError";
- case kActionCodeDownloadInvalidMetadataSize:
- return "kActionCodeDownloadInvalidMetadataSize";
- case kActionCodeDownloadInvalidMetadataSignature:
- return "kActionCodeDownloadInvalidMetadataSignature";
- case kActionCodeOmahaResponseInvalid:
- return "kActionCodeOmahaResponseInvalid";
- case kActionCodeOmahaUpdateIgnoredPerPolicy:
- return "kActionCodeOmahaUpdateIgnoredPerPolicy";
- case kActionCodeOmahaUpdateDeferredPerPolicy:
- return "kActionCodeOmahaUpdateDeferredPerPolicy";
- case kActionCodeOmahaErrorInHTTPResponse:
- return "kActionCodeOmahaErrorInHTTPResponse";
- case kActionCodeDownloadOperationHashMissingError:
- return "kActionCodeDownloadOperationHashMissingError";
- case kActionCodeDownloadMetadataSignatureMissingError:
- return "kActionCodeDownloadMetadataSignatureMissingError";
- case kActionCodeOmahaUpdateDeferredForBackoff:
- return "kActionCodeOmahaUpdateDeferredForBackoff";
- case kActionCodePostinstallPowerwashError:
- return "kActionCodePostinstallPowerwashError";
- case kActionCodeUpdateCanceledByChannelChange:
- return "kActionCodeUpdateCanceledByChannelChange";
- case kActionCodeUmaReportedMax:
- return "kActionCodeUmaReportedMax";
- case kActionCodeOmahaRequestHTTPResponseBase:
- return "kActionCodeOmahaRequestHTTPResponseBase";
- case kActionCodeResumedFlag:
+ case kErrorCodeSuccess: return "kErrorCodeSuccess";
+ case kErrorCodeError: return "kErrorCodeError";
+ case kErrorCodeOmahaRequestError: return "kErrorCodeOmahaRequestError";
+ case kErrorCodeOmahaResponseHandlerError:
+ return "kErrorCodeOmahaResponseHandlerError";
+ case kErrorCodeFilesystemCopierError:
+ return "kErrorCodeFilesystemCopierError";
+ case kErrorCodePostinstallRunnerError:
+ return "kErrorCodePostinstallRunnerError";
+ case kErrorCodeSetBootableFlagError:
+ return "kErrorCodeSetBootableFlagError";
+ case kErrorCodeInstallDeviceOpenError:
+ return "kErrorCodeInstallDeviceOpenError";
+ case kErrorCodeKernelDeviceOpenError:
+ return "kErrorCodeKernelDeviceOpenError";
+ case kErrorCodeDownloadTransferError:
+ return "kErrorCodeDownloadTransferError";
+ case kErrorCodePayloadHashMismatchError:
+ return "kErrorCodePayloadHashMismatchError";
+ case kErrorCodePayloadSizeMismatchError:
+ return "kErrorCodePayloadSizeMismatchError";
+ case kErrorCodeDownloadPayloadVerificationError:
+ return "kErrorCodeDownloadPayloadVerificationError";
+ case kErrorCodeDownloadNewPartitionInfoError:
+ return "kErrorCodeDownloadNewPartitionInfoError";
+ case kErrorCodeDownloadWriteError:
+ return "kErrorCodeDownloadWriteError";
+ case kErrorCodeNewRootfsVerificationError:
+ return "kErrorCodeNewRootfsVerificationError";
+ case kErrorCodeNewKernelVerificationError:
+ return "kErrorCodeNewKernelVerificationError";
+ case kErrorCodeSignedDeltaPayloadExpectedError:
+ return "kErrorCodeSignedDeltaPayloadExpectedError";
+ case kErrorCodeDownloadPayloadPubKeyVerificationError:
+ return "kErrorCodeDownloadPayloadPubKeyVerificationError";
+ case kErrorCodePostinstallBootedFromFirmwareB:
+ return "kErrorCodePostinstallBootedFromFirmwareB";
+ case kErrorCodeDownloadStateInitializationError:
+ return "kErrorCodeDownloadStateInitializationError";
+ case kErrorCodeDownloadInvalidMetadataMagicString:
+ return "kErrorCodeDownloadInvalidMetadataMagicString";
+ case kErrorCodeDownloadSignatureMissingInManifest:
+ return "kErrorCodeDownloadSignatureMissingInManifest";
+ case kErrorCodeDownloadManifestParseError:
+ return "kErrorCodeDownloadManifestParseError";
+ case kErrorCodeDownloadMetadataSignatureError:
+ return "kErrorCodeDownloadMetadataSignatureError";
+ case kErrorCodeDownloadMetadataSignatureVerificationError:
+ return "kErrorCodeDownloadMetadataSignatureVerificationError";
+ case kErrorCodeDownloadMetadataSignatureMismatch:
+ return "kErrorCodeDownloadMetadataSignatureMismatch";
+ case kErrorCodeDownloadOperationHashVerificationError:
+ return "kErrorCodeDownloadOperationHashVerificationError";
+ case kErrorCodeDownloadOperationExecutionError:
+ return "kErrorCodeDownloadOperationExecutionError";
+ case kErrorCodeDownloadOperationHashMismatch:
+ return "kErrorCodeDownloadOperationHashMismatch";
+ case kErrorCodeOmahaRequestEmptyResponseError:
+ return "kErrorCodeOmahaRequestEmptyResponseError";
+ case kErrorCodeOmahaRequestXMLParseError:
+ return "kErrorCodeOmahaRequestXMLParseError";
+ case kErrorCodeDownloadInvalidMetadataSize:
+ return "kErrorCodeDownloadInvalidMetadataSize";
+ case kErrorCodeDownloadInvalidMetadataSignature:
+ return "kErrorCodeDownloadInvalidMetadataSignature";
+ case kErrorCodeOmahaResponseInvalid:
+ return "kErrorCodeOmahaResponseInvalid";
+ case kErrorCodeOmahaUpdateIgnoredPerPolicy:
+ return "kErrorCodeOmahaUpdateIgnoredPerPolicy";
+ case kErrorCodeOmahaUpdateDeferredPerPolicy:
+ return "kErrorCodeOmahaUpdateDeferredPerPolicy";
+ case kErrorCodeOmahaErrorInHTTPResponse:
+ return "kErrorCodeOmahaErrorInHTTPResponse";
+ case kErrorCodeDownloadOperationHashMissingError:
+ return "kErrorCodeDownloadOperationHashMissingError";
+ case kErrorCodeDownloadMetadataSignatureMissingError:
+ return "kErrorCodeDownloadMetadataSignatureMissingError";
+ case kErrorCodeOmahaUpdateDeferredForBackoff:
+ return "kErrorCodeOmahaUpdateDeferredForBackoff";
+ case kErrorCodePostinstallPowerwashError:
+ return "kErrorCodePostinstallPowerwashError";
+ case kErrorCodeUpdateCanceledByChannelChange:
+ return "kErrorCodeUpdateCanceledByChannelChange";
+ case kErrorCodeUmaReportedMax:
+ return "kErrorCodeUmaReportedMax";
+ case kErrorCodeOmahaRequestHTTPResponseBase:
+ return "kErrorCodeOmahaRequestHTTPResponseBase";
+ case kErrorCodeResumedFlag:
return "Resumed";
- case kActionCodeDevModeFlag:
+ case kErrorCodeDevModeFlag:
return "DevMode";
- case kActionCodeTestImageFlag:
+ case kErrorCodeTestImageFlag:
return "TestImage";
- case kActionCodeTestOmahaUrlFlag:
+ case kErrorCodeTestOmahaUrlFlag:
return "TestOmahaUrl";
- case kSpecialFlags:
- return "kSpecialFlags";
+ case kErrorCodeSpecialFlags:
+ return "kErrorCodeSpecialFlags";
// Don't add a default case to let the compiler warn about newly added
// error codes which should be added here.
}
diff --git a/utils.h b/utils.h
index 74c4d16..bc645d2 100644
--- a/utils.h
+++ b/utils.h
@@ -294,16 +294,16 @@
// aggregating error codes beyond the enum range, etc. This method is
// idempotent, i.e. if called with a value previously returned by this method,
// it'll return the same value again.
-ActionExitCode GetBaseErrorCode(ActionExitCode code);
+ErrorCode GetBaseErrorCode(ErrorCode code);
// Sends the error code to UMA using the metrics interface object in the given
// system state. It also uses the system state to determine the right UMA
// bucket for the error code.
-void SendErrorCodeToUma(SystemState* system_state, ActionExitCode code);
+void SendErrorCodeToUma(SystemState* system_state, ErrorCode code);
-// Returns a string representation of the ActionExitCodes (either the base
+// Returns a string representation of the ErrorCodes (either the base
// error codes or the bit flags) for logging purposes.
-std::string CodeToString(ActionExitCode code);
+std::string CodeToString(ErrorCode code);
// Creates the powerwash marker file with the appropriate commands in it.
// Returns true if successfully created. False otherwise.
@@ -441,13 +441,13 @@
AbstractAction* action)
: processor_(processor),
action_(action),
- code_(kActionCodeError),
+ code_(kErrorCodeError),
should_complete_(true) {}
~ScopedActionCompleter() {
if (should_complete_)
processor_->ActionComplete(action_, code_);
}
- void set_code(ActionExitCode code) { code_ = code; }
+ void set_code(ErrorCode code) { code_ = code; }
void set_should_complete(bool should_complete) {
should_complete_ = should_complete;
}
@@ -455,7 +455,7 @@
private:
ActionProcessor* processor_;
AbstractAction* action_;
- ActionExitCode code_;
+ ErrorCode code_;
bool should_complete_;
DISALLOW_COPY_AND_ASSIGN(ScopedActionCompleter);
};