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/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());