Report Enum metrics from CertificateChecker.
The certificate checker was reporting a "user action" whenever an
update check HTTPS connection or HTTPS payload download had an invalid
HTTPS certificate or a valid one that was changed since the last
connection to the same server.
This patch sends an Enum metric for every HTTPS connection to check for
and update or download the payload with one of the three options: an
invalid certificate, a valid one already seen or a valid but different
certificate.
This patch also moves these metrics to the metrics.{h,cc} module, where
all the other metrics are reported, using an observer pattern in the
CertificateChecker, needed to remove the dependency on the metrics
library from the libpayload_consumer.
Bug: 25818567
TEST=FEATURES=test emerge-link update_engine; mma;
Change-Id: Ia1b6eb799e13b439b520ba14549d8973e18bcbfa
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index f4291e9..69585c8 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -28,6 +28,7 @@
#include <base/strings/stringprintf.h>
#include <base/time/time.h>
#include <brillo/bind_lambda.h>
+#include <brillo/make_unique_ptr.h>
#include <brillo/message_loops/fake_message_loop.h>
#include <brillo/message_loops/message_loop.h>
#include <brillo/message_loops/message_loop_utils.h>
@@ -42,6 +43,7 @@
#include "update_engine/common/prefs.h"
#include "update_engine/common/test_utils.h"
#include "update_engine/common/utils.h"
+#include "update_engine/fake_system_state.h"
#include "update_engine/metrics.h"
#include "update_engine/mock_connection_manager.h"
#include "update_engine/mock_payload_state.h"
@@ -317,7 +319,7 @@
fake_system_state_.set_request_params(request_params);
OmahaRequestAction action(&fake_system_state_,
nullptr,
- fetcher,
+ brillo::make_unique_ptr(fetcher),
ping_only);
OmahaRequestActionTestProcessorDelegate delegate;
delegate.expected_code_ = expected_code;
@@ -374,7 +376,10 @@
nullptr);
FakeSystemState fake_system_state;
fake_system_state.set_request_params(¶ms);
- OmahaRequestAction action(&fake_system_state, event, fetcher, false);
+ OmahaRequestAction action(&fake_system_state,
+ event,
+ brillo::make_unique_ptr(fetcher),
+ false);
OmahaRequestActionTestProcessorDelegate delegate;
ActionProcessor processor;
processor.set_delegate(&delegate);
@@ -839,9 +844,10 @@
OmahaRequestParams params = request_params_;
fake_system_state_.set_request_params(¶ms);
OmahaRequestAction action(&fake_system_state_, nullptr,
- new MockHttpFetcher(http_response.data(),
- http_response.size(),
- nullptr),
+ brillo::make_unique_ptr(
+ new MockHttpFetcher(http_response.data(),
+ http_response.size(),
+ nullptr)),
false);
OmahaRequestActionTestProcessorDelegate delegate;
ActionProcessor processor;
@@ -1008,9 +1014,10 @@
string http_response("doesn't matter");
OmahaRequestAction action(&fake_system_state_, nullptr,
- new MockHttpFetcher(http_response.data(),
- http_response.size(),
- nullptr),
+ brillo::make_unique_ptr(
+ new MockHttpFetcher(http_response.data(),
+ http_response.size(),
+ nullptr)),
false);
TerminateEarlyTestProcessorDelegate delegate;
ActionProcessor processor;
@@ -1221,9 +1228,10 @@
OmahaRequestAction update_check_action(
&fake_system_state_,
nullptr,
- new MockHttpFetcher(http_response.data(),
- http_response.size(),
- nullptr),
+ brillo::make_unique_ptr(
+ new MockHttpFetcher(http_response.data(),
+ http_response.size(),
+ nullptr)),
false);
EXPECT_FALSE(update_check_action.IsEvent());
@@ -1232,9 +1240,10 @@
OmahaRequestAction event_action(
&fake_system_state_,
new OmahaEvent(OmahaEvent::kTypeUpdateComplete),
- new MockHttpFetcher(http_response.data(),
- http_response.size(),
- nullptr),
+ brillo::make_unique_ptr(
+ new MockHttpFetcher(http_response.data(),
+ http_response.size(),
+ nullptr)),
false);
EXPECT_TRUE(event_action.IsEvent());
}