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/common/http_fetcher.h b/common/http_fetcher.h
index 1d4dba9..11e8e9f 100644
--- a/common/http_fetcher.h
+++ b/common/http_fetcher.h
@@ -28,7 +28,6 @@
#include "update_engine/common/http_common.h"
#include "update_engine/proxy_resolver.h"
-#include "update_engine/system_state.h"
// This class is a simple wrapper around an HTTP library (libcurl). We can
// easily mock out this interface for testing.
@@ -45,14 +44,13 @@
// |proxy_resolver| is the resolver that will be consulted for proxy
// settings. It may be null, in which case direct connections will
// be used. Does not take ownership of the resolver.
- HttpFetcher(ProxyResolver* proxy_resolver, SystemState* system_state)
+ HttpFetcher(ProxyResolver* proxy_resolver)
: post_data_set_(false),
http_response_code_(0),
delegate_(nullptr),
proxies_(1, kNoProxy),
proxy_resolver_(proxy_resolver),
- callback_(nullptr),
- system_state_(system_state) {}
+ callback_(nullptr) {}
virtual ~HttpFetcher();
void set_delegate(HttpFetcherDelegate* delegate) { delegate_ = delegate; }
@@ -129,11 +127,6 @@
ProxyResolver* proxy_resolver() const { return proxy_resolver_; }
- // Returns the global SystemState.
- SystemState* GetSystemState() {
- return system_state_;
- }
-
protected:
// The URL we're actively fetching from
std::string url_;
@@ -163,9 +156,6 @@
// Callback for when we are resolving proxies
std::unique_ptr<base::Closure> callback_;
- // Global system context.
- SystemState* system_state_;
-
private:
// Callback from the proxy resolver
void ProxiesResolved(const std::deque<std::string>& proxies);