update_engine: Add internal error codes that used for metrics.

Whenever we are dealing with some problem that require defining error
codes and sending UMA metrics, we need to define a new ErrorCode enum
value. These error codes then will be used to send which UMA metric
value to send. Some of the UMA metrics seems to have circumvent this
process by introducing their own error codes without adding them to the
global list of error codes.

This CL introduces three new error codes:
 - kInternalLibCurlError
 - kUnresolvedHostError
 - kUnresolvedHostRecovered (Technically not an error code, but fits the
   description and use case of it.)

That are then translated to the UMA metric values we send for
DownloadErrorCode.

In addition, this CL moves the responsibility of sending these UMA
metrics from LibCurlHttpFetcher to OmahaRequestAction which is the more
correct place to send it because that's where the operations are
completed (success or failure) and we can safely decide on the value of
UMA without risking to send overlapping or duplicated metrics.

For example, previously we send kInternalLibCurlError in conjunction
with the kUnresolvedHostError. But doing this can hide the fact that
these two error codes might be related and caused by the same underlying
issue.

Same goes for kUnresolvedHostError and kUnresolvedHosRecovered. If we
send both these metrics at the same time, then we need to subtract the
number of kUnresolvedHosRecovered from kUnresolvedHostError to figure out
the number of unresolved host errors that did not recover. By
exclusively sending one or another. We can see exactly how many are
recovered and how many did not. Although this might change the meaning
of kUnresolvedHostError metric, in the long term it will not be an issue
as all the results will converge to the new behavior.

The enum.xml (chrome) is updated in crrev.com/c/1774101

BUG=None
TEST=cros_workon_make --board=amd64-generic --test --noreconf update_engine

Change-Id: I3c7bb5f6159a0bc3a37d55666572b9cd6730f3cb
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/1759544
Reviewed-by: Nicolas Norvez <norvez@chromium.org>
Tested-by: Amin Hassani <ahassani@chromium.org>
Commit-Queue: Amin Hassani <ahassani@chromium.org>
diff --git a/mock_libcurl_http_fetcher.h b/mock_libcurl_http_fetcher.h
new file mode 100644
index 0000000..a8ef0f4
--- /dev/null
+++ b/mock_libcurl_http_fetcher.h
@@ -0,0 +1,37 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef UPDATE_ENGINE_MOCK_LIBCURL_HTTP_FETCHER_H_
+#define UPDATE_ENGINE_MOCK_LIBCURL_HTTP_FETCHER_H_
+
+#include <gmock/gmock.h>
+
+#include "update_engine/connection_manager_interface.h"
+
+namespace chromeos_update_engine {
+
+class MockLibcurlHttpFetcher : public LibcurlHttpFetcher {
+ public:
+  MockLibcurlHttpFetcher(ProxyResolver* proxy_resolver,
+                         HardwareInterface* hardware)
+      : LibcurlHttpFetcher(proxy_resolver, hardware) {}
+
+  MOCK_METHOD0(GetHttpResponseCode, void());
+};
+
+}  // namespace chromeos_update_engine
+
+#endif  // UPDATE_ENGINE_MOCK_LIBCURL_HTTP_FETCHER_H_