Add an uploader to metrics_daemon

Metrics_daemon will now upload the metrics to Chrome's backend when Chrome is
not available.
This uses //components/metrics from chrome to use its protobuf definition and
the metrics common code.

This functionality is not yet enabled. It will be once the end-to-end test is
enabled.

BUG=chromium:358283, chromium:364579
TEST=FEATURES=test emerge-amd64-generic metrics

CQ-DEPEND=CL:205790
CQ-DEPEND=CL:206055

Change-Id: I87aaf7a2ac041581fa3ffd4ec61f73e933c00a52
Reviewed-on: https://chromium-review.googlesource.com/205810
Reviewed-by: Bertrand Simonnet <bsimonnet@chromium.org>
Tested-by: Bertrand Simonnet <bsimonnet@chromium.org>
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Bertrand Simonnet <bsimonnet@chromium.org>
diff --git a/metrics/metrics_daemon.h b/metrics/metrics_daemon.h
index 9c234a1..2bd12b0 100644
--- a/metrics/metrics_daemon.h
+++ b/metrics/metrics_daemon.h
@@ -18,6 +18,7 @@
 
 #include "metrics/metrics_library.h"
 #include "metrics/persistent_integer.h"
+#include "uploader/upload_service.h"
 
 using chromeos_metrics::PersistentInteger;
 
@@ -27,7 +28,9 @@
   ~MetricsDaemon();
 
   // Initializes.
-  void Init(bool testing, MetricsLibraryInterface* metrics_lib,
+  void Init(bool testing,
+            bool uploader_active,
+            MetricsLibraryInterface* metrics_lib,
             const std::string& diskstats_path,
             const std::string& vmstats_path,
             const std::string& cpuinfo_max_freq_path,
@@ -37,6 +40,9 @@
   // forking.
   void Run(bool run_as_daemon);
 
+  // Triggers an upload event and exit. (Used to test UploadService)
+  void RunUploaderTest();
+
  protected:
   // Used also by the unit tests.
   static const char kComprDataSizeName[];
@@ -363,6 +369,8 @@
   std::string vmstats_path_;
   std::string scaling_max_freq_path_;
   std::string cpuinfo_max_freq_path_;
+
+  scoped_ptr<UploadService> upload_service_;
 };
 
 #endif  // METRICS_METRICS_DAEMON_H_