Add data usage tracking for feedback uploader, trace uploader, dom distiller

This CL tags the data use from Chrome services feedback uploader, trace uploader
and dom distiller

BUG=527304

Review-Url: https://codereview.chromium.org/2375773002
Cr-Commit-Position: refs/heads/master@{#425594}
diff --git a/chrome/browser/android/feedback/connectivity_checker.cc b/chrome/browser/android/feedback/connectivity_checker.cc
index 9a4154c..a499401 100644
--- a/chrome/browser/android/feedback/connectivity_checker.cc
+++ b/chrome/browser/android/feedback/connectivity_checker.cc
@@ -14,6 +14,7 @@
 #include "base/timer/timer.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/profiles/profile_android.h"
+#include "components/data_use_measurement/core/data_use_user_data.h"
 #include "jni/ConnectivityChecker_jni.h"
 #include "net/base/load_flags.h"
 #include "net/http/http_status_code.h"
@@ -141,6 +142,9 @@
 
 void ConnectivityChecker::StartAsyncCheck() {
   url_fetcher_ = net::URLFetcher::Create(url_, net::URLFetcher::GET, this);
+  data_use_measurement::DataUseUserData::AttachToFetcher(
+      url_fetcher_.get(),
+      data_use_measurement::DataUseUserData::FEEDBACK_UPLOADER);
   url_fetcher_->SetRequestContext(request_context_);
   url_fetcher_->SetStopOnRedirect(true);
   url_fetcher_->SetAutomaticallyRetryOn5xx(false);
diff --git a/chrome/browser/tracing/crash_service_uploader.cc b/chrome/browser/tracing/crash_service_uploader.cc
index ab677e5..248eb6b 100644
--- a/chrome/browser/tracing/crash_service_uploader.cc
+++ b/chrome/browser/tracing/crash_service_uploader.cc
@@ -17,6 +17,7 @@
 #include "base/strings/stringprintf.h"
 #include "base/time/time.h"
 #include "build/build_config.h"
+#include "components/data_use_measurement/core/data_use_user_data.h"
 #include "components/tracing/common/tracing_switches.h"
 #include "components/version_info/version_info.h"
 #include "content/public/browser/browser_thread.h"
@@ -310,6 +311,9 @@
 
   url_fetcher_ =
       net::URLFetcher::Create(GURL(upload_url), net::URLFetcher::POST, this);
+  data_use_measurement::DataUseUserData::AttachToFetcher(
+      url_fetcher_.get(),
+      data_use_measurement::DataUseUserData::TRACING_UPLOADER);
   url_fetcher_->SetRequestContext(request_context_);
   url_fetcher_->SetUploadData(content_type, post_data);
   url_fetcher_->Start();
diff --git a/components/data_use_measurement/core/data_use_user_data.cc b/components/data_use_measurement/core/data_use_user_data.cc
index d1e2f09..a272226 100644
--- a/components/data_use_measurement/core/data_use_user_data.cc
+++ b/components/data_use_measurement/core/data_use_user_data.cc
@@ -86,6 +86,12 @@
       return "Precache";
     case NTP_TILES:
       return "NTPTiles";
+    case FEEDBACK_UPLOADER:
+      return "FeedbackUploader";
+    case TRACING_UPLOADER:
+      return "TracingUploader";
+    case DOM_DISTILLER:
+      return "DOMDistiller";
   }
   return "INVALID";
 }
diff --git a/components/data_use_measurement/core/data_use_user_data.h b/components/data_use_measurement/core/data_use_user_data.h
index f220084..98fee5fd 100644
--- a/components/data_use_measurement/core/data_use_user_data.h
+++ b/components/data_use_measurement/core/data_use_user_data.h
@@ -44,6 +44,9 @@
     DATA_REDUCTION_PROXY,
     PRECACHE,
     NTP_TILES,
+    FEEDBACK_UPLOADER,
+    TRACING_UPLOADER,
+    DOM_DISTILLER,
   };
 
   // The state of the application. Only available on Android and on other
diff --git a/components/dom_distiller/DEPS b/components/dom_distiller/DEPS
index 78c3cb4..b02404d 100644
--- a/components/dom_distiller/DEPS
+++ b/components/dom_distiller/DEPS
@@ -1,4 +1,5 @@
 include_rules = [
+  "+components/data_use_measurement/core",
   "+components/leveldb_proto",
   "+components/pref_registry",
   "+components/prefs",
diff --git a/components/dom_distiller/core/BUILD.gn b/components/dom_distiller/core/BUILD.gn
index 1ba587aa..3ed00be 100644
--- a/components/dom_distiller/core/BUILD.gn
+++ b/components/dom_distiller/core/BUILD.gn
@@ -63,6 +63,7 @@
   ]
   deps = [
     "//base",
+    "//components/data_use_measurement/core",
     "//components/leveldb_proto",
     "//components/pref_registry",
     "//components/prefs",
diff --git a/components/dom_distiller/core/distiller_url_fetcher.cc b/components/dom_distiller/core/distiller_url_fetcher.cc
index 0061d67..752c7ad 100644
--- a/components/dom_distiller/core/distiller_url_fetcher.cc
+++ b/components/dom_distiller/core/distiller_url_fetcher.cc
@@ -4,6 +4,7 @@
 
 #include "components/dom_distiller/core/distiller_url_fetcher.h"
 
+#include "components/data_use_measurement/core/data_use_user_data.h"
 #include "net/http/http_status_code.h"
 #include "net/url_request/url_fetcher.h"
 #include "net/url_request/url_fetcher_delegate.h"
@@ -48,6 +49,8 @@
     const std::string& url) {
   std::unique_ptr<net::URLFetcher> fetcher =
       URLFetcher::Create(GURL(url), URLFetcher::GET, this);
+  data_use_measurement::DataUseUserData::AttachToFetcher(
+      fetcher.get(), data_use_measurement::DataUseUserData::DOM_DISTILLER);
   fetcher->SetRequestContext(context_getter);
   static const int kMaxRetries = 5;
   fetcher->SetMaxRetriesOn5xx(kMaxRetries);
diff --git a/components/feedback/BUILD.gn b/components/feedback/BUILD.gn
index 2382cc6..49ee204 100644
--- a/components/feedback/BUILD.gn
+++ b/components/feedback/BUILD.gn
@@ -30,6 +30,7 @@
 
   deps = [
     "//base",
+    "//components/data_use_measurement/core",
     "//components/feedback/proto",
     "//components/keyed_service/content",
     "//components/keyed_service/core",
diff --git a/components/feedback/DEPS b/components/feedback/DEPS
index 73e72b2..d1b80c1 100644
--- a/components/feedback/DEPS
+++ b/components/feedback/DEPS
@@ -1,5 +1,6 @@
 include_rules = [
   "-content",
+  "+components/data_use_measurement/core",
   "+components/keyed_service",
   "+components/pref_registry",
   "+components/prefs",
diff --git a/components/feedback/feedback_uploader_chrome.cc b/components/feedback/feedback_uploader_chrome.cc
index c59513d..0de322a 100644
--- a/components/feedback/feedback_uploader_chrome.cc
+++ b/components/feedback/feedback_uploader_chrome.cc
@@ -11,6 +11,7 @@
 #include "base/files/file_path.h"
 #include "base/task_runner_util.h"
 #include "base/threading/sequenced_worker_pool.h"
+#include "components/data_use_measurement/core/data_use_user_data.h"
 #include "components/feedback/feedback_report.h"
 #include "components/feedback/feedback_switches.h"
 #include "components/feedback/feedback_uploader_delegate.h"
@@ -55,7 +56,8 @@
                                AsWeakPtr()),
               base::Bind(&FeedbackUploaderChrome::RetryReport, AsWeakPtr())))
           .release();
-
+  data_use_measurement::DataUseUserData::AttachToFetcher(
+      fetcher, data_use_measurement::DataUseUserData::FEEDBACK_UPLOADER);
   // Tell feedback server about the variation state of this install.
   net::HttpRequestHeaders headers;
   variations::AppendVariationHeaders(
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index 92ebc71..4d4969e 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -77603,6 +77603,9 @@
   <int value="17" label="Data Reduction Proxy"/>
   <int value="18" label="Precache"/>
   <int value="19" label="NTPTiles"/>
+  <int value="20" label="Feedback Uploader"/>
+  <int value="21" label="Tracing Uploader"/>
+  <int value="22" label="DOM Distiller"/>
 </enum>
 
 <enum name="DecodedImageOrientation" type="int">