Change ErrorCode into an enum class.
This change is needed in order for us to be able to import ErrorCode
symbols from chromeos_update_engine into chromeos_update_manager.
Unfortunately, shifting from plain 'enum' into an 'enum class' means
that the compiler treats the new class as a distinct type from int,
which in turn means that plenty of seamless arithmetic/bitwise
operations we used for manipulating error code values throughout the
code needed to be retrofitted with static_cast operators.
In the future, we should consider imposing a proper abstraction on
update engine error codes that'll prevent mingling with value encoding
directly and prevent such nastiness. It'll also make things more
coherent (types, semantics) and safer.
BUG=chromium:358329
TEST=Unit tests.
Change-Id: Ie55fa566b764cdab6c4785d995fb6daee4cb32d3
Reviewed-on: https://chromium-review.googlesource.com/203209
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/action_processor.cc b/action_processor.cc
index 068a399..e3862c4 100644
--- a/action_processor.cc
+++ b/action_processor.cc
@@ -65,7 +65,7 @@
if (actions_.empty()) {
LOG(INFO) << "ActionProcessor::ActionComplete: finished last action of"
" type " << old_type;
- } else if (code != kErrorCodeSuccess) {
+ } else if (code != ErrorCode::kSuccess) {
LOG(INFO) << "ActionProcessor::ActionComplete: " << old_type
<< " action failed. Aborting processing.";
actions_.clear();
diff --git a/action_processor_unittest.cc b/action_processor_unittest.cc
index 20bded6..a55f0d3 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, kErrorCodeSuccess);
+ processor()->ActionComplete(this, ErrorCode::kSuccess);
}
string Type() const { return "ActionProcessorTestAction"; }
};
@@ -66,7 +66,7 @@
processing_done_called_(false),
processing_stopped_called_(false),
action_completed_called_(false),
- action_exit_code_(kErrorCodeError) {}
+ action_exit_code_(ErrorCode::kError) {}
virtual void ProcessingDone(const ActionProcessor* processor,
ErrorCode code) {
diff --git a/action_unittest.cc b/action_unittest.cc
index e09967f..4ab5166 100644
--- a/action_unittest.cc
+++ b/action_unittest.cc
@@ -33,7 +33,7 @@
void PerformAction() {}
void CompleteAction() {
ASSERT_TRUE(processor());
- processor()->ActionComplete(this, kErrorCodeSuccess);
+ processor()->ActionComplete(this, ErrorCode::kSuccess);
}
string Type() const { return "ActionTestAction"; }
};
diff --git a/delta_performer.cc b/delta_performer.cc
index c0932df..ef66af0 100644
--- a/delta_performer.cc
+++ b/delta_performer.cc
@@ -194,7 +194,7 @@
LOG(ERROR) << "Failed to perform " << op_type_name << " operation "
<< next_operation_num_;
- *error = kErrorCodeDownloadOperationExecutionError;
+ *error = ErrorCode::kDownloadOperationExecutionError;
return false;
}
@@ -310,7 +310,7 @@
DeltaPerformer::MetadataParseResult DeltaPerformer::ParsePayloadMetadata(
const std::vector<char>& payload,
ErrorCode* error) {
- *error = kErrorCodeSuccess;
+ *error = ErrorCode::kSuccess;
const uint64_t manifest_offset = GetManifestOffset();
uint64_t manifest_size = (metadata_size_ ?
metadata_size_ - manifest_offset : 0);
@@ -323,7 +323,7 @@
// Validate the magic string.
if (memcmp(payload.data(), kDeltaMagic, strlen(kDeltaMagic)) != 0) {
LOG(ERROR) << "Bad payload format -- invalid delta magic.";
- *error = kErrorCodeDownloadInvalidMetadataMagicString;
+ *error = ErrorCode::kDownloadInvalidMetadataMagicString;
return kMetadataParseError;
}
@@ -340,7 +340,7 @@
if (major_payload_version != kSupportedMajorPayloadVersion) {
LOG(ERROR) << "Bad payload format -- unsupported payload version: "
<< major_payload_version;
- *error = kErrorCodeUnsupportedMajorPayloadVersion;
+ *error = ErrorCode::kUnsupportedMajorPayloadVersion;
return kMetadataParseError;
}
@@ -362,7 +362,7 @@
LOG(ERROR) << "Mandatory metadata size in Omaha response ("
<< install_plan_->metadata_size
<< ") is missing/incorrect, actual = " << metadata_size_;
- *error = kErrorCodeDownloadInvalidMetadataSize;
+ *error = ErrorCode::kDownloadInvalidMetadataSize;
return kMetadataParseError;
}
}
@@ -386,13 +386,13 @@
<< install_plan_->metadata_size
<< ") in Omaha response as validation is not mandatory. "
<< "Trusting metadata size in payload = " << metadata_size_;
- SendUmaStat(kErrorCodeDownloadInvalidMetadataSize);
+ SendUmaStat(ErrorCode::kDownloadInvalidMetadataSize);
}
// 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 != kErrorCodeSuccess) {
+ if (*error != ErrorCode::kSuccess) {
if (install_plan_->hash_checks_mandatory) {
// The autoupdate_CatchBadSignatures test checks for this string
// in log-files. Keep in sync.
@@ -403,13 +403,13 @@
// For non-mandatory cases, just send a UMA stat.
LOG(WARNING) << "Ignoring metadata signature validation failures";
SendUmaStat(*error);
- *error = kErrorCodeSuccess;
+ *error = ErrorCode::kSuccess;
}
// The payload metadata is deemed valid, it's safe to parse the protobuf.
if (!manifest_.ParseFromArray(&payload[manifest_offset], manifest_size)) {
LOG(ERROR) << "Unable to parse manifest in update file.";
- *error = kErrorCodeDownloadManifestParseError;
+ *error = ErrorCode::kDownloadManifestParseError;
return kMetadataParseError;
}
@@ -423,7 +423,7 @@
// and stores an action exit code in |error|.
bool DeltaPerformer::Write(const void* bytes, size_t count,
ErrorCode *error) {
- *error = kErrorCodeSuccess;
+ *error = ErrorCode::kSuccess;
const char* c_bytes = reinterpret_cast<const char*>(bytes);
system_state_->payload_state()->DownloadProgress(count);
@@ -452,7 +452,7 @@
}
// Checks the integrity of the payload manifest.
- if ((*error = ValidateManifest()) != kErrorCodeSuccess)
+ if ((*error = ValidateManifest()) != ErrorCode::kSuccess)
return false;
manifest_valid_ = true;
@@ -464,7 +464,7 @@
LogPartitionInfo(manifest_);
if (!PrimeUpdateState()) {
- *error = kErrorCodeDownloadStateInitializationError;
+ *error = ErrorCode::kDownloadStateInitializationError;
LOG(ERROR) << "Unable to prime the update state.";
return false;
}
@@ -509,7 +509,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 != kErrorCodeSuccess) {
+ if (*error != ErrorCode::kSuccess) {
if (install_plan_->hash_checks_mandatory) {
LOG(ERROR) << "Mandatory operation hash check failed";
return false;
@@ -518,7 +518,7 @@
// For non-mandatory cases, just send a UMA stat.
LOG(WARNING) << "Ignoring operation validation errors";
SendUmaStat(*error);
- *error = kErrorCodeSuccess;
+ *error = ErrorCode::kSuccess;
}
}
@@ -859,13 +859,13 @@
if (install_plan_->metadata_signature.empty()) {
if (install_plan_->hash_checks_mandatory) {
LOG(ERROR) << "Missing mandatory metadata signature in Omaha response";
- return kErrorCodeDownloadMetadataSignatureMissingError;
+ return ErrorCode::kDownloadMetadataSignatureMissingError;
}
// For non-mandatory cases, just send a UMA stat.
LOG(WARNING) << "Cannot validate metadata as the signature is empty";
- SendUmaStat(kErrorCodeDownloadMetadataSignatureMissingError);
- return kErrorCodeSuccess;
+ SendUmaStat(ErrorCode::kDownloadMetadataSignatureMissingError);
+ return ErrorCode::kSuccess;
}
// Convert base64-encoded signature to raw bytes.
@@ -874,7 +874,7 @@
&metadata_signature)) {
LOG(ERROR) << "Unable to decode base64 metadata signature: "
<< install_plan_->metadata_signature;
- return kErrorCodeDownloadMetadataSignatureError;
+ return ErrorCode::kDownloadMetadataSignatureError;
}
// See if we should use the public RSA key in the Omaha response.
@@ -894,21 +894,21 @@
path_to_public_key.value(),
&expected_metadata_hash)) {
LOG(ERROR) << "Unable to compute expected hash from metadata signature";
- return kErrorCodeDownloadMetadataSignatureError;
+ return ErrorCode::kDownloadMetadataSignatureError;
}
OmahaHashCalculator metadata_hasher;
metadata_hasher.Update(metadata, metadata_size);
if (!metadata_hasher.Finalize()) {
LOG(ERROR) << "Unable to compute actual hash of manifest";
- return kErrorCodeDownloadMetadataSignatureVerificationError;
+ return ErrorCode::kDownloadMetadataSignatureVerificationError;
}
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 kErrorCodeDownloadMetadataSignatureVerificationError;
+ return ErrorCode::kDownloadMetadataSignatureVerificationError;
}
if (calculated_metadata_hash != expected_metadata_hash) {
@@ -916,13 +916,13 @@
utils::HexDumpVector(expected_metadata_hash);
LOG(ERROR) << "Calculated hash = ";
utils::HexDumpVector(calculated_metadata_hash);
- return kErrorCodeDownloadMetadataSignatureMismatch;
+ return ErrorCode::kDownloadMetadataSignatureMismatch;
}
// The autoupdate_CatchBadSignatures test checks for this string in
// log-files. Keep in sync.
LOG(INFO) << "Metadata hash signature matches value in Omaha response.";
- return kErrorCodeSuccess;
+ return ErrorCode::kSuccess;
}
ErrorCode DeltaPerformer::ValidateManifest() {
@@ -940,7 +940,7 @@
if (manifest_.has_old_kernel_info() || manifest_.has_old_rootfs_info()) {
LOG(ERROR) << "Purported full payload contains old partition "
"hash(es), aborting update";
- return kErrorCodePayloadMismatchedType;
+ return ErrorCode::kPayloadMismatchedType;
}
if (manifest_.minor_version() != kFullPayloadMinorVersion) {
@@ -948,7 +948,7 @@
<< manifest_.minor_version()
<< ", but all full payloads should have version "
<< kFullPayloadMinorVersion << ".";
- return kErrorCodeUnsupportedMinorPayloadVersion;
+ return ErrorCode::kUnsupportedMinorPayloadVersion;
}
} else {
if (manifest_.minor_version() != kSupportedMinorPayloadVersion) {
@@ -956,14 +956,14 @@
<< manifest_.minor_version()
<< " not the supported "
<< kSupportedMinorPayloadVersion;
- return kErrorCodeUnsupportedMinorPayloadVersion;
+ return ErrorCode::kUnsupportedMinorPayloadVersion;
}
}
// TODO(garnold) we should be adding more and more manifest checks, such as
// partition boundaries etc (see chromium-os:37661).
- return kErrorCodeSuccess;
+ return ErrorCode::kSuccess;
}
ErrorCode DeltaPerformer::ValidateOperationHash(
@@ -975,7 +975,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 kErrorCodeSuccess;
+ return ErrorCode::kSuccess;
}
// No hash is present for an operation that has data blobs. This shouldn't
@@ -995,15 +995,15 @@
if (install_plan_->hash_checks_mandatory) {
LOG(ERROR) << "Missing mandatory operation hash for operation "
<< next_operation_num_ + 1;
- return kErrorCodeDownloadOperationHashMissingError;
+ return ErrorCode::kDownloadOperationHashMissingError;
}
// 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(kErrorCodeDownloadOperationHashMissingError);
+ SendUmaStat(ErrorCode::kDownloadOperationHashMissingError);
}
- return kErrorCodeSuccess;
+ return ErrorCode::kSuccess;
}
vector<char> expected_op_hash;
@@ -1016,7 +1016,7 @@
if (!operation_hasher.Finalize()) {
LOG(ERROR) << "Unable to compute actual hash of operation "
<< next_operation_num_;
- return kErrorCodeDownloadOperationHashVerificationError;
+ return ErrorCode::kDownloadOperationHashVerificationError;
}
vector<char> calculated_op_hash = operation_hasher.raw_hash();
@@ -1027,10 +1027,10 @@
LOG(ERROR) << "Calculated hash over " << operation.data_length()
<< " bytes at offset: " << operation.data_offset() << " = ";
utils::HexDumpVector(calculated_op_hash);
- return kErrorCodeDownloadOperationHashMismatch;
+ return ErrorCode::kDownloadOperationHashMismatch;
}
- return kErrorCodeSuccess;
+ return ErrorCode::kSuccess;
}
#define TEST_AND_RETURN_VAL(_retval, _condition) \
@@ -1058,38 +1058,38 @@
<< path_to_public_key.value();
// Verifies the download size.
- TEST_AND_RETURN_VAL(kErrorCodePayloadSizeMismatchError,
+ TEST_AND_RETURN_VAL(ErrorCode::kPayloadSizeMismatchError,
update_check_response_size ==
metadata_size_ + buffer_offset_);
// Verifies the payload hash.
const string& payload_hash_data = hash_calculator_.hash();
- TEST_AND_RETURN_VAL(kErrorCodeDownloadPayloadVerificationError,
+ TEST_AND_RETURN_VAL(ErrorCode::kDownloadPayloadVerificationError,
!payload_hash_data.empty());
- TEST_AND_RETURN_VAL(kErrorCodePayloadHashMismatchError,
+ TEST_AND_RETURN_VAL(ErrorCode::kPayloadHashMismatchError,
payload_hash_data == update_check_response_hash);
// Verifies the signed payload hash.
if (!utils::FileExists(path_to_public_key.value().c_str())) {
LOG(WARNING) << "Not verifying signed delta payload -- missing public key.";
- return kErrorCodeSuccess;
+ return ErrorCode::kSuccess;
}
- TEST_AND_RETURN_VAL(kErrorCodeSignedDeltaPayloadExpectedError,
+ TEST_AND_RETURN_VAL(ErrorCode::kSignedDeltaPayloadExpectedError,
!signatures_message_data_.empty());
vector<char> signed_hash_data;
- TEST_AND_RETURN_VAL(kErrorCodeDownloadPayloadPubKeyVerificationError,
+ TEST_AND_RETURN_VAL(ErrorCode::kDownloadPayloadPubKeyVerificationError,
PayloadSigner::VerifySignature(
signatures_message_data_,
path_to_public_key.value(),
&signed_hash_data));
OmahaHashCalculator signed_hasher;
- TEST_AND_RETURN_VAL(kErrorCodeDownloadPayloadPubKeyVerificationError,
+ TEST_AND_RETURN_VAL(ErrorCode::kDownloadPayloadPubKeyVerificationError,
signed_hasher.SetContext(signed_hash_context_));
- TEST_AND_RETURN_VAL(kErrorCodeDownloadPayloadPubKeyVerificationError,
+ TEST_AND_RETURN_VAL(ErrorCode::kDownloadPayloadPubKeyVerificationError,
signed_hasher.Finalize());
vector<char> hash_data = signed_hasher.raw_hash();
PayloadSigner::PadRSA2048SHA256Hash(&hash_data);
- TEST_AND_RETURN_VAL(kErrorCodeDownloadPayloadPubKeyVerificationError,
+ TEST_AND_RETURN_VAL(ErrorCode::kDownloadPayloadPubKeyVerificationError,
!hash_data.empty());
if (hash_data != signed_hash_data) {
// The autoupdate_CatchBadSignatures test checks for this string
@@ -1099,7 +1099,7 @@
utils::HexDumpVector(signed_hash_data);
LOG(ERROR) << "Computed Signature:";
utils::HexDumpVector(hash_data);
- return kErrorCodeDownloadPayloadPubKeyVerificationError;
+ return ErrorCode::kDownloadPayloadPubKeyVerificationError;
}
LOG(INFO) << "Payload hash matches value in payload.";
@@ -1111,7 +1111,7 @@
// indicate that to the payload state so that AU can backoff appropriately.
system_state_->payload_state()->DownloadComplete();
- return kErrorCodeSuccess;
+ return ErrorCode::kSuccess;
}
bool DeltaPerformer::GetNewPartitionInfo(uint64_t* kernel_size,
diff --git a/delta_performer.h b/delta_performer.h
index 4338646..8fffffb 100644
--- a/delta_performer.h
+++ b/delta_performer.h
@@ -106,10 +106,10 @@
// 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 kErrorCodeSuccess on success, an
+ // size using the public key and returns ErrorCode::kSuccess 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 kErrorCodeSignedDeltaPayloadExpectedError if the
+ // unavailable; it returns ErrorCode::kSignedDeltaPayloadExpectedError if the
// public key is available but the delta payload doesn't include a signature.
ErrorCode VerifyPayload(const std::string& update_check_response_hash,
const uint64_t update_check_response_size);
@@ -225,14 +225,14 @@
// Validates that the hash of the blobs corresponding to the given |operation|
// matches what's specified in the manifest in the payload.
- // Returns kErrorCodeSuccess on match or a suitable error code otherwise.
+ // Returns ErrorCode::kSuccess 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 kErrorCodeSuccess on match or a suitable error code otherwise.
+ // Returns ErrorCode::kSuccess 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
diff --git a/delta_performer_unittest.cc b/delta_performer_unittest.cc
index dc0b202..a063fa2 100644
--- a/delta_performer_unittest.cc
+++ b/delta_performer_unittest.cc
@@ -43,7 +43,13 @@
extern const char* kUnittestPublicKey2Path;
static const size_t kBlockSize = 4096;
-static const char* kBogusMetadataSignature1 = "awSFIUdUZz2VWFiR+ku0Pj00V7bPQPQFYQSXjEXr3vaw3TE4xHV5CraY3/YrZpBvJ5z4dSBskoeuaO1TNC/S6E05t+yt36tE4Fh79tMnJ/z9fogBDXWgXLEUyG78IEQrYH6/eBsQGT2RJtBgXIXbZ9W+5G9KmGDoPOoiaeNsDuqHiBc/58OFsrxskH8E6vMSBmMGGk82mvgzic7ApcoURbCGey1b3Mwne/hPZ/bb9CIyky8Og9IfFMdL2uAweOIRfjoTeLYZpt+WN65Vu7jJ0cQN8e1y+2yka5112wpRf/LLtPgiAjEZnsoYpLUd7CoVpLRtClp97kN2+tXGNBQqkA==";
+static const char* kBogusMetadataSignature1 =
+ "awSFIUdUZz2VWFiR+ku0Pj00V7bPQPQFYQSXjEXr3vaw3TE4xHV5CraY3/YrZpBv"
+ "J5z4dSBskoeuaO1TNC/S6E05t+yt36tE4Fh79tMnJ/z9fogBDXWgXLEUyG78IEQr"
+ "YH6/eBsQGT2RJtBgXIXbZ9W+5G9KmGDoPOoiaeNsDuqHiBc/58OFsrxskH8E6vMS"
+ "BmMGGk82mvgzic7ApcoURbCGey1b3Mwne/hPZ/bb9CIyky8Og9IfFMdL2uAweOIR"
+ "fjoTeLYZpt+WN65Vu7jJ0cQN8e1y+2yka5112wpRf/LLtPgiAjEZnsoYpLUd7CoV"
+ "pLRtClp97kN2+tXGNBQqkA==";
static const int kDefaultKernelSize = 4096; // Something small for a test
static const char* kNewDataString = "This is new data.";
@@ -673,7 +679,7 @@
int some_offset = state->metadata_size + 300;
LOG(INFO) << "Tampered value at offset: " << some_offset;
state->delta[some_offset]++;
- expected_error = kErrorCodeDownloadOperationHashMismatch;
+ expected_error = ErrorCode::kDownloadOperationHashMismatch;
continue_writing = false;
break;
}
@@ -681,7 +687,7 @@
case kValidOperationData:
default:
// no change.
- expected_error = kErrorCodeSuccess;
+ expected_error = ErrorCode::kSuccess;
continue_writing = true;
break;
}
@@ -694,7 +700,7 @@
count,
&actual_error));
// Normally write_succeeded should be true every time and
- // actual_error should be kErrorCodeSuccess. If so, continue the loop.
+ // actual_error should be ErrorCode::kSuccess. 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
@@ -709,7 +715,7 @@
}
}
- EXPECT_EQ(kErrorCodeSuccess, actual_error);
+ EXPECT_EQ(ErrorCode::kSuccess, actual_error);
}
// If we had continued all the way through, Close should succeed.
@@ -729,7 +735,7 @@
return;
}
- int expected_times = (expected_result == kErrorCodeSuccess) ? 1 : 0;
+ int expected_times = (expected_result == ErrorCode::kSuccess) ? 1 : 0;
EXPECT_CALL(*(state->fake_system_state.mock_payload_state()),
DownloadComplete()).Times(expected_times);
@@ -740,7 +746,7 @@
state->delta.size()));
LOG(INFO) << "Verified payload.";
- if (expected_result != kErrorCodeSuccess) {
+ if (expected_result != ErrorCode::kSuccess) {
// no need to verify new partition if VerifyPayload failed.
return;
}
@@ -778,13 +784,13 @@
void VerifyPayload(DeltaPerformer* performer,
DeltaState* state,
SignatureTest signature_test) {
- ErrorCode expected_result = kErrorCodeSuccess;
+ ErrorCode expected_result = ErrorCode::kSuccess;
switch (signature_test) {
case kSignatureNone:
- expected_result = kErrorCodeSignedDeltaPayloadExpectedError;
+ expected_result = ErrorCode::kSignedDeltaPayloadExpectedError;
break;
case kSignatureGeneratedShellBadKey:
- expected_result = kErrorCodeDownloadPayloadPubKeyVerificationError;
+ expected_result = ErrorCode::kDownloadPayloadPubKeyVerificationError;
break;
default: break; // appease gcc
}
@@ -844,7 +850,7 @@
EXPECT_TRUE(result);
} else {
EXPECT_FALSE(result);
- EXPECT_EQ(kErrorCodeDownloadInvalidMetadataSize, error_code);
+ EXPECT_EQ(ErrorCode::kDownloadInvalidMetadataSize, error_code);
}
EXPECT_LT(performer.Close(), 0);
@@ -886,13 +892,13 @@
case kEmptyMetadataSignature:
install_plan.metadata_signature.clear();
expected_result = DeltaPerformer::kMetadataParseError;
- expected_error = kErrorCodeDownloadMetadataSignatureMissingError;
+ expected_error = ErrorCode::kDownloadMetadataSignatureMissingError;
break;
case kInvalidMetadataSignature:
install_plan.metadata_signature = kBogusMetadataSignature1;
expected_result = DeltaPerformer::kMetadataParseError;
- expected_error = kErrorCodeDownloadMetadataSignatureMismatch;
+ expected_error = ErrorCode::kDownloadMetadataSignatureMismatch;
break;
case kValidMetadataSignature:
@@ -907,14 +913,14 @@
&install_plan.metadata_signature));
EXPECT_FALSE(install_plan.metadata_signature.empty());
expected_result = DeltaPerformer::kMetadataParseSuccess;
- expected_error = kErrorCodeSuccess;
+ expected_error = ErrorCode::kSuccess;
break;
}
// Ignore the expected result/error if hash checks are not mandatory.
if (!hash_checks_mandatory) {
expected_result = DeltaPerformer::kMetadataParseSuccess;
- expected_error = kErrorCodeSuccess;
+ expected_error = ErrorCode::kSuccess;
}
// Create the delta performer object.
@@ -930,7 +936,7 @@
// Init actual_error with an invalid value so that we make sure
// ParsePayloadMetadata properly populates it in all cases.
- actual_error = kErrorCodeUmaReportedMax;
+ actual_error = ErrorCode::kUmaReportedMax;
actual_result = delta_performer.ParsePayloadMetadata(payload, &actual_error);
EXPECT_EQ(expected_result, actual_result);
@@ -1008,7 +1014,8 @@
manifest.mutable_new_rootfs_info();
manifest.set_minor_version(DeltaPerformer::kFullPayloadMinorVersion);
- DeltaPerformerTest::RunManifestValidation(manifest, true, kErrorCodeSuccess);
+ DeltaPerformerTest::RunManifestValidation(manifest, true,
+ ErrorCode::kSuccess);
}
TEST(DeltaPerformerTest, ValidateManifestDeltaGoodTest) {
@@ -1020,14 +1027,16 @@
manifest.mutable_new_rootfs_info();
manifest.set_minor_version(DeltaPerformer::kSupportedMinorPayloadVersion);
- DeltaPerformerTest::RunManifestValidation(manifest, false, kErrorCodeSuccess);
+ DeltaPerformerTest::RunManifestValidation(manifest, false,
+ ErrorCode::kSuccess);
}
TEST(DeltaPerformerTest, ValidateManifestFullUnsetMinorVersion) {
// The Manifest we are validating.
DeltaArchiveManifest manifest;
- DeltaPerformerTest::RunManifestValidation(manifest, true, kErrorCodeSuccess);
+ DeltaPerformerTest::RunManifestValidation(manifest, true,
+ ErrorCode::kSuccess);
}
TEST(DeltaPerformerTest, ValidateManifestDeltaUnsetMinorVersion) {
@@ -1036,7 +1045,7 @@
DeltaPerformerTest::RunManifestValidation(
manifest, false,
- kErrorCodeUnsupportedMinorPayloadVersion);
+ ErrorCode::kUnsupportedMinorPayloadVersion);
}
TEST(DeltaPerformerTest, ValidateManifestFullOldKernelTest) {
@@ -1049,7 +1058,7 @@
DeltaPerformerTest::RunManifestValidation(
manifest, true,
- kErrorCodePayloadMismatchedType);
+ ErrorCode::kPayloadMismatchedType);
}
TEST(DeltaPerformerTest, ValidateManifestFullOldRootfsTest) {
@@ -1062,7 +1071,7 @@
DeltaPerformerTest::RunManifestValidation(
manifest, true,
- kErrorCodePayloadMismatchedType);
+ ErrorCode::kPayloadMismatchedType);
}
TEST(DeltaPerformerTest, ValidateManifestBadMinorVersion) {
@@ -1075,7 +1084,7 @@
DeltaPerformerTest::RunManifestValidation(
manifest, false,
- kErrorCodeUnsupportedMinorPayloadVersion);
+ ErrorCode::kUnsupportedMinorPayloadVersion);
}
TEST(DeltaPerformerTest, RunAsRootSmallImageTest) {
diff --git a/download_action.cc b/download_action.cc
index 8d211ea..6f4811a 100644
--- a/download_action.cc
+++ b/download_action.cc
@@ -33,7 +33,7 @@
system_state_(system_state),
http_fetcher_(http_fetcher),
writer_(NULL),
- code_(kErrorCodeSuccess),
+ code_(ErrorCode::kSuccess),
delegate_(NULL),
bytes_received_(0),
p2p_sharing_fd_(-1),
@@ -172,7 +172,7 @@
if (rc < 0) {
LOG(ERROR) << "Unable to open output file " << install_plan_.install_path;
// report error to processor
- processor_->ActionComplete(this, kErrorCodeInstallDeviceOpenError);
+ processor_->ActionComplete(this, ErrorCode::kInstallDeviceOpenError);
return;
}
if (delta_performer_.get() &&
@@ -181,7 +181,7 @@
LOG(ERROR) << "Unable to open kernel file "
<< install_plan_.kernel_install_path.c_str();
writer_->Close();
- processor_->ActionComplete(this, kErrorCodeKernelDeviceOpenError);
+ processor_->ActionComplete(this, ErrorCode::kKernelDeviceOpenError);
return;
}
if (delegate_) {
@@ -291,11 +291,11 @@
delegate_->SetDownloadStatus(false); // Set to inactive.
}
ErrorCode code =
- successful ? kErrorCodeSuccess : kErrorCodeDownloadTransferError;
- if (code == kErrorCodeSuccess && delta_performer_.get()) {
+ successful ? ErrorCode::kSuccess : ErrorCode::kDownloadTransferError;
+ if (code == ErrorCode::kSuccess && delta_performer_.get()) {
code = delta_performer_->VerifyPayload(install_plan_.payload_hash,
install_plan_.payload_size);
- if (code != kErrorCodeSuccess) {
+ if (code != ErrorCode::kSuccess) {
LOG(ERROR) << "Download of " << install_plan_.download_url
<< " failed due to payload verification error.";
// Delete p2p file, if applicable.
@@ -307,18 +307,18 @@
&install_plan_.rootfs_size,
&install_plan_.rootfs_hash)) {
LOG(ERROR) << "Unable to get new partition hash info.";
- code = kErrorCodeDownloadNewPartitionInfoError;
+ code = ErrorCode::kDownloadNewPartitionInfoError;
}
}
// Write the path to the output pipe if we're successful.
- if (code == kErrorCodeSuccess && HasOutputPipe())
+ if (code == ErrorCode::kSuccess && HasOutputPipe())
SetOutputObject(install_plan_);
processor_->ActionComplete(this, code);
}
void DownloadAction::TransferTerminated(HttpFetcher *fetcher) {
- if (code_ != kErrorCodeSuccess) {
+ if (code_ != ErrorCode::kSuccess) {
processor_->ActionComplete(this, code_);
}
}
diff --git a/download_action_unittest.cc b/download_action_unittest.cc
index 6f05a8b..7bf2530 100644
--- a/download_action_unittest.cc
+++ b/download_action_unittest.cc
@@ -60,7 +60,7 @@
g_main_loop_quit(loop_);
vector<char> found_data;
ASSERT_TRUE(utils::ReadFile(path_, &found_data));
- if (expected_code_ != kErrorCodeDownloadWriteError) {
+ if (expected_code_ != ErrorCode::kDownloadWriteError) {
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]);
@@ -76,7 +76,7 @@
if (type == DownloadAction::StaticType()) {
EXPECT_EQ(expected_code_, code);
} else {
- EXPECT_EQ(kErrorCodeSuccess, code);
+ EXPECT_EQ(ErrorCode::kSuccess, code);
}
}
@@ -172,9 +172,9 @@
EXPECT_CALL(download_delegate, BytesReceived(_, _)).Times(AtLeast(1));
EXPECT_CALL(download_delegate, SetDownloadStatus(false)).Times(1);
}
- ErrorCode expected_code = kErrorCodeSuccess;
+ ErrorCode expected_code = ErrorCode::kSuccess;
if (fail_write > 0)
- expected_code = kErrorCodeDownloadWriteError;
+ expected_code = ErrorCode::kDownloadWriteError;
DownloadActionTestProcessorDelegate delegate(expected_code);
delegate.loop_ = loop;
delegate.expected_data_ = vector<char>(data.begin() + 1, data.end());
@@ -334,7 +334,7 @@
ASSERT_TRUE(HasInputObject());
EXPECT_TRUE(expected_input_object_ == GetInputObject());
ASSERT_TRUE(processor());
- processor()->ActionComplete(this, kErrorCodeSuccess);
+ processor()->ActionComplete(this, ErrorCode::kSuccess);
}
string Type() const { return "DownloadActionTestAction"; }
InstallPlan expected_input_object_;
@@ -501,7 +501,7 @@
http_fetcher_));
download_action_->SetTestFileWriter(&writer);
BondActions(&feeder_action, download_action_.get());
- DownloadActionTestProcessorDelegate delegate(kErrorCodeSuccess);
+ DownloadActionTestProcessorDelegate delegate(ErrorCode::kSuccess);
delegate.loop_ = loop_;
delegate.expected_data_ = vector<char>(data_.begin() + start_at_offset_,
data_.end());
diff --git a/error_code.h b/error_code.h
index fc66ac9..5f3a2cb 100644
--- a/error_code.h
+++ b/error_code.h
@@ -5,56 +5,58 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_ERROR_CODE_H_
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_ERROR_CODE_H_
+#include <ostream>
+
namespace chromeos_update_engine {
// Action exit codes.
-enum ErrorCode {
- kErrorCodeSuccess = 0,
- kErrorCodeError = 1,
- kErrorCodeOmahaRequestError = 2,
- kErrorCodeOmahaResponseHandlerError = 3,
- kErrorCodeFilesystemCopierError = 4,
- kErrorCodePostinstallRunnerError = 5,
- kErrorCodePayloadMismatchedType = 6,
- 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,
- kErrorCodePostinstallFirmwareRONotUpdatable = 43,
- kErrorCodeUnsupportedMajorPayloadVersion = 44,
- kErrorCodeUnsupportedMinorPayloadVersion = 45,
+enum class ErrorCode : int {
+ kSuccess = 0,
+ kError = 1,
+ kOmahaRequestError = 2,
+ kOmahaResponseHandlerError = 3,
+ kFilesystemCopierError = 4,
+ kPostinstallRunnerError = 5,
+ kPayloadMismatchedType = 6,
+ kInstallDeviceOpenError = 7,
+ kKernelDeviceOpenError = 8,
+ kDownloadTransferError = 9,
+ kPayloadHashMismatchError = 10,
+ kPayloadSizeMismatchError = 11,
+ kDownloadPayloadVerificationError = 12,
+ kDownloadNewPartitionInfoError = 13,
+ kDownloadWriteError = 14,
+ kNewRootfsVerificationError = 15,
+ kNewKernelVerificationError = 16,
+ kSignedDeltaPayloadExpectedError = 17,
+ kDownloadPayloadPubKeyVerificationError = 18,
+ kPostinstallBootedFromFirmwareB = 19,
+ kDownloadStateInitializationError = 20,
+ kDownloadInvalidMetadataMagicString = 21,
+ kDownloadSignatureMissingInManifest = 22,
+ kDownloadManifestParseError = 23,
+ kDownloadMetadataSignatureError = 24,
+ kDownloadMetadataSignatureVerificationError = 25,
+ kDownloadMetadataSignatureMismatch = 26,
+ kDownloadOperationHashVerificationError = 27,
+ kDownloadOperationExecutionError = 28,
+ kDownloadOperationHashMismatch = 29,
+ kOmahaRequestEmptyResponseError = 30,
+ kOmahaRequestXMLParseError = 31,
+ kDownloadInvalidMetadataSize = 32,
+ kDownloadInvalidMetadataSignature = 33,
+ kOmahaResponseInvalid = 34,
+ kOmahaUpdateIgnoredPerPolicy = 35,
+ kOmahaUpdateDeferredPerPolicy = 36,
+ kOmahaErrorInHTTPResponse = 37,
+ kDownloadOperationHashMissingError = 38,
+ kDownloadMetadataSignatureMissingError = 39,
+ kOmahaUpdateDeferredForBackoff = 40,
+ kPostinstallPowerwashError = 41,
+ kUpdateCanceledByChannelChange = 42,
+ kPostinstallFirmwareRONotUpdatable = 43,
+ kUnsupportedMajorPayloadVersion = 44,
+ kUnsupportedMinorPayloadVersion = 45,
// VERY IMPORTANT! When adding new error codes:
//
@@ -64,10 +66,10 @@
// build until this case is added.
// Any code above this is sent to both Omaha and UMA as-is, except
- // kErrorCodeOmahaErrorInHTTPResponse (see error code 2000 for more details).
+ // kOmahaErrorInHTTPResponse (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
+ // kUmaReportedMax 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
@@ -75,38 +77,45 @@
// 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,
+ kUmaReportedMax,
// 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
+ // errors are aggregated into one: kOmahaErrorInHTTPResponse.
+ kOmahaRequestHTTPResponseBase = 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,
+ // TODO(garnold) This is very debatable value to use, knowing that the
+ // underlying type is a signed int (often, 32-bit). However, at this point
+ // there are parts of the ecosystem that expect this to be a negative value,
+ // so we preserve this semantics. This should be reconsidered if/when we
+ // modify the implementation of ErrorCode into a properly encapsulated class.
+ kDevModeFlag = 1 << 31,
// Set if resuming an interruped update.
- kErrorCodeResumedFlag = 1 << 30,
+ kResumedFlag = 1 << 30,
// Set if using a dev/test image as opposed to an MP-signed image.
- kErrorCodeTestImageFlag = 1 << 29,
+ kTestImageFlag = 1 << 29,
// Set if using devserver or Omaha sandbox (using crosh autest).
- kErrorCodeTestOmahaUrlFlag = 1 << 28,
+ kTestOmahaUrlFlag = 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)
+ kSpecialFlags = (kDevModeFlag | kResumedFlag | kTestImageFlag |
+ kTestOmahaUrlFlag)
};
+inline std::ostream& operator<<(std::ostream& os, ErrorCode val) {
+ return os << static_cast<int>(val);
+}
+
} // namespace chromeos_update_engine
#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_ERROR_CODE_H_
diff --git a/file_writer.h b/file_writer.h
index 9350bb6..155fe74 100644
--- a/file_writer.h
+++ b/file_writer.h
@@ -41,7 +41,7 @@
virtual bool Write(const void* bytes,
size_t count,
ErrorCode* error) {
- *error = kErrorCodeDownloadWriteError;
+ *error = ErrorCode::kDownloadWriteError;
return Write(bytes, count);
}
diff --git a/filesystem_copier_action.cc b/filesystem_copier_action.cc
index d557eba..4bfde99 100644
--- a/filesystem_copier_action.cc
+++ b/filesystem_copier_action.cc
@@ -79,7 +79,7 @@
LOG(INFO) << "filesystem copying skipped on resumed update.";
if (HasOutputPipe())
SetOutputObject(install_plan_);
- abort_action_completer.set_code(kErrorCodeSuccess);
+ abort_action_completer.set_code(ErrorCode::kSuccess);
return;
}
@@ -96,7 +96,7 @@
LOG(INFO) << "filesystem copying skipped on full update.";
if (HasOutputPipe())
SetOutputObject(install_plan_);
- abort_action_completer.set_code(kErrorCodeSuccess);
+ abort_action_completer.set_code(ErrorCode::kSuccess);
return;
}
@@ -169,7 +169,7 @@
}
if (cancelled_)
return;
- if (code == kErrorCodeSuccess && HasOutputPipe())
+ if (code == ErrorCode::kSuccess && HasOutputPipe())
SetOutputObject(install_plan_);
processor_->ActionComplete(this, code);
}
@@ -268,7 +268,7 @@
}
if (failed_ || cancelled_) {
if (!reading && !writing) {
- Cleanup(kErrorCodeError);
+ Cleanup(ErrorCode::kError);
}
return;
}
@@ -302,18 +302,18 @@
}
if (!reading && !writing) {
// We're done!
- ErrorCode code = kErrorCodeSuccess;
+ ErrorCode code = ErrorCode::kSuccess;
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 = kErrorCodeNewKernelVerificationError;
+ code = ErrorCode::kNewKernelVerificationError;
LOG(ERROR) << "New kernel verification failed.";
}
} else {
if (install_plan_.rootfs_hash != hasher_.raw_hash()) {
- code = kErrorCodeNewRootfsVerificationError;
+ code = ErrorCode::kNewRootfsVerificationError;
LOG(ERROR) << "New rootfs verification failed.";
}
}
@@ -326,7 +326,7 @@
}
} else {
LOG(ERROR) << "Unable to finalize the hash.";
- code = kErrorCodeError;
+ code = ErrorCode::kError;
}
Cleanup(code);
}
diff --git a/filesystem_copier_action_unittest.cc b/filesystem_copier_action_unittest.cc
index 300708f..3e5f1b9 100644
--- a/filesystem_copier_action_unittest.cc
+++ b/filesystem_copier_action_unittest.cc
@@ -49,7 +49,7 @@
public:
FilesystemCopierActionTestDelegate(GMainLoop* loop,
FilesystemCopierAction* action)
- : loop_(loop), action_(action), ran_(false), code_(kErrorCodeError) {}
+ : loop_(loop), action_(action), ran_(false), code_(ErrorCode::kError) {}
void ExitMainLoop() {
GMainContext* context = g_main_loop_get_context(loop_);
// We cannot use g_main_context_pending() alone to determine if it is safe
@@ -242,18 +242,18 @@
success = success && is_delegate_ran;
}
if (run_out_of_space || terminate_early) {
- EXPECT_EQ(kErrorCodeError, delegate.code());
- return (kErrorCodeError == delegate.code());
+ EXPECT_EQ(ErrorCode::kError, delegate.code());
+ return (ErrorCode::kError == delegate.code());
}
if (verify_hash == 2) {
ErrorCode expected_exit_code =
(use_kernel_partition ?
- kErrorCodeNewKernelVerificationError :
- kErrorCodeNewRootfsVerificationError);
+ ErrorCode::kNewKernelVerificationError :
+ ErrorCode::kNewRootfsVerificationError);
EXPECT_EQ(expected_exit_code, delegate.code());
return (expected_exit_code == delegate.code());
}
- EXPECT_EQ(kErrorCodeSuccess, delegate.code());
+ EXPECT_EQ(ErrorCode::kSuccess, delegate.code());
// Make sure everything in the out_image is there
vector<char> a_out;
@@ -320,7 +320,7 @@
processor.StartProcessing();
EXPECT_FALSE(processor.IsRunning());
EXPECT_TRUE(delegate.ran_);
- EXPECT_EQ(kErrorCodeError, delegate.code_);
+ EXPECT_EQ(ErrorCode::kError, delegate.code_);
}
TEST_F(FilesystemCopierActionTest, ResumeTest) {
@@ -345,7 +345,7 @@
processor.StartProcessing();
EXPECT_FALSE(processor.IsRunning());
EXPECT_TRUE(delegate.ran_);
- EXPECT_EQ(kErrorCodeSuccess, delegate.code_);
+ EXPECT_EQ(ErrorCode::kSuccess, delegate.code_);
EXPECT_EQ(kUrl, collector_action.object().download_url);
}
@@ -378,7 +378,7 @@
processor.StartProcessing();
EXPECT_FALSE(processor.IsRunning());
EXPECT_TRUE(delegate.ran_);
- EXPECT_EQ(kErrorCodeError, delegate.code_);
+ EXPECT_EQ(ErrorCode::kError, delegate.code_);
}
TEST_F(FilesystemCopierActionTest, RunAsRootVerifyHashTest) {
diff --git a/install_plan.h b/install_plan.h
index 9090f0b..b6bf293 100644
--- a/install_plan.h
+++ b/install_plan.h
@@ -102,7 +102,7 @@
if (HasOutputPipe()) {
SetOutputObject(install_plan_);
}
- processor_->ActionComplete(this, kErrorCodeSuccess);
+ processor_->ActionComplete(this, ErrorCode::kSuccess);
}
InstallPlan* install_plan() { return &install_plan_; }
diff --git a/metrics.cc b/metrics.cc
index f8a316a..f98f3e5 100644
--- a/metrics.cc
+++ b/metrics.cc
@@ -276,14 +276,14 @@
static_cast<int>(attempt_result),
static_cast<int>(AttemptResult::kNumConstants));
- if (internal_error_code != kErrorCodeSuccess) {
+ if (internal_error_code != ErrorCode::kSuccess) {
metric = metrics::kMetricAttemptInternalErrorCode;
LOG(INFO) << "Uploading " << internal_error_code
<< " for metric " << metric;
system_state->metrics_lib()->SendEnumToUMA(
metric,
- internal_error_code,
- kErrorCodeUmaReportedMax);
+ static_cast<int>(internal_error_code),
+ static_cast<int>(ErrorCode::kUmaReportedMax));
}
if (payload_download_error_code != DownloadErrorCode::kUnset) {
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index 9e43385..5955157 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -166,7 +166,8 @@
// is not success.
string error_code;
if (event->result != OmahaEvent::kResultSuccess) {
- error_code = base::StringPrintf(" errorcode=\"%d\"", event->error_code);
+ error_code = base::StringPrintf(" errorcode=\"%d\"",
+ static_cast<int>(event->error_code));
}
app_body = base::StringPrintf(
" <event eventtype=\"%d\" eventresult=\"%d\"%s></event>\n",
@@ -412,7 +413,7 @@
if (ping_only_ &&
!ShouldPing(ping_active_days_) &&
!ShouldPing(ping_roll_call_days_)) {
- processor_->ActionComplete(this, kErrorCodeSuccess);
+ processor_->ActionComplete(this, ErrorCode::kSuccess);
return;
}
@@ -535,7 +536,7 @@
scoped_ptr<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
xpath_nodeset(GetNodeSet(doc, ConstXMLStr(kUpdatecheckNodeXpath)));
if (!xpath_nodeset.get()) {
- completer->set_code(kErrorCodeOmahaResponseInvalid);
+ completer->set_code(ErrorCode::kOmahaResponseInvalid);
return false;
}
@@ -603,7 +604,7 @@
// Get status.
if (!xmlHasProp(update_check_node, ConstXMLStr("status"))) {
LOG(ERROR) << "Omaha Response missing status";
- completer->set_code(kErrorCodeOmahaResponseInvalid);
+ completer->set_code(ErrorCode::kOmahaResponseInvalid);
return false;
}
@@ -612,13 +613,13 @@
LOG(INFO) << "No update.";
output_object->update_exists = false;
SetOutputObject(*output_object);
- completer->set_code(kErrorCodeSuccess);
+ completer->set_code(ErrorCode::kSuccess);
return false;
}
if (status != "ok") {
LOG(ERROR) << "Unknown Omaha response status: " << status;
- completer->set_code(kErrorCodeOmahaResponseInvalid);
+ completer->set_code(ErrorCode::kOmahaResponseInvalid);
return false;
}
@@ -634,7 +635,7 @@
scoped_ptr<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
xpath_nodeset(GetNodeSet(doc, ConstXMLStr(kUpdateUrlNodeXPath)));
if (!xpath_nodeset.get()) {
- completer->set_code(kErrorCodeOmahaResponseInvalid);
+ completer->set_code(ErrorCode::kOmahaResponseInvalid);
return false;
}
@@ -649,7 +650,7 @@
const string codebase(XmlGetProperty(url_node, "codebase"));
if (codebase.empty()) {
LOG(ERROR) << "Omaha Response URL has empty codebase";
- completer->set_code(kErrorCodeOmahaResponseInvalid);
+ completer->set_code(ErrorCode::kOmahaResponseInvalid);
return false;
}
output_object->payload_urls.push_back(codebase);
@@ -668,7 +669,7 @@
scoped_ptr<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
xpath_nodeset(GetNodeSet(doc, ConstXMLStr(kPackageNodeXPath)));
if (!xpath_nodeset.get()) {
- completer->set_code(kErrorCodeOmahaResponseInvalid);
+ completer->set_code(ErrorCode::kOmahaResponseInvalid);
return false;
}
@@ -687,7 +688,7 @@
LOG(INFO) << "Omaha Response package name = " << package_name;
if (package_name.empty()) {
LOG(ERROR) << "Omaha Response has empty package name";
- completer->set_code(kErrorCodeOmahaResponseInvalid);
+ completer->set_code(ErrorCode::kOmahaResponseInvalid);
return false;
}
@@ -701,7 +702,7 @@
off_t size = ParseInt(XmlGetProperty(package_node, "size"));
if (size <= 0) {
LOG(ERROR) << "Omaha Response has invalid payload size: " << size;
- completer->set_code(kErrorCodeOmahaResponseInvalid);
+ completer->set_code(ErrorCode::kOmahaResponseInvalid);
return false;
}
output_object->size = size;
@@ -723,7 +724,7 @@
scoped_ptr<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
xpath_manifest_nodeset(GetNodeSet(doc, ConstXMLStr(kManifestNodeXPath)));
if (!xpath_manifest_nodeset.get()) {
- completer->set_code(kErrorCodeOmahaResponseInvalid);
+ completer->set_code(ErrorCode::kOmahaResponseInvalid);
return false;
}
@@ -737,7 +738,7 @@
output_object->version = XmlGetProperty(manifest_node, kTagVersion);
if (output_object->version.empty()) {
LOG(ERROR) << "Omaha Response does not have version in manifest!";
- completer->set_code(kErrorCodeOmahaResponseInvalid);
+ completer->set_code(ErrorCode::kOmahaResponseInvalid);
return false;
}
@@ -748,7 +749,7 @@
scoped_ptr<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
xpath_action_nodeset(GetNodeSet(doc, ConstXMLStr(kActionNodeXPath)));
if (!xpath_action_nodeset.get()) {
- completer->set_code(kErrorCodeOmahaResponseInvalid);
+ completer->set_code(ErrorCode::kOmahaResponseInvalid);
return false;
}
@@ -772,14 +773,14 @@
if (!pie_action_node) {
LOG(ERROR) << "Omaha Response has no postinstall event action";
- completer->set_code(kErrorCodeOmahaResponseInvalid);
+ completer->set_code(ErrorCode::kOmahaResponseInvalid);
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(kErrorCodeOmahaResponseInvalid);
+ completer->set_code(ErrorCode::kOmahaResponseInvalid);
return false;
}
@@ -830,7 +831,7 @@
LOG(INFO) << "Signalling Crash Reporter.";
utils::ScheduleCrashReporterUpload();
}
- completer.set_code(kErrorCodeSuccess);
+ completer.set_code(ErrorCode::kSuccess);
return;
}
@@ -842,7 +843,7 @@
code = 999;
}
completer.set_code(static_cast<ErrorCode>(
- kErrorCodeOmahaRequestHTTPResponseBase + code));
+ static_cast<int>(ErrorCode::kOmahaRequestHTTPResponseBase) + code));
return;
}
@@ -852,8 +853,8 @@
if (!doc.get()) {
LOG(ERROR) << "Omaha response not valid XML";
completer.set_code(response_buffer_.empty() ?
- kErrorCodeOmahaRequestEmptyResponseError :
- kErrorCodeOmahaRequestXMLParseError);
+ ErrorCode::kOmahaRequestEmptyResponseError :
+ ErrorCode::kOmahaRequestXMLParseError);
return;
}
@@ -870,7 +871,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(kErrorCodeSuccess);
+ completer.set_code(ErrorCode::kSuccess);
return;
}
@@ -882,7 +883,7 @@
if (ShouldIgnoreUpdate(output_object)) {
output_object.update_exists = false;
- completer.set_code(kErrorCodeOmahaUpdateIgnoredPerPolicy);
+ completer.set_code(ErrorCode::kOmahaUpdateIgnoredPerPolicy);
return;
}
@@ -942,7 +943,7 @@
if (ShouldDeferDownload(&output_object)) {
output_object.update_exists = false;
LOG(INFO) << "Ignoring Omaha updates as updates are deferred by policy.";
- completer.set_code(kErrorCodeOmahaUpdateDeferredPerPolicy);
+ completer.set_code(ErrorCode::kOmahaUpdateDeferredPerPolicy);
return;
}
@@ -950,10 +951,10 @@
output_object.update_exists = false;
LOG(INFO) << "Ignoring Omaha updates in order to backoff our retry "
<< "attempts";
- completer.set_code(kErrorCodeOmahaUpdateDeferredForBackoff);
+ completer.set_code(ErrorCode::kOmahaUpdateDeferredForBackoff);
return;
}
- completer.set_code(kErrorCodeSuccess);
+ completer.set_code(ErrorCode::kSuccess);
}
void OmahaRequestAction::OnLookupPayloadViaP2PCompleted(const string& url) {
@@ -1303,7 +1304,7 @@
// Regular update attempt.
switch (code) {
- case kErrorCodeSuccess:
+ case ErrorCode::kSuccess:
// OK, we parsed the response successfully but that does
// necessarily mean that an update is available.
if (HasOutputPipe()) {
@@ -1319,17 +1320,17 @@
}
break;
- case kErrorCodeOmahaUpdateIgnoredPerPolicy:
+ case ErrorCode::kOmahaUpdateIgnoredPerPolicy:
result = metrics::CheckResult::kUpdateAvailable;
reaction = metrics::CheckReaction::kIgnored;
break;
- case kErrorCodeOmahaUpdateDeferredPerPolicy:
+ case ErrorCode::kOmahaUpdateDeferredPerPolicy:
result = metrics::CheckResult::kUpdateAvailable;
reaction = metrics::CheckReaction::kDeferring;
break;
- case kErrorCodeOmahaUpdateDeferredForBackoff:
+ case ErrorCode::kOmahaUpdateDeferredForBackoff:
result = metrics::CheckResult::kUpdateAvailable;
reaction = metrics::CheckReaction::kBackingOff;
break;
diff --git a/omaha_request_action.h b/omaha_request_action.h
index c8505a9..c005cc4 100644
--- a/omaha_request_action.h
+++ b/omaha_request_action.h
@@ -54,11 +54,11 @@
OmahaEvent()
: type(kTypeUnknown),
result(kResultError),
- error_code(kErrorCodeError) {}
+ error_code(ErrorCode::kError) {}
explicit OmahaEvent(Type in_type)
: type(in_type),
result(kResultSuccess),
- error_code(kErrorCodeSuccess) {}
+ error_code(ErrorCode::kSuccess) {}
OmahaEvent(Type in_type, Result in_result, ErrorCode in_error_code)
: type(in_type),
result(in_result),
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index e371103..9cd3294 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -147,7 +147,7 @@
public:
OmahaRequestActionTestProcessorDelegate()
: loop_(NULL),
- expected_code_(kErrorCodeSuccess) {}
+ expected_code_(ErrorCode::kSuccess) {}
virtual ~OmahaRequestActionTestProcessorDelegate() {
}
virtual void ProcessingDone(const ActionProcessor* processor,
@@ -163,7 +163,7 @@
if (action->Type() == OmahaRequestAction::StaticType())
EXPECT_EQ(expected_code_, code);
else
- EXPECT_EQ(kErrorCodeSuccess, code);
+ EXPECT_EQ(ErrorCode::kSuccess, code);
}
GMainLoop *loop_;
ErrorCode expected_code_;
@@ -195,7 +195,7 @@
has_input_object_ = HasInputObject();
if (has_input_object_)
omaha_response_ = GetInputObject();
- processor_->ActionComplete(this, kErrorCodeSuccess);
+ processor_->ActionComplete(this, ErrorCode::kSuccess);
}
// Should never be called
void TerminateProcessing() {
@@ -338,7 +338,7 @@
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kNoUpdateAvailable,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -367,7 +367,7 @@
"20101020"), // deadline
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
@@ -406,7 +406,7 @@
""), // deadline
-1,
false, // ping_only
- kErrorCodeOmahaUpdateIgnoredPerPolicy,
+ ErrorCode::kOmahaUpdateIgnoredPerPolicy,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kIgnored,
metrics::DownloadErrorCode::kUnset,
@@ -447,7 +447,7 @@
""), // deadline
-1,
false, // ping_only
- kErrorCodeOmahaUpdateIgnoredPerPolicy,
+ ErrorCode::kOmahaUpdateIgnoredPerPolicy,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kIgnored,
metrics::DownloadErrorCode::kUnset,
@@ -482,7 +482,7 @@
""), // deadline
-1,
false, // ping_only
- kErrorCodeOmahaUpdateIgnoredPerPolicy,
+ ErrorCode::kOmahaUpdateIgnoredPerPolicy,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kIgnored,
metrics::DownloadErrorCode::kUnset,
@@ -504,7 +504,7 @@
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kNoUpdateAvailable,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -551,7 +551,7 @@
false), // disable_p2p_for sharing
-1,
false, // ping_only
- kErrorCodeOmahaUpdateDeferredPerPolicy,
+ ErrorCode::kOmahaUpdateDeferredPerPolicy,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kDeferring,
metrics::DownloadErrorCode::kUnset,
@@ -583,7 +583,7 @@
false), // disable_p2p_for sharing
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
@@ -633,7 +633,7 @@
false), // disable_p2p_for sharing
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
@@ -683,7 +683,7 @@
false), // disable_p2p_for sharing
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
@@ -734,7 +734,7 @@
false), // disable_p2p_for sharing
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
@@ -788,7 +788,7 @@
false), // disable_p2p_for sharing
-1,
false, // ping_only
- kErrorCodeOmahaUpdateDeferredPerPolicy,
+ ErrorCode::kOmahaUpdateDeferredPerPolicy,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kDeferring,
metrics::DownloadErrorCode::kUnset,
@@ -824,7 +824,7 @@
false), // disable_p2p_for sharing
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
@@ -876,7 +876,7 @@
false), // disable_p2p_for sharing
-1,
false, // ping_only
- kErrorCodeOmahaUpdateDeferredPerPolicy,
+ ErrorCode::kOmahaUpdateDeferredPerPolicy,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kDeferring,
metrics::DownloadErrorCode::kUnset,
@@ -914,7 +914,7 @@
false), // disable_p2p_for sharing
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
@@ -959,7 +959,7 @@
"invalid xml>",
-1,
false, // ping_only
- kErrorCodeOmahaRequestXMLParseError,
+ ErrorCode::kOmahaRequestXMLParseError,
metrics::CheckResult::kParsingError,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -979,7 +979,7 @@
"",
-1,
false, // ping_only
- kErrorCodeOmahaRequestEmptyResponseError,
+ ErrorCode::kOmahaRequestEmptyResponseError,
metrics::CheckResult::kParsingError,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1003,7 +1003,7 @@
"<updatecheck/></app></response>",
-1,
false, // ping_only
- kErrorCodeOmahaResponseInvalid,
+ ErrorCode::kOmahaResponseInvalid,
metrics::CheckResult::kParsingError,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1027,7 +1027,7 @@
"<updatecheck status=\"InvalidStatusTest\"/></app></response>",
-1,
false, // ping_only
- kErrorCodeOmahaResponseInvalid,
+ ErrorCode::kOmahaResponseInvalid,
metrics::CheckResult::kParsingError,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1051,7 +1051,7 @@
"</app></response>",
-1,
false, // ping_only
- kErrorCodeOmahaResponseInvalid,
+ ErrorCode::kOmahaResponseInvalid,
metrics::CheckResult::kParsingError,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1089,7 +1089,7 @@
input_response,
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
@@ -1187,7 +1187,7 @@
"invalid xml>",
-1,
false, // ping_only
- kErrorCodeOmahaRequestXMLParseError,
+ ErrorCode::kOmahaRequestXMLParseError,
metrics::CheckResult::kParsingError,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1225,7 +1225,7 @@
"<20110101"), // deadline
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
@@ -1258,7 +1258,7 @@
"deadline"),
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
@@ -1282,7 +1282,7 @@
"invalid xml>",
-1,
false, // ping_only
- kErrorCodeOmahaRequestXMLParseError,
+ ErrorCode::kOmahaRequestXMLParseError,
metrics::CheckResult::kParsingError,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1319,7 +1319,7 @@
"invalid xml>",
-1,
false, // ping_only
- kErrorCodeOmahaRequestXMLParseError,
+ ErrorCode::kOmahaRequestXMLParseError,
metrics::CheckResult::kParsingError,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1361,7 +1361,7 @@
TestEvent(kDefaultTestParams,
new OmahaEvent(OmahaEvent::kTypeDownloadComplete,
OmahaEvent::kResultError,
- kErrorCodeError),
+ ErrorCode::kError),
"invalid xml>",
&post_data);
// convert post_data to string
@@ -1371,7 +1371,7 @@
"errorcode=\"%d\"></event>\n",
OmahaEvent::kTypeDownloadComplete,
OmahaEvent::kResultError,
- kErrorCodeError);
+ static_cast<int>(ErrorCode::kError));
EXPECT_NE(post_str.find(expected_event), string::npos);
EXPECT_EQ(post_str.find("updatecheck"), string::npos);
}
@@ -1435,7 +1435,7 @@
"invalid xml>",
-1,
false, // ping_only
- kErrorCodeOmahaRequestXMLParseError,
+ ErrorCode::kOmahaRequestXMLParseError,
metrics::CheckResult::kParsingError,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1483,7 +1483,7 @@
"invalid xml>",
-1,
false, // ping_only
- kErrorCodeOmahaRequestXMLParseError,
+ ErrorCode::kOmahaRequestXMLParseError,
metrics::CheckResult::kParsingError,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1502,19 +1502,19 @@
OmahaEvent default_event;
EXPECT_EQ(OmahaEvent::kTypeUnknown, default_event.type);
EXPECT_EQ(OmahaEvent::kResultError, default_event.result);
- EXPECT_EQ(kErrorCodeError, default_event.error_code);
+ EXPECT_EQ(ErrorCode::kError, 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(kErrorCodeSuccess, success_event.error_code);
+ EXPECT_EQ(ErrorCode::kSuccess, success_event.error_code);
OmahaEvent error_event(OmahaEvent::kTypeUpdateDownloadFinished,
OmahaEvent::kResultError,
- kErrorCodeError);
+ ErrorCode::kError);
EXPECT_EQ(OmahaEvent::kTypeUpdateDownloadFinished, error_event.type);
EXPECT_EQ(OmahaEvent::kResultError, error_event.result);
- EXPECT_EQ(kErrorCodeError, error_event.error_code);
+ EXPECT_EQ(ErrorCode::kError, error_event.error_code);
}
TEST(OmahaRequestActionTest, PingTest) {
@@ -1544,7 +1544,7 @@
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
ping_only,
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kUnset,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1587,7 +1587,7 @@
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kNoUpdateAvailable,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1622,7 +1622,7 @@
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kNoUpdateAvailable,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1658,7 +1658,7 @@
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kNoUpdateAvailable,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1688,7 +1688,7 @@
GetNoUpdateResponse(OmahaRequestParams::kAppId),
-1,
true, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kUnset,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1727,7 +1727,7 @@
"<updatecheck status=\"noupdate\"/></app></response>",
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kNoUpdateAvailable,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1767,7 +1767,7 @@
"<updatecheck status=\"noupdate\"/></app></response>",
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kNoUpdateAvailable,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1793,7 +1793,7 @@
"<updatecheck status=\"noupdate\"/></app></response>",
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kNoUpdateAvailable,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1819,7 +1819,7 @@
"<updatecheck status=\"noupdate\"/></app></response>",
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kNoUpdateAvailable,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1837,7 +1837,7 @@
"invalid xml>",
-1,
false, // ping_only
- kErrorCodeOmahaRequestXMLParseError,
+ ErrorCode::kOmahaRequestXMLParseError,
metrics::CheckResult::kParsingError,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -1851,6 +1851,8 @@
TEST(OmahaRequestActionTest, NetworkFailureTest) {
OmahaResponse response;
+ const int http_error_code =
+ static_cast<int>(ErrorCode::kOmahaRequestHTTPResponseBase) + 501;
ASSERT_FALSE(
TestUpdateCheck(NULL, // prefs
NULL, // payload_state
@@ -1860,8 +1862,7 @@
"",
501,
false, // ping_only
- static_cast<ErrorCode>(
- kErrorCodeOmahaRequestHTTPResponseBase + 501),
+ static_cast<ErrorCode>(http_error_code),
metrics::CheckResult::kDownloadError,
metrics::CheckReaction::kUnset,
static_cast<metrics::DownloadErrorCode>(501),
@@ -1872,6 +1873,8 @@
TEST(OmahaRequestActionTest, NetworkFailureBadHTTPCodeTest) {
OmahaResponse response;
+ const int http_error_code =
+ static_cast<int>(ErrorCode::kOmahaRequestHTTPResponseBase) + 999;
ASSERT_FALSE(
TestUpdateCheck(NULL, // prefs
NULL, // payload_state
@@ -1881,8 +1884,7 @@
"",
1500,
false, // ping_only
- static_cast<ErrorCode>(
- kErrorCodeOmahaRequestHTTPResponseBase + 999),
+ static_cast<ErrorCode>(http_error_code),
metrics::CheckResult::kDownloadError,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kHttpStatusOther,
@@ -1929,7 +1931,7 @@
false), // disable_p2p_for sharing
-1,
false, // ping_only
- kErrorCodeOmahaUpdateDeferredPerPolicy,
+ ErrorCode::kOmahaUpdateDeferredPerPolicy,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kDeferring,
metrics::DownloadErrorCode::kUnset,
@@ -1965,7 +1967,7 @@
false), // disable_p2p_for sharing
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
@@ -2017,7 +2019,7 @@
false), // disable_p2p_for sharing
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
@@ -2068,7 +2070,7 @@
"invalid xml>",
-1,
false, // ping_only
- kErrorCodeOmahaRequestXMLParseError,
+ ErrorCode::kOmahaRequestXMLParseError,
metrics::CheckResult::kParsingError,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -2119,7 +2121,7 @@
"invalid xml>",
-1,
false, // ping_only
- kErrorCodeOmahaRequestXMLParseError,
+ ErrorCode::kOmahaRequestXMLParseError,
metrics::CheckResult::kParsingError,
metrics::CheckReaction::kUnset,
metrics::DownloadErrorCode::kUnset,
@@ -2183,7 +2185,7 @@
omaha_disable_p2p_for_sharing),
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
@@ -2308,7 +2310,7 @@
false), // disable_p2p_for sharing
-1,
false, // ping_only
- kErrorCodeSuccess,
+ ErrorCode::kSuccess,
metrics::CheckResult::kUpdateAvailable,
metrics::CheckReaction::kUpdating,
metrics::DownloadErrorCode::kUnset,
diff --git a/omaha_response_handler_action.cc b/omaha_response_handler_action.cc
index 7a30403..5b4410c 100644
--- a/omaha_response_handler_action.cc
+++ b/omaha_response_handler_action.cc
@@ -57,7 +57,7 @@
// This shouldn't happen as we should always supply the HTTPS backup URL.
// Handling this anyway, just in case.
LOG(ERROR) << "There are no suitable URLs in the response to use.";
- completer.set_code(kErrorCodeOmahaResponseInvalid);
+ completer.set_code(ErrorCode::kOmahaResponseInvalid);
return;
}
@@ -126,7 +126,7 @@
response.deadline.size());
chmod(deadline_file_.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
- completer.set_code(kErrorCodeSuccess);
+ completer.set_code(ErrorCode::kSuccess);
}
bool OmahaResponseHandlerAction::AreHashChecksMandatory(
diff --git a/omaha_response_handler_action_unittest.cc b/omaha_response_handler_action_unittest.cc
index 82f7369..4af21b4 100644
--- a/omaha_response_handler_action_unittest.cc
+++ b/omaha_response_handler_action_unittest.cc
@@ -37,7 +37,7 @@
: public ActionProcessorDelegate {
public:
OmahaResponseHandlerActionProcessorDelegate()
- : code_(kErrorCodeError),
+ : code_(ErrorCode::kError),
code_set_(false) {}
void ActionCompleted(ActionProcessor* processor,
AbstractAction* action,
@@ -103,7 +103,7 @@
if (out)
*out = collector_action.object();
EXPECT_TRUE(delegate.code_set_);
- return delegate.code_ == kErrorCodeSuccess;
+ return delegate.code_ == ErrorCode::kSuccess;
}
bool OmahaResponseHandlerActionTest::DoTest(const OmahaResponse& in,
diff --git a/payload_signer.cc b/payload_signer.cc
index 1084109..a3ac5b9 100644
--- a/payload_signer.cc
+++ b/payload_signer.cc
@@ -187,7 +187,7 @@
// Loads the payload and parses the manifest.
TEST_AND_RETURN_FALSE(utils::ReadFile(payload_path, &payload));
LOG(INFO) << "Payload size: " << payload.size();
- ErrorCode error = kErrorCodeSuccess;
+ ErrorCode error = ErrorCode::kSuccess;
InstallPlan install_plan;
DeltaPerformer delta_performer(NULL, NULL, &install_plan);
TEST_AND_RETURN_FALSE(
diff --git a/payload_state.cc b/payload_state.cc
index 975ba15..3f9aa19 100644
--- a/payload_state.cc
+++ b/payload_state.cc
@@ -211,7 +211,7 @@
switch (attempt_type_) {
case AttemptType::kUpdate:
- CollectAndReportAttemptMetrics(kErrorCodeSuccess);
+ CollectAndReportAttemptMetrics(ErrorCode::kSuccess);
CollectAndReportSuccessfulUpdateMetrics();
ClearPersistedAttemptMetrics();
break;
@@ -259,27 +259,27 @@
// 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 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:
- case kErrorCodePayloadMismatchedType:
- case kErrorCodeUnsupportedMajorPayloadVersion:
- case kErrorCodeUnsupportedMinorPayloadVersion:
+ case ErrorCode::kPayloadHashMismatchError:
+ case ErrorCode::kPayloadSizeMismatchError:
+ case ErrorCode::kDownloadPayloadVerificationError:
+ case ErrorCode::kDownloadPayloadPubKeyVerificationError:
+ case ErrorCode::kSignedDeltaPayloadExpectedError:
+ case ErrorCode::kDownloadInvalidMetadataMagicString:
+ case ErrorCode::kDownloadSignatureMissingInManifest:
+ case ErrorCode::kDownloadManifestParseError:
+ case ErrorCode::kDownloadMetadataSignatureError:
+ case ErrorCode::kDownloadMetadataSignatureVerificationError:
+ case ErrorCode::kDownloadMetadataSignatureMismatch:
+ case ErrorCode::kDownloadOperationHashVerificationError:
+ case ErrorCode::kDownloadOperationExecutionError:
+ case ErrorCode::kDownloadOperationHashMismatch:
+ case ErrorCode::kDownloadInvalidMetadataSize:
+ case ErrorCode::kDownloadInvalidMetadataSignature:
+ case ErrorCode::kDownloadOperationHashMissingError:
+ case ErrorCode::kDownloadMetadataSignatureMissingError:
+ case ErrorCode::kPayloadMismatchedType:
+ case ErrorCode::kUnsupportedMajorPayloadVersion:
+ case ErrorCode::kUnsupportedMinorPayloadVersion:
IncrementUrlIndex();
break;
@@ -291,11 +291,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 kErrorCodeError:
- case kErrorCodeDownloadTransferError:
- case kErrorCodeDownloadWriteError:
- case kErrorCodeDownloadStateInitializationError:
- case kErrorCodeOmahaErrorInHTTPResponse: // Aggregate code for HTTP errors.
+ case ErrorCode::kError:
+ case ErrorCode::kDownloadTransferError:
+ case ErrorCode::kDownloadWriteError:
+ case ErrorCode::kDownloadStateInitializationError:
+ case ErrorCode::kOmahaErrorInHTTPResponse: // Aggregate for HTTP errors.
IncrementFailureCount();
break;
@@ -308,36 +308,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 kErrorCodeOmahaRequestError:
- case kErrorCodeOmahaResponseHandlerError:
- case kErrorCodePostinstallRunnerError:
- case kErrorCodeFilesystemCopierError:
- case kErrorCodeInstallDeviceOpenError:
- case kErrorCodeKernelDeviceOpenError:
- case kErrorCodeDownloadNewPartitionInfoError:
- case kErrorCodeNewRootfsVerificationError:
- case kErrorCodeNewKernelVerificationError:
- case kErrorCodePostinstallBootedFromFirmwareB:
- case kErrorCodePostinstallFirmwareRONotUpdatable:
- case kErrorCodeOmahaRequestEmptyResponseError:
- case kErrorCodeOmahaRequestXMLParseError:
- case kErrorCodeOmahaResponseInvalid:
- case kErrorCodeOmahaUpdateIgnoredPerPolicy:
- case kErrorCodeOmahaUpdateDeferredPerPolicy:
- case kErrorCodeOmahaUpdateDeferredForBackoff:
- case kErrorCodePostinstallPowerwashError:
- case kErrorCodeUpdateCanceledByChannelChange:
+ case ErrorCode::kOmahaRequestError:
+ case ErrorCode::kOmahaResponseHandlerError:
+ case ErrorCode::kPostinstallRunnerError:
+ case ErrorCode::kFilesystemCopierError:
+ case ErrorCode::kInstallDeviceOpenError:
+ case ErrorCode::kKernelDeviceOpenError:
+ case ErrorCode::kDownloadNewPartitionInfoError:
+ case ErrorCode::kNewRootfsVerificationError:
+ case ErrorCode::kNewKernelVerificationError:
+ case ErrorCode::kPostinstallBootedFromFirmwareB:
+ case ErrorCode::kPostinstallFirmwareRONotUpdatable:
+ case ErrorCode::kOmahaRequestEmptyResponseError:
+ case ErrorCode::kOmahaRequestXMLParseError:
+ case ErrorCode::kOmahaResponseInvalid:
+ case ErrorCode::kOmahaUpdateIgnoredPerPolicy:
+ case ErrorCode::kOmahaUpdateDeferredPerPolicy:
+ case ErrorCode::kOmahaUpdateDeferredForBackoff:
+ case ErrorCode::kPostinstallPowerwashError:
+ case ErrorCode::kUpdateCanceledByChannelChange:
LOG(INFO) << "Not incrementing URL index or failure count for this error";
break;
- case kErrorCodeSuccess: // success code
- 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
+ case ErrorCode::kSuccess: // success code
+ case ErrorCode::kUmaReportedMax: // not an error code
+ case ErrorCode::kOmahaRequestHTTPResponseBase: // aggregated already
+ case ErrorCode::kDevModeFlag: // not an error code
+ case ErrorCode::kResumedFlag: // not an error code
+ case ErrorCode::kTestImageFlag: // not an error code
+ case ErrorCode::kTestOmahaUrlFlag: // not an error code
+ case ErrorCode::kSpecialFlags: // 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.
@@ -591,7 +591,7 @@
metrics::DownloadErrorCode payload_download_error_code =
metrics::DownloadErrorCode::kUnset;
- ErrorCode internal_error_code = kErrorCodeSuccess;
+ ErrorCode internal_error_code = ErrorCode::kSuccess;
metrics::AttemptResult attempt_result = utils::GetAttemptResult(code);
// Add additional detail to AttemptResult
diff --git a/payload_state_unittest.cc b/payload_state_unittest.cc
index 3071a6b..aa04cff 100644
--- a/payload_state_unittest.cc
+++ b/payload_state_unittest.cc
@@ -91,12 +91,12 @@
class PayloadStateTest : public ::testing::Test { };
TEST(PayloadStateTest, DidYouAddANewErrorCode) {
- if (kErrorCodeUmaReportedMax != 46) {
+ if (static_cast<int>(ErrorCode::kUmaReportedMax) != 46) {
LOG(ERROR) << "The following failure is intentional. If you added a new "
<< "ErrorCode enum value, make sure to add it to the "
<< "PayloadState::UpdateFailed method and then update this test "
- << "to the new value of kErrorCodeUmaReportedMax, which is "
- << kErrorCodeUmaReportedMax;
+ << "to the new value of ErrorCode::kUmaReportedMax, which is "
+ << ErrorCode::kUmaReportedMax;
EXPECT_FALSE("Please see the log line above");
}
}
@@ -285,7 +285,7 @@
EXPECT_EQ("http://test", payload_state.GetCurrentUrl());
// Verify that on the first error, the URL index advances to 1.
- ErrorCode error = kErrorCodeDownloadMetadataSignatureMismatch;
+ ErrorCode error = ErrorCode::kDownloadMetadataSignatureMismatch;
payload_state.UpdateFailed(error);
EXPECT_EQ("https://test", payload_state.GetCurrentUrl());
@@ -322,7 +322,7 @@
EXPECT_EQ(1, payload_state.GetNumResponsesSeen());
// Advance the URL index to 1 by faking an error.
- ErrorCode error = kErrorCodeDownloadMetadataSignatureMismatch;
+ ErrorCode error = ErrorCode::kDownloadMetadataSignatureMismatch;
payload_state.UpdateFailed(error);
EXPECT_EQ("https://test", payload_state.GetCurrentUrl());
EXPECT_EQ(1, payload_state.GetUrlSwitchCount());
@@ -418,7 +418,7 @@
EXPECT_EQ(1, payload_state.GetNumResponsesSeen());
// This should advance the URL index.
- payload_state.UpdateFailed(kErrorCodeDownloadMetadataSignatureMismatch);
+ payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch);
EXPECT_EQ(0, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(0, payload_state.GetFullPayloadAttemptNumber());
EXPECT_EQ("https://test", payload_state.GetCurrentUrl());
@@ -426,7 +426,7 @@
EXPECT_EQ(1, payload_state.GetUrlSwitchCount());
// This should advance the failure count only.
- payload_state.UpdateFailed(kErrorCodeDownloadTransferError);
+ payload_state.UpdateFailed(ErrorCode::kDownloadTransferError);
EXPECT_EQ(0, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(0, payload_state.GetFullPayloadAttemptNumber());
EXPECT_EQ("https://test", payload_state.GetCurrentUrl());
@@ -434,7 +434,7 @@
EXPECT_EQ(1, payload_state.GetUrlSwitchCount());
// This should advance the failure count only.
- payload_state.UpdateFailed(kErrorCodeDownloadTransferError);
+ payload_state.UpdateFailed(ErrorCode::kDownloadTransferError);
EXPECT_EQ(0, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(0, payload_state.GetFullPayloadAttemptNumber());
EXPECT_EQ("https://test", payload_state.GetCurrentUrl());
@@ -445,7 +445,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(kErrorCodeDownloadTransferError);
+ payload_state.UpdateFailed(ErrorCode::kDownloadTransferError);
EXPECT_EQ(1, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(1, payload_state.GetFullPayloadAttemptNumber());
EXPECT_EQ("http://test", payload_state.GetCurrentUrl());
@@ -454,7 +454,7 @@
EXPECT_TRUE(payload_state.ShouldBackoffDownload());
// This should advance the URL index.
- payload_state.UpdateFailed(kErrorCodePayloadHashMismatchError);
+ payload_state.UpdateFailed(ErrorCode::kPayloadHashMismatchError);
EXPECT_EQ(1, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(1, payload_state.GetFullPayloadAttemptNumber());
EXPECT_EQ("https://test", payload_state.GetCurrentUrl());
@@ -464,7 +464,7 @@
// This should advance the URL index and payload attempt number due to
// wrap-around of URL index.
- payload_state.UpdateFailed(kErrorCodeDownloadMetadataSignatureMissingError);
+ payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMissingError);
EXPECT_EQ(2, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(2, payload_state.GetFullPayloadAttemptNumber());
EXPECT_EQ("http://test", payload_state.GetCurrentUrl());
@@ -474,7 +474,7 @@
// This HTTP error code should only increase the failure count.
payload_state.UpdateFailed(static_cast<ErrorCode>(
- kErrorCodeOmahaRequestHTTPResponseBase + 404));
+ static_cast<int>(ErrorCode::kOmahaRequestHTTPResponseBase) + 404));
EXPECT_EQ(2, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(2, payload_state.GetFullPayloadAttemptNumber());
EXPECT_EQ("http://test", payload_state.GetCurrentUrl());
@@ -609,8 +609,8 @@
// Generate enough events to advance URL index, failure count and
// payload attempt number all to 1.
payload_state.DownloadComplete();
- payload_state.UpdateFailed(kErrorCodeDownloadMetadataSignatureMismatch);
- payload_state.UpdateFailed(kErrorCodeDownloadTransferError);
+ payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch);
+ payload_state.UpdateFailed(ErrorCode::kDownloadTransferError);
EXPECT_EQ(1, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(1, payload_state.GetFullPayloadAttemptNumber());
EXPECT_EQ("https://test", payload_state.GetCurrentUrl());
@@ -666,8 +666,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
// an interactive check.
- payload_state.UpdateFailed(kErrorCodeDownloadMetadataSignatureMismatch);
- payload_state.UpdateFailed(kErrorCodeDownloadMetadataSignatureMismatch);
+ payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch);
+ payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch);
EXPECT_EQ("http://test", payload_state.GetCurrentUrl());
EXPECT_EQ(1, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(1, payload_state.GetFullPayloadAttemptNumber());
@@ -689,8 +689,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
// an interactive check.
- payload_state.UpdateFailed(kErrorCodeDownloadMetadataSignatureMismatch);
- payload_state.UpdateFailed(kErrorCodeDownloadMetadataSignatureMismatch);
+ payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch);
+ payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch);
EXPECT_EQ("http://test", payload_state.GetCurrentUrl());
EXPECT_EQ(1, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(1, payload_state.GetFullPayloadAttemptNumber());
@@ -724,8 +724,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(kErrorCodeDownloadMetadataSignatureMismatch);
- payload_state.UpdateFailed(kErrorCodeDownloadMetadataSignatureMismatch);
+ payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch);
+ payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch);
EXPECT_EQ("http://test", payload_state.GetCurrentUrl());
EXPECT_EQ(2, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(0, payload_state.GetFullPayloadAttemptNumber());
@@ -790,8 +790,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(kErrorCodeDownloadMetadataSignatureMismatch);
- payload_state.UpdateFailed(kErrorCodeDownloadMetadataSignatureMismatch);
+ payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch);
+ payload_state.UpdateFailed(ErrorCode::kDownloadMetadataSignatureMismatch);
EXPECT_EQ(2, payload_state.GetPayloadAttemptNumber());
EXPECT_EQ(2, payload_state.GetFullPayloadAttemptNumber());
EXPECT_FALSE(payload_state.ShouldBackoffDownload());
@@ -841,7 +841,7 @@
payload_state.GetTotalBytesDownloaded(kDownloadSourceHttpsServer));
// Simulate an error that'll cause the url index to point to https.
- ErrorCode error = kErrorCodeDownloadMetadataSignatureMismatch;
+ ErrorCode error = ErrorCode::kDownloadMetadataSignatureMismatch;
payload_state.UpdateFailed(error);
// Test that no new progress is made on HTTP and new progress is on HTTPS.
@@ -1344,7 +1344,7 @@
EXPECT_EQ("https://test", payload_state.GetCurrentUrl());
// Advance the URL index to 1 by faking an error.
- ErrorCode error = kErrorCodeDownloadMetadataSignatureMismatch;
+ ErrorCode error = ErrorCode::kDownloadMetadataSignatureMismatch;
payload_state.UpdateFailed(error);
// Check that we still skip the HTTP URL and use only the HTTPS url.
diff --git a/postinstall_runner_action.cc b/postinstall_runner_action.cc
index 1b3af2f..cc8968b 100644
--- a/postinstall_runner_action.cc
+++ b/postinstall_runner_action.cc
@@ -67,7 +67,7 @@
if (utils::CreatePowerwashMarkerFile(powerwash_marker_file_)) {
powerwash_marker_created_ = true;
} else {
- completer.set_code(kErrorCodePostinstallPowerwashError);
+ completer.set_code(ErrorCode::kPostinstallPowerwashError);
return;
}
}
@@ -111,14 +111,14 @@
// 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(kErrorCodePostinstallBootedFromFirmwareB);
+ completer.set_code(ErrorCode::kPostinstallBootedFromFirmwareB);
}
if (return_code == 4) {
// 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(kErrorCodePostinstallFirmwareRONotUpdatable);
+ completer.set_code(ErrorCode::kPostinstallFirmwareRONotUpdatable);
}
return;
@@ -129,7 +129,7 @@
SetOutputObject(install_plan_);
}
- completer.set_code(kErrorCodeSuccess);
+ completer.set_code(ErrorCode::kSuccess);
}
void PostinstallRunnerAction::StaticCompletePostinstall(int return_code,
diff --git a/postinstall_runner_action_unittest.cc b/postinstall_runner_action_unittest.cc
index be77e08..acceb2b 100644
--- a/postinstall_runner_action_unittest.cc
+++ b/postinstall_runner_action_unittest.cc
@@ -47,7 +47,7 @@
public:
PostinstActionProcessorDelegate()
: loop_(NULL),
- code_(kErrorCodeError),
+ code_(ErrorCode::kError),
code_set_(false) {}
void ProcessingDone(const ActionProcessor* processor,
ErrorCode code) {
@@ -192,7 +192,7 @@
ASSERT_FALSE(processor.IsRunning());
EXPECT_TRUE(delegate.code_set_);
- EXPECT_EQ(should_succeed, delegate.code_ == kErrorCodeSuccess);
+ EXPECT_EQ(should_succeed, delegate.code_ == ErrorCode::kSuccess);
EXPECT_EQ(should_succeed, !collector_action.object().install_path.empty());
if (should_succeed)
EXPECT_TRUE(install_plan == collector_action.object());
@@ -208,7 +208,7 @@
}
if (err_code == 2)
- EXPECT_EQ(kErrorCodePostinstallBootedFromFirmwareB, delegate.code_);
+ EXPECT_EQ(ErrorCode::kPostinstallBootedFromFirmwareB, 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 43ff339..120f080 100644
--- a/test_utils.h
+++ b/test_utils.h
@@ -216,7 +216,7 @@
if (this->HasOutputPipe()) {
this->SetOutputObject(out_obj_);
}
- this->processor_->ActionComplete(this, kErrorCodeSuccess);
+ this->processor_->ActionComplete(this, ErrorCode::kSuccess);
}
static std::string StaticType() { return "ObjectFeederAction"; }
std::string Type() const { return StaticType(); }
@@ -250,7 +250,7 @@
if (this->HasInputObject()) {
object_ = this->GetInputObject();
}
- this->processor_->ActionComplete(this, kErrorCodeSuccess);
+ this->processor_->ActionComplete(this, ErrorCode::kSuccess);
}
static std::string StaticType() { return "ObjectCollectorAction"; }
std::string Type() const { return StaticType(); }
diff --git a/update_attempter.cc b/update_attempter.cc
index dd52d0d..46a798b 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -89,24 +89,24 @@
}
}
-// 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|
+// Turns a generic ErrorCode::kError to a generic error code specific
+// to |action| (e.g., ErrorCode::kFilesystemCopierError). If |code| is
+// not ErrorCode::kError, or the action is not matched, returns |code|
// unchanged.
ErrorCode GetErrorCodeForAction(AbstractAction* action,
ErrorCode code) {
- if (code != kErrorCodeError)
+ if (code != ErrorCode::kError)
return code;
const string type = action->Type();
if (type == OmahaRequestAction::StaticType())
- return kErrorCodeOmahaRequestError;
+ return ErrorCode::kOmahaRequestError;
if (type == OmahaResponseHandlerAction::StaticType())
- return kErrorCodeOmahaResponseHandlerError;
+ return ErrorCode::kOmahaResponseHandlerError;
if (type == FilesystemCopierAction::StaticType())
- return kErrorCodeFilesystemCopierError;
+ return ErrorCode::kFilesystemCopierError;
if (type == PostinstallRunnerAction::StaticType())
- return kErrorCodePostinstallRunnerError;
+ return ErrorCode::kPostinstallRunnerError;
return code;
}
@@ -850,7 +850,7 @@
"so requesting reboot from user.";
}
- if (code == kErrorCodeSuccess) {
+ if (code == ErrorCode::kSuccess) {
WriteUpdateCompletedMarker();
prefs_->SetInt64(kPrefsDeltaUpdateFailures, 0);
prefs_->SetString(kPrefsPreviousVersion,
@@ -957,12 +957,12 @@
}
}
}
- if (code != kErrorCodeSuccess) {
+ if (code != ErrorCode::kSuccess) {
// 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 != kErrorCodeDownloadTransferError) {
+ code != ErrorCode::kDownloadTransferError) {
MarkDeltaUpdateFailure();
}
// On failure, schedule an error event to be sent to Omaha.
@@ -1128,17 +1128,17 @@
uint32_t flags = 0;
if (!system_state_->hardware()->IsNormalBootMode())
- flags |= kErrorCodeDevModeFlag;
+ flags |= static_cast<uint32_t>(ErrorCode::kDevModeFlag);
if (response_handler_action_.get() &&
response_handler_action_->install_plan().is_resume)
- flags |= kErrorCodeResumedFlag;
+ flags |= static_cast<uint32_t>(ErrorCode::kResumedFlag);
if (!system_state_->hardware()->IsOfficialBuild())
- flags |= kErrorCodeTestImageFlag;
+ flags |= static_cast<uint32_t>(ErrorCode::kTestImageFlag);
if (omaha_request_params_->update_url() != kProductionOmahaUrl)
- flags |= kErrorCodeTestOmahaUrlFlag;
+ flags |= static_cast<uint32_t>(ErrorCode::kTestOmahaUrlFlag);
return flags;
}
@@ -1152,7 +1152,7 @@
<< params->target_channel()
<< " is different from the download channel: "
<< params->download_channel();
- *cancel_reason = kErrorCodeUpdateCanceledByChannelChange;
+ *cancel_reason = ErrorCode::kUpdateCanceledByChannelChange;
return true;
}
@@ -1180,7 +1180,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 == kErrorCodeError) ||
+ code == ErrorCode::kError) ||
status_ == UPDATE_STATUS_REPORTING_ERROR_EVENT) {
return;
}
@@ -1192,9 +1192,9 @@
// the switch cases below.
OmahaEvent::Result event_result;
switch (code) {
- case kErrorCodeOmahaUpdateIgnoredPerPolicy:
- case kErrorCodeOmahaUpdateDeferredPerPolicy:
- case kErrorCodeOmahaUpdateDeferredForBackoff:
+ case ErrorCode::kOmahaUpdateIgnoredPerPolicy:
+ case ErrorCode::kOmahaUpdateDeferredPerPolicy:
+ case ErrorCode::kOmahaUpdateDeferredForBackoff:
event_result = OmahaEvent::kResultUpdateDeferred;
break;
default:
@@ -1203,10 +1203,11 @@
}
code = GetErrorCodeForAction(action, code);
- fake_update_success_ = code == kErrorCodePostinstallBootedFromFirmwareB;
+ fake_update_success_ = code == ErrorCode::kPostinstallBootedFromFirmwareB;
// Compute the final error code with all the bit flags to be sent to Omaha.
- code = static_cast<ErrorCode>(code | GetErrorCodeFlags());
+ code = static_cast<ErrorCode>(
+ static_cast<uint32_t>(code) | GetErrorCodeFlags());
error_event_.reset(new OmahaEvent(OmahaEvent::kTypeUpdateComplete,
event_result,
code));
diff --git a/update_attempter_unittest.cc b/update_attempter_unittest.cc
index e5f66aa..aa0af3e 100644
--- a/update_attempter_unittest.cc
+++ b/update_attempter_unittest.cc
@@ -166,7 +166,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, kErrorCodeSuccess);
+ attempter_.ActionCompleted(NULL, &action, ErrorCode::kSuccess);
EXPECT_EQ(503, attempter_.http_response_code());
EXPECT_EQ(UPDATE_STATUS_FINALIZING, attempter_.status());
ASSERT_TRUE(attempter_.error_event_.get() == NULL);
@@ -178,7 +178,7 @@
attempter_.status_ = UPDATE_STATUS_DOWNLOADING;
EXPECT_CALL(*prefs_, GetInt64(kPrefsDeltaUpdateFailures, _))
.WillOnce(Return(false));
- attempter_.ActionCompleted(NULL, &action, kErrorCodeError);
+ attempter_.ActionCompleted(NULL, &action, ErrorCode::kError);
ASSERT_TRUE(attempter_.error_event_.get() != NULL);
}
@@ -195,7 +195,7 @@
UpdateCheckScheduler scheduler(&attempter_, &fake_system_state_);
attempter_.set_update_check_scheduler(&scheduler);
EXPECT_CALL(*prefs_, GetInt64(kPrefsDeltaUpdateFailures, _)).Times(0);
- attempter_.ActionCompleted(NULL, &action, kErrorCodeSuccess);
+ attempter_.ActionCompleted(NULL, &action, ErrorCode::kSuccess);
EXPECT_EQ(500, attempter_.http_response_code());
EXPECT_EQ(UPDATE_STATUS_IDLE, attempter_.status());
EXPECT_EQ(234, scheduler.poll_interval());
@@ -218,30 +218,31 @@
TEST_F(UpdateAttempterTest, GetErrorCodeForActionTest) {
extern ErrorCode GetErrorCodeForAction(AbstractAction* action,
ErrorCode code);
- EXPECT_EQ(kErrorCodeSuccess,
- GetErrorCodeForAction(NULL, kErrorCodeSuccess));
+ EXPECT_EQ(ErrorCode::kSuccess,
+ GetErrorCodeForAction(NULL, ErrorCode::kSuccess));
FakeSystemState fake_system_state;
OmahaRequestAction omaha_request_action(&fake_system_state, NULL,
NULL, false);
- EXPECT_EQ(kErrorCodeOmahaRequestError,
- GetErrorCodeForAction(&omaha_request_action, kErrorCodeError));
+ EXPECT_EQ(ErrorCode::kOmahaRequestError,
+ GetErrorCodeForAction(&omaha_request_action, ErrorCode::kError));
OmahaResponseHandlerAction omaha_response_handler_action(&fake_system_state_);
- EXPECT_EQ(kErrorCodeOmahaResponseHandlerError,
+ EXPECT_EQ(ErrorCode::kOmahaResponseHandlerError,
GetErrorCodeForAction(&omaha_response_handler_action,
- kErrorCodeError));
+ ErrorCode::kError));
FilesystemCopierAction filesystem_copier_action(
&fake_system_state_, false, false);
- EXPECT_EQ(kErrorCodeFilesystemCopierError,
- GetErrorCodeForAction(&filesystem_copier_action, kErrorCodeError));
+ EXPECT_EQ(ErrorCode::kFilesystemCopierError,
+ GetErrorCodeForAction(&filesystem_copier_action,
+ ErrorCode::kError));
PostinstallRunnerAction postinstall_runner_action;
- EXPECT_EQ(kErrorCodePostinstallRunnerError,
+ EXPECT_EQ(ErrorCode::kPostinstallRunnerError,
GetErrorCodeForAction(&postinstall_runner_action,
- kErrorCodeError));
+ ErrorCode::kError));
ActionMock action_mock;
EXPECT_CALL(action_mock, Type()).Times(1).WillOnce(Return("ActionMock"));
- EXPECT_EQ(kErrorCodeError,
- GetErrorCodeForAction(&action_mock, kErrorCodeError));
+ EXPECT_EQ(ErrorCode::kError,
+ GetErrorCodeForAction(&action_mock, ErrorCode::kError));
}
TEST_F(UpdateAttempterTest, DisableDeltaUpdateIfNeededTest) {
@@ -308,7 +309,7 @@
OmahaRequestAction::StaticType())))
.Times(1);
EXPECT_CALL(*processor_, StartProcessing()).Times(1);
- ErrorCode err = kErrorCodeError;
+ ErrorCode err = ErrorCode::kError;
EXPECT_CALL(*fake_system_state_.mock_payload_state(), UpdateFailed(err));
attempter_.error_event_.reset(new OmahaEvent(OmahaEvent::kTypeUpdateComplete,
OmahaEvent::kResultError,
@@ -593,13 +594,15 @@
TEST_F(UpdateAttempterTest, CreatePendingErrorEventTest) {
ActionMock action;
- const ErrorCode kCode = kErrorCodeDownloadTransferError;
+ const ErrorCode kCode = ErrorCode::kDownloadTransferError;
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 | kErrorCodeTestOmahaUrlFlag,
- attempter_.error_event_->error_code);
+ EXPECT_EQ(
+ static_cast<ErrorCode>(static_cast<int>(kCode) |
+ static_cast<int>(ErrorCode::kTestOmahaUrlFlag)),
+ attempter_.error_event_->error_code);
}
TEST_F(UpdateAttempterTest, CreatePendingErrorEventResumedTest) {
@@ -608,13 +611,17 @@
response_action->install_plan_.is_resume = true;
attempter_.response_handler_action_.reset(response_action);
ActionMock action;
- const ErrorCode kCode = kErrorCodeInstallDeviceOpenError;
+ const ErrorCode kCode = ErrorCode::kInstallDeviceOpenError;
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 | kErrorCodeResumedFlag | kErrorCodeTestOmahaUrlFlag,
- attempter_.error_event_->error_code);
+ EXPECT_EQ(
+ static_cast<ErrorCode>(
+ static_cast<int>(kCode) |
+ static_cast<int>(ErrorCode::kResumedFlag) |
+ static_cast<int>(ErrorCode::kTestOmahaUrlFlag)),
+ attempter_.error_event_->error_code);
}
TEST_F(UpdateAttempterTest, ReadChannelFromPolicy) {
diff --git a/utils.cc b/utils.cc
index 2664f9c..9e4a4d8 100644
--- a/utils.cc
+++ b/utils.cc
@@ -936,105 +936,107 @@
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 kErrorCodeUmaReportedMax.
- ErrorCode base_code = static_cast<ErrorCode>(code & ~kErrorCodeSpecialFlags);
+ // with values less than ErrorCode::kUmaReportedMax.
+ ErrorCode base_code = static_cast<ErrorCode>(
+ static_cast<int>(code) & ~static_cast<int>(ErrorCode::kSpecialFlags));
// 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 >= kErrorCodeOmahaRequestHTTPResponseBase) {
+ if (base_code >= ErrorCode::kOmahaRequestHTTPResponseBase) {
// 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 kErrorCodeOmahaErrorInHTTPResponse";
- base_code = kErrorCodeOmahaErrorInHTTPResponse;
+ << " to ErrorCode::kOmahaErrorInHTTPResponse";
+ base_code = ErrorCode::kOmahaErrorInHTTPResponse;
}
return base_code;
}
metrics::AttemptResult GetAttemptResult(ErrorCode code) {
- ErrorCode base_code = static_cast<ErrorCode>(code & ~kErrorCodeSpecialFlags);
+ ErrorCode base_code = static_cast<ErrorCode>(
+ static_cast<int>(code) & ~static_cast<int>(ErrorCode::kSpecialFlags));
switch (base_code) {
- case kErrorCodeSuccess:
+ case ErrorCode::kSuccess:
return metrics::AttemptResult::kUpdateSucceeded;
- case kErrorCodeDownloadTransferError:
+ case ErrorCode::kDownloadTransferError:
return metrics::AttemptResult::kPayloadDownloadError;
- case kErrorCodeDownloadInvalidMetadataSize:
- case kErrorCodeDownloadInvalidMetadataMagicString:
- case kErrorCodeDownloadMetadataSignatureError:
- case kErrorCodeDownloadMetadataSignatureVerificationError:
- case kErrorCodePayloadMismatchedType:
- case kErrorCodeUnsupportedMajorPayloadVersion:
- case kErrorCodeUnsupportedMinorPayloadVersion:
- case kErrorCodeDownloadNewPartitionInfoError:
- case kErrorCodeDownloadSignatureMissingInManifest:
- case kErrorCodeDownloadManifestParseError:
- case kErrorCodeDownloadOperationHashMissingError:
+ case ErrorCode::kDownloadInvalidMetadataSize:
+ case ErrorCode::kDownloadInvalidMetadataMagicString:
+ case ErrorCode::kDownloadMetadataSignatureError:
+ case ErrorCode::kDownloadMetadataSignatureVerificationError:
+ case ErrorCode::kPayloadMismatchedType:
+ case ErrorCode::kUnsupportedMajorPayloadVersion:
+ case ErrorCode::kUnsupportedMinorPayloadVersion:
+ case ErrorCode::kDownloadNewPartitionInfoError:
+ case ErrorCode::kDownloadSignatureMissingInManifest:
+ case ErrorCode::kDownloadManifestParseError:
+ case ErrorCode::kDownloadOperationHashMissingError:
return metrics::AttemptResult::kMetadataMalformed;
- case kErrorCodeDownloadOperationHashMismatch:
- case kErrorCodeDownloadOperationHashVerificationError:
+ case ErrorCode::kDownloadOperationHashMismatch:
+ case ErrorCode::kDownloadOperationHashVerificationError:
return metrics::AttemptResult::kOperationMalformed;
- case kErrorCodeDownloadOperationExecutionError:
- case kErrorCodeInstallDeviceOpenError:
- case kErrorCodeKernelDeviceOpenError:
- case kErrorCodeDownloadWriteError:
- case kErrorCodeFilesystemCopierError:
+ case ErrorCode::kDownloadOperationExecutionError:
+ case ErrorCode::kInstallDeviceOpenError:
+ case ErrorCode::kKernelDeviceOpenError:
+ case ErrorCode::kDownloadWriteError:
+ case ErrorCode::kFilesystemCopierError:
return metrics::AttemptResult::kOperationExecutionError;
- case kErrorCodeDownloadMetadataSignatureMismatch:
+ case ErrorCode::kDownloadMetadataSignatureMismatch:
return metrics::AttemptResult::kMetadataVerificationFailed;
- case kErrorCodePayloadSizeMismatchError:
- case kErrorCodePayloadHashMismatchError:
- case kErrorCodeDownloadPayloadVerificationError:
- case kErrorCodeSignedDeltaPayloadExpectedError:
- case kErrorCodeDownloadPayloadPubKeyVerificationError:
+ case ErrorCode::kPayloadSizeMismatchError:
+ case ErrorCode::kPayloadHashMismatchError:
+ case ErrorCode::kDownloadPayloadVerificationError:
+ case ErrorCode::kSignedDeltaPayloadExpectedError:
+ case ErrorCode::kDownloadPayloadPubKeyVerificationError:
return metrics::AttemptResult::kPayloadVerificationFailed;
- case kErrorCodeNewRootfsVerificationError:
- case kErrorCodeNewKernelVerificationError:
+ case ErrorCode::kNewRootfsVerificationError:
+ case ErrorCode::kNewKernelVerificationError:
return metrics::AttemptResult::kVerificationFailed;
- case kErrorCodePostinstallRunnerError:
- case kErrorCodePostinstallBootedFromFirmwareB:
- case kErrorCodePostinstallFirmwareRONotUpdatable:
+ case ErrorCode::kPostinstallRunnerError:
+ case ErrorCode::kPostinstallBootedFromFirmwareB:
+ case ErrorCode::kPostinstallFirmwareRONotUpdatable:
return metrics::AttemptResult::kPostInstallFailed;
// We should never get these errors in the update-attempt stage so
// return internal error if this happens.
- case kErrorCodeError:
- case kErrorCodeOmahaRequestXMLParseError:
- case kErrorCodeOmahaRequestError:
- case kErrorCodeOmahaResponseHandlerError:
- case kErrorCodeDownloadStateInitializationError:
- case kErrorCodeOmahaRequestEmptyResponseError:
- case kErrorCodeDownloadInvalidMetadataSignature:
- case kErrorCodeOmahaResponseInvalid:
- case kErrorCodeOmahaUpdateIgnoredPerPolicy:
- case kErrorCodeOmahaUpdateDeferredPerPolicy:
- case kErrorCodeOmahaErrorInHTTPResponse:
- case kErrorCodeDownloadMetadataSignatureMissingError:
- case kErrorCodeOmahaUpdateDeferredForBackoff:
- case kErrorCodePostinstallPowerwashError:
- case kErrorCodeUpdateCanceledByChannelChange:
+ case ErrorCode::kError:
+ case ErrorCode::kOmahaRequestXMLParseError:
+ case ErrorCode::kOmahaRequestError:
+ case ErrorCode::kOmahaResponseHandlerError:
+ case ErrorCode::kDownloadStateInitializationError:
+ case ErrorCode::kOmahaRequestEmptyResponseError:
+ case ErrorCode::kDownloadInvalidMetadataSignature:
+ case ErrorCode::kOmahaResponseInvalid:
+ case ErrorCode::kOmahaUpdateIgnoredPerPolicy:
+ case ErrorCode::kOmahaUpdateDeferredPerPolicy:
+ case ErrorCode::kOmahaErrorInHTTPResponse:
+ case ErrorCode::kDownloadMetadataSignatureMissingError:
+ case ErrorCode::kOmahaUpdateDeferredForBackoff:
+ case ErrorCode::kPostinstallPowerwashError:
+ case ErrorCode::kUpdateCanceledByChannelChange:
return metrics::AttemptResult::kInternalError;
// Special flags. These can't happen (we mask them out above) but
// the compiler doesn't know that. Just break out so we can warn and
// return |kInternalError|.
- case kErrorCodeUmaReportedMax:
- case kErrorCodeOmahaRequestHTTPResponseBase:
- case kErrorCodeDevModeFlag:
- case kErrorCodeResumedFlag:
- case kErrorCodeTestImageFlag:
- case kErrorCodeTestOmahaUrlFlag:
- case kErrorCodeSpecialFlags:
+ case ErrorCode::kUmaReportedMax:
+ case ErrorCode::kOmahaRequestHTTPResponseBase:
+ case ErrorCode::kDevModeFlag:
+ case ErrorCode::kResumedFlag:
+ case ErrorCode::kTestImageFlag:
+ case ErrorCode::kTestOmahaUrlFlag:
+ case ErrorCode::kSpecialFlags:
break;
}
@@ -1044,10 +1046,13 @@
metrics::DownloadErrorCode GetDownloadErrorCode(ErrorCode code) {
- ErrorCode base_code = static_cast<ErrorCode>(code & ~kErrorCodeSpecialFlags);
+ ErrorCode base_code = static_cast<ErrorCode>(
+ static_cast<int>(code) & ~static_cast<int>(ErrorCode::kSpecialFlags));
- if (base_code >= kErrorCodeOmahaRequestHTTPResponseBase) {
- int http_status = base_code - kErrorCodeOmahaRequestHTTPResponseBase;
+ if (base_code >= ErrorCode::kOmahaRequestHTTPResponseBase) {
+ int http_status =
+ static_cast<int>(base_code) -
+ static_cast<int>(ErrorCode::kOmahaRequestHTTPResponseBase);
if (http_status >= 200 && http_status <= 599) {
return static_cast<metrics::DownloadErrorCode>(
static_cast<int>(metrics::DownloadErrorCode::kHttpStatus200) +
@@ -1062,73 +1067,73 @@
}
switch (base_code) {
- // Unfortunately, kErrorCodeDownloadTransferError is returned for a wide
+ // Unfortunately, ErrorCode::kDownloadTransferError is returned for a wide
// variety of errors (proxy errors, host not reachable, timeouts etc.).
//
// For now just map that to kDownloading. See http://crbug.com/355745
// for how we plan to add more detail in the future.
- case kErrorCodeDownloadTransferError:
+ case ErrorCode::kDownloadTransferError:
return metrics::DownloadErrorCode::kDownloadError;
// All of these error codes are not related to downloading so break
// out so we can warn and return InputMalformed.
- case kErrorCodeSuccess:
- case kErrorCodeError:
- case kErrorCodeOmahaRequestError:
- case kErrorCodeOmahaResponseHandlerError:
- case kErrorCodeFilesystemCopierError:
- case kErrorCodePostinstallRunnerError:
- case kErrorCodePayloadMismatchedType:
- case kErrorCodeInstallDeviceOpenError:
- case kErrorCodeKernelDeviceOpenError:
- case kErrorCodePayloadHashMismatchError:
- case kErrorCodePayloadSizeMismatchError:
- case kErrorCodeDownloadPayloadVerificationError:
- case kErrorCodeDownloadNewPartitionInfoError:
- case kErrorCodeDownloadWriteError:
- case kErrorCodeNewRootfsVerificationError:
- case kErrorCodeNewKernelVerificationError:
- case kErrorCodeSignedDeltaPayloadExpectedError:
- case kErrorCodeDownloadPayloadPubKeyVerificationError:
- case kErrorCodePostinstallBootedFromFirmwareB:
- case kErrorCodeDownloadStateInitializationError:
- case kErrorCodeDownloadInvalidMetadataMagicString:
- case kErrorCodeDownloadSignatureMissingInManifest:
- case kErrorCodeDownloadManifestParseError:
- case kErrorCodeDownloadMetadataSignatureError:
- case kErrorCodeDownloadMetadataSignatureVerificationError:
- case kErrorCodeDownloadMetadataSignatureMismatch:
- case kErrorCodeDownloadOperationHashVerificationError:
- case kErrorCodeDownloadOperationExecutionError:
- case kErrorCodeDownloadOperationHashMismatch:
- case kErrorCodeOmahaRequestEmptyResponseError:
- case kErrorCodeOmahaRequestXMLParseError:
- case kErrorCodeDownloadInvalidMetadataSize:
- case kErrorCodeDownloadInvalidMetadataSignature:
- case kErrorCodeOmahaResponseInvalid:
- case kErrorCodeOmahaUpdateIgnoredPerPolicy:
- case kErrorCodeOmahaUpdateDeferredPerPolicy:
- case kErrorCodeOmahaErrorInHTTPResponse:
- case kErrorCodeDownloadOperationHashMissingError:
- case kErrorCodeDownloadMetadataSignatureMissingError:
- case kErrorCodeOmahaUpdateDeferredForBackoff:
- case kErrorCodePostinstallPowerwashError:
- case kErrorCodeUpdateCanceledByChannelChange:
- case kErrorCodePostinstallFirmwareRONotUpdatable:
- case kErrorCodeUnsupportedMajorPayloadVersion:
- case kErrorCodeUnsupportedMinorPayloadVersion:
+ case ErrorCode::kSuccess:
+ case ErrorCode::kError:
+ case ErrorCode::kOmahaRequestError:
+ case ErrorCode::kOmahaResponseHandlerError:
+ case ErrorCode::kFilesystemCopierError:
+ case ErrorCode::kPostinstallRunnerError:
+ case ErrorCode::kPayloadMismatchedType:
+ case ErrorCode::kInstallDeviceOpenError:
+ case ErrorCode::kKernelDeviceOpenError:
+ case ErrorCode::kPayloadHashMismatchError:
+ case ErrorCode::kPayloadSizeMismatchError:
+ case ErrorCode::kDownloadPayloadVerificationError:
+ case ErrorCode::kDownloadNewPartitionInfoError:
+ case ErrorCode::kDownloadWriteError:
+ case ErrorCode::kNewRootfsVerificationError:
+ case ErrorCode::kNewKernelVerificationError:
+ case ErrorCode::kSignedDeltaPayloadExpectedError:
+ case ErrorCode::kDownloadPayloadPubKeyVerificationError:
+ case ErrorCode::kPostinstallBootedFromFirmwareB:
+ case ErrorCode::kDownloadStateInitializationError:
+ case ErrorCode::kDownloadInvalidMetadataMagicString:
+ case ErrorCode::kDownloadSignatureMissingInManifest:
+ case ErrorCode::kDownloadManifestParseError:
+ case ErrorCode::kDownloadMetadataSignatureError:
+ case ErrorCode::kDownloadMetadataSignatureVerificationError:
+ case ErrorCode::kDownloadMetadataSignatureMismatch:
+ case ErrorCode::kDownloadOperationHashVerificationError:
+ case ErrorCode::kDownloadOperationExecutionError:
+ case ErrorCode::kDownloadOperationHashMismatch:
+ case ErrorCode::kOmahaRequestEmptyResponseError:
+ case ErrorCode::kOmahaRequestXMLParseError:
+ case ErrorCode::kDownloadInvalidMetadataSize:
+ case ErrorCode::kDownloadInvalidMetadataSignature:
+ case ErrorCode::kOmahaResponseInvalid:
+ case ErrorCode::kOmahaUpdateIgnoredPerPolicy:
+ case ErrorCode::kOmahaUpdateDeferredPerPolicy:
+ case ErrorCode::kOmahaErrorInHTTPResponse:
+ case ErrorCode::kDownloadOperationHashMissingError:
+ case ErrorCode::kDownloadMetadataSignatureMissingError:
+ case ErrorCode::kOmahaUpdateDeferredForBackoff:
+ case ErrorCode::kPostinstallPowerwashError:
+ case ErrorCode::kUpdateCanceledByChannelChange:
+ case ErrorCode::kPostinstallFirmwareRONotUpdatable:
+ case ErrorCode::kUnsupportedMajorPayloadVersion:
+ case ErrorCode::kUnsupportedMinorPayloadVersion:
break;
// Special flags. These can't happen (we mask them out above) but
// the compiler doesn't know that. Just break out so we can warn and
// return |kInputMalformed|.
- case kErrorCodeUmaReportedMax:
- case kErrorCodeOmahaRequestHTTPResponseBase:
- case kErrorCodeDevModeFlag:
- case kErrorCodeResumedFlag:
- case kErrorCodeTestImageFlag:
- case kErrorCodeTestOmahaUrlFlag:
- case kErrorCodeSpecialFlags:
+ case ErrorCode::kUmaReportedMax:
+ case ErrorCode::kOmahaRequestHTTPResponseBase:
+ case ErrorCode::kDevModeFlag:
+ case ErrorCode::kResumedFlag:
+ case ErrorCode::kTestImageFlag:
+ case ErrorCode::kTestOmahaUrlFlag:
+ case ErrorCode::kSpecialFlags:
LOG(ERROR) << "Unexpected error code " << base_code;
break;
}
@@ -1175,7 +1180,8 @@
// 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 & kErrorCodeSpecialFlags;
+ uint32_t flags = (static_cast<uint32_t>(code) &
+ static_cast<uint32_t>(ErrorCode::kSpecialFlags));
string flag_names;
string separator = "";
for(size_t i = 0; i < sizeof(flags) * 8; i++) {
@@ -1197,7 +1203,8 @@
// 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 & kErrorCodeSpecialFlags;
+ uint32_t flags =
+ static_cast<int>(code) & static_cast<int>(ErrorCode::kSpecialFlags);
if (!flags)
flags = system_state->update_attempter()->GetErrorCodeFlags();
@@ -1205,7 +1212,8 @@
// 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 & ~kErrorCodeResumedFlag) ?
+ string metric =
+ flags & ~static_cast<uint32_t>(ErrorCode::kResumedFlag) ?
"Installer.DevModeErrorCodes" : "Installer.NormalErrorCodes";
LOG(INFO) << "Sending error code " << uma_error_code
@@ -1213,9 +1221,9 @@
<< " to UMA metric: " << metric
<< ". Flags = " << (flags ? GetFlagNames(flags) : "None");
- system_state->metrics_lib()->SendEnumToUMA(metric,
- uma_error_code,
- kErrorCodeUmaReportedMax);
+ system_state->metrics_lib()->SendEnumToUMA(
+ metric, static_cast<int>(uma_error_code),
+ static_cast<int>(ErrorCode::kUmaReportedMax));
}
string CodeToString(ErrorCode code) {
@@ -1223,112 +1231,114 @@
// 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 & kErrorCodeSpecialFlags) && (code & ~kErrorCodeSpecialFlags))
- code = static_cast<ErrorCode>(code & ~kErrorCodeSpecialFlags);
+ if ((static_cast<int>(code) & static_cast<int>(ErrorCode::kSpecialFlags)) &&
+ (static_cast<int>(code) & ~static_cast<int>(ErrorCode::kSpecialFlags)))
+ code = static_cast<ErrorCode>(
+ static_cast<int>(code) & ~static_cast<int>(ErrorCode::kSpecialFlags));
switch (code) {
- 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 kErrorCodePayloadMismatchedType:
- return "kErrorCodePayloadMismatchedType";
- 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:
+ case ErrorCode::kSuccess: return "ErrorCode::kSuccess";
+ case ErrorCode::kError: return "ErrorCode::kError";
+ case ErrorCode::kOmahaRequestError: return "ErrorCode::kOmahaRequestError";
+ case ErrorCode::kOmahaResponseHandlerError:
+ return "ErrorCode::kOmahaResponseHandlerError";
+ case ErrorCode::kFilesystemCopierError:
+ return "ErrorCode::kFilesystemCopierError";
+ case ErrorCode::kPostinstallRunnerError:
+ return "ErrorCode::kPostinstallRunnerError";
+ case ErrorCode::kPayloadMismatchedType:
+ return "ErrorCode::kPayloadMismatchedType";
+ case ErrorCode::kInstallDeviceOpenError:
+ return "ErrorCode::kInstallDeviceOpenError";
+ case ErrorCode::kKernelDeviceOpenError:
+ return "ErrorCode::kKernelDeviceOpenError";
+ case ErrorCode::kDownloadTransferError:
+ return "ErrorCode::kDownloadTransferError";
+ case ErrorCode::kPayloadHashMismatchError:
+ return "ErrorCode::kPayloadHashMismatchError";
+ case ErrorCode::kPayloadSizeMismatchError:
+ return "ErrorCode::kPayloadSizeMismatchError";
+ case ErrorCode::kDownloadPayloadVerificationError:
+ return "ErrorCode::kDownloadPayloadVerificationError";
+ case ErrorCode::kDownloadNewPartitionInfoError:
+ return "ErrorCode::kDownloadNewPartitionInfoError";
+ case ErrorCode::kDownloadWriteError:
+ return "ErrorCode::kDownloadWriteError";
+ case ErrorCode::kNewRootfsVerificationError:
+ return "ErrorCode::kNewRootfsVerificationError";
+ case ErrorCode::kNewKernelVerificationError:
+ return "ErrorCode::kNewKernelVerificationError";
+ case ErrorCode::kSignedDeltaPayloadExpectedError:
+ return "ErrorCode::kSignedDeltaPayloadExpectedError";
+ case ErrorCode::kDownloadPayloadPubKeyVerificationError:
+ return "ErrorCode::kDownloadPayloadPubKeyVerificationError";
+ case ErrorCode::kPostinstallBootedFromFirmwareB:
+ return "ErrorCode::kPostinstallBootedFromFirmwareB";
+ case ErrorCode::kDownloadStateInitializationError:
+ return "ErrorCode::kDownloadStateInitializationError";
+ case ErrorCode::kDownloadInvalidMetadataMagicString:
+ return "ErrorCode::kDownloadInvalidMetadataMagicString";
+ case ErrorCode::kDownloadSignatureMissingInManifest:
+ return "ErrorCode::kDownloadSignatureMissingInManifest";
+ case ErrorCode::kDownloadManifestParseError:
+ return "ErrorCode::kDownloadManifestParseError";
+ case ErrorCode::kDownloadMetadataSignatureError:
+ return "ErrorCode::kDownloadMetadataSignatureError";
+ case ErrorCode::kDownloadMetadataSignatureVerificationError:
+ return "ErrorCode::kDownloadMetadataSignatureVerificationError";
+ case ErrorCode::kDownloadMetadataSignatureMismatch:
+ return "ErrorCode::kDownloadMetadataSignatureMismatch";
+ case ErrorCode::kDownloadOperationHashVerificationError:
+ return "ErrorCode::kDownloadOperationHashVerificationError";
+ case ErrorCode::kDownloadOperationExecutionError:
+ return "ErrorCode::kDownloadOperationExecutionError";
+ case ErrorCode::kDownloadOperationHashMismatch:
+ return "ErrorCode::kDownloadOperationHashMismatch";
+ case ErrorCode::kOmahaRequestEmptyResponseError:
+ return "ErrorCode::kOmahaRequestEmptyResponseError";
+ case ErrorCode::kOmahaRequestXMLParseError:
+ return "ErrorCode::kOmahaRequestXMLParseError";
+ case ErrorCode::kDownloadInvalidMetadataSize:
+ return "ErrorCode::kDownloadInvalidMetadataSize";
+ case ErrorCode::kDownloadInvalidMetadataSignature:
+ return "ErrorCode::kDownloadInvalidMetadataSignature";
+ case ErrorCode::kOmahaResponseInvalid:
+ return "ErrorCode::kOmahaResponseInvalid";
+ case ErrorCode::kOmahaUpdateIgnoredPerPolicy:
+ return "ErrorCode::kOmahaUpdateIgnoredPerPolicy";
+ case ErrorCode::kOmahaUpdateDeferredPerPolicy:
+ return "ErrorCode::kOmahaUpdateDeferredPerPolicy";
+ case ErrorCode::kOmahaErrorInHTTPResponse:
+ return "ErrorCode::kOmahaErrorInHTTPResponse";
+ case ErrorCode::kDownloadOperationHashMissingError:
+ return "ErrorCode::kDownloadOperationHashMissingError";
+ case ErrorCode::kDownloadMetadataSignatureMissingError:
+ return "ErrorCode::kDownloadMetadataSignatureMissingError";
+ case ErrorCode::kOmahaUpdateDeferredForBackoff:
+ return "ErrorCode::kOmahaUpdateDeferredForBackoff";
+ case ErrorCode::kPostinstallPowerwashError:
+ return "ErrorCode::kPostinstallPowerwashError";
+ case ErrorCode::kUpdateCanceledByChannelChange:
+ return "ErrorCode::kUpdateCanceledByChannelChange";
+ case ErrorCode::kUmaReportedMax:
+ return "ErrorCode::kUmaReportedMax";
+ case ErrorCode::kOmahaRequestHTTPResponseBase:
+ return "ErrorCode::kOmahaRequestHTTPResponseBase";
+ case ErrorCode::kResumedFlag:
return "Resumed";
- case kErrorCodeDevModeFlag:
+ case ErrorCode::kDevModeFlag:
return "DevMode";
- case kErrorCodeTestImageFlag:
+ case ErrorCode::kTestImageFlag:
return "TestImage";
- case kErrorCodeTestOmahaUrlFlag:
+ case ErrorCode::kTestOmahaUrlFlag:
return "TestOmahaUrl";
- case kErrorCodeSpecialFlags:
- return "kErrorCodeSpecialFlags";
- case kErrorCodePostinstallFirmwareRONotUpdatable:
- return "kErrorCodePostinstallFirmwareRONotUpdatable";
- case kErrorCodeUnsupportedMajorPayloadVersion:
- return "kErrorCodeUnsupportedMajorPayloadVersion";
- case kErrorCodeUnsupportedMinorPayloadVersion:
- return "kErrorCodeUnsupportedMinorPayloadVersion";
+ case ErrorCode::kSpecialFlags:
+ return "ErrorCode::kSpecialFlags";
+ case ErrorCode::kPostinstallFirmwareRONotUpdatable:
+ return "ErrorCode::kPostinstallFirmwareRONotUpdatable";
+ case ErrorCode::kUnsupportedMajorPayloadVersion:
+ return "ErrorCode::kUnsupportedMajorPayloadVersion";
+ case ErrorCode::kUnsupportedMinorPayloadVersion:
+ return "ErrorCode::kUnsupportedMinorPayloadVersion";
// 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 d2a0fc2..ed71e9f 100644
--- a/utils.h
+++ b/utils.h
@@ -347,7 +347,7 @@
// Transforms a ErrorCode value into a metrics::DownloadErrorCode.
// This obviously only works for errors related to downloading so if |code|
-// is e.g. |kErrorCodeFilesystemCopierError| then
+// is e.g. |ErrorCode::kFilesystemCopierError| then
// |kDownloadErrorCodeInputMalformed| is returned.
metrics::DownloadErrorCode GetDownloadErrorCode(ErrorCode code);
@@ -570,7 +570,7 @@
AbstractAction* action)
: processor_(processor),
action_(action),
- code_(kErrorCodeError),
+ code_(ErrorCode::kError),
should_complete_(true) {}
~ScopedActionCompleter() {
if (should_complete_)