Implemented download metrics for the component updater.

BUG=304354

Review URL: https://codereview.chromium.org/110293003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241454 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/component_updater/crx_downloader.cc b/chrome/browser/component_updater/crx_downloader.cc
index fcd518cf..ac8b2405 100644
--- a/chrome/browser/component_updater/crx_downloader.cc
+++ b/chrome/browser/component_updater/crx_downloader.cc
@@ -14,6 +14,15 @@
 
 namespace component_updater {
 
+CrxDownloader::Result::Result() : error(0) {}
+
+CrxDownloader::DownloadMetrics::DownloadMetrics()
+    : downloader(kNone),
+      error(0),
+      bytes_downloaded(0),
+      bytes_total(0),
+      download_time_ms(0) {}
+
 // On Windows, the first downloader in the chain is a background downloader,
 // which uses the BITS service.
 CrxDownloader* CrxDownloader::Create(
@@ -49,6 +58,22 @@
 CrxDownloader::~CrxDownloader() {
 }
 
+GURL CrxDownloader::url() const {
+  return current_url_ != urls_.end() ? *current_url_ : GURL();
+}
+
+const std::vector<CrxDownloader::DownloadMetrics>
+CrxDownloader::download_metrics() const {
+  if (!successor_)
+    return download_metrics_;
+
+  std::vector<DownloadMetrics> retval(successor_->download_metrics());
+  retval.insert(retval.begin(),
+                download_metrics_.begin(),
+                download_metrics_.end());
+  return retval;
+}
+
 bool CrxDownloader::StartDownloadFromUrl(const GURL& url) {
   std::vector<GURL> urls;
   urls.push_back(url);
@@ -72,9 +97,14 @@
   return true;
 }
 
-void CrxDownloader::OnDownloadComplete(bool is_handled, const Result& result) {
+void CrxDownloader::OnDownloadComplete(
+    bool is_handled,
+    const Result& result,
+    const DownloadMetrics& download_metrics) {
   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
 
+  download_metrics_.push_back(download_metrics);
+
   if (result.error) {
     // If an error has occured, in general try the next url if there is any,
     // then move on to the successor in the chain if there is any successor.