summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorivansham <ivansham@amazon.com>2015-02-18 15:27:09 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-18 23:27:47 +0000
commit1fbce4562b2a12e9a40cca38b3dcebd71dd02063 (patch)
tree641b628def66760ca03807446d04519db71efc94
parent32c453b595c6cfeeb3fcdbd74333b3ebbcf815d5 (diff)
downloadchromium_src-1fbce4562b2a12e9a40cca38b3dcebd71dd02063.zip
chromium_src-1fbce4562b2a12e9a40cca38b3dcebd71dd02063.tar.gz
chromium_src-1fbce4562b2a12e9a40cca38b3dcebd71dd02063.tar.bz2
Allow server endpoint to be injected into the NetMetricsLogUploader from chrome/
As discussed in https://codereview.chromium.org/866163002/, this change will allow consumer of the metrics component to configure the metrics uploader endpoint without modifying the component. BUG=453987 Review URL: https://codereview.chromium.org/886173002 Cr-Commit-Position: refs/heads/master@{#316915}
-rw-r--r--AUTHORS1
-rw-r--r--chrome/browser/metrics/chrome_metrics_service_client.cc7
-rw-r--r--chrome/browser/metrics/chrome_metrics_service_client.h2
-rw-r--r--chromecast/browser/metrics/cast_metrics_service_client.cc7
-rw-r--r--chromecast/browser/metrics/cast_metrics_service_client.h2
-rw-r--r--components/metrics.gypi2
-rw-r--r--components/metrics/BUILD.gn2
-rw-r--r--components/metrics/metrics_service.cc7
-rw-r--r--components/metrics/metrics_service_client.h2
-rw-r--r--components/metrics/test_metrics_service_client.cc2
-rw-r--r--components/metrics/test_metrics_service_client.h2
-rw-r--r--components/metrics/url_constants.cc13
-rw-r--r--components/metrics/url_constants.h18
13 files changed, 43 insertions, 24 deletions
diff --git a/AUTHORS b/AUTHORS
index ce9ba20..ca53284 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -196,6 +196,7 @@ Hyungwook Lee <withlhw@gmail.com>
Ian Scott <ian.scott@arteris.com>
Ibrar Ahmed <ibrar.ahmad@gmail.com>
Ion Rosca <rosca@adobe.com>
+Ivan Sham <ivansham@amazon.com>
J. Ryan Stinnett <jryans@chromium.org>
Jacob Mandelson <jacob@mandelson.org>
Jaehun Lim <ljaehun.lim@samsung.com>
diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc
index 5d30941..a6ee8b7 100644
--- a/chrome/browser/metrics/chrome_metrics_service_client.cc
+++ b/chrome/browser/metrics/chrome_metrics_service_client.cc
@@ -36,6 +36,7 @@
#include "components/metrics/net/network_metrics_provider.h"
#include "components/metrics/profiler/profiler_metrics_provider.h"
#include "components/metrics/profiler/tracking_synchronizer.h"
+#include "components/metrics/url_constants.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/histogram_fetcher.h"
#include "content/public/browser/notification_service.h"
@@ -236,12 +237,12 @@ void ChromeMetricsServiceClient::CollectFinalMetrics(
scoped_ptr<metrics::MetricsLogUploader>
ChromeMetricsServiceClient::CreateUploader(
- const std::string& server_url,
- const std::string& mime_type,
const base::Callback<void(int)>& on_upload_complete) {
return scoped_ptr<metrics::MetricsLogUploader>(
new metrics::NetMetricsLogUploader(
- g_browser_process->system_request_context(), server_url, mime_type,
+ g_browser_process->system_request_context(),
+ metrics::kDefaultMetricsServerUrl,
+ metrics::kDefaultMetricsMimeType,
on_upload_complete));
}
diff --git a/chrome/browser/metrics/chrome_metrics_service_client.h b/chrome/browser/metrics/chrome_metrics_service_client.h
index 3f2e96c..2b95742 100644
--- a/chrome/browser/metrics/chrome_metrics_service_client.h
+++ b/chrome/browser/metrics/chrome_metrics_service_client.h
@@ -67,8 +67,6 @@ class ChromeMetricsServiceClient
void StartGatheringMetrics(const base::Closure& done_callback) override;
void CollectFinalMetrics(const base::Closure& done_callback) override;
scoped_ptr<metrics::MetricsLogUploader> CreateUploader(
- const std::string& server_url,
- const std::string& mime_type,
const base::Callback<void(int)>& on_upload_complete) override;
base::string16 GetRegistryBackupKey() override;
diff --git a/chromecast/browser/metrics/cast_metrics_service_client.cc b/chromecast/browser/metrics/cast_metrics_service_client.cc
index 84192d7..3e97217 100644
--- a/chromecast/browser/metrics/cast_metrics_service_client.cc
+++ b/chromecast/browser/metrics/cast_metrics_service_client.cc
@@ -21,6 +21,7 @@
#include "components/metrics/net/net_metrics_log_uploader.h"
#include "components/metrics/net/network_metrics_provider.h"
#include "components/metrics/profiler/profiler_metrics_provider.h"
+#include "components/metrics/url_constants.h"
#include "content/public/common/content_switches.h"
#if defined(OS_LINUX)
@@ -133,10 +134,8 @@ void CastMetricsServiceClient::CollectFinalMetrics(
scoped_ptr< ::metrics::MetricsLogUploader>
CastMetricsServiceClient::CreateUploader(
- const std::string& server_url,
- const std::string& mime_type,
const base::Callback<void(int)>& on_upload_complete) {
- std::string uma_server_url(server_url);
+ std::string uma_server_url(::metrics::kDefaultMetricsServerUrl);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kOverrideMetricsUploadUrl)) {
uma_server_url.assign(
@@ -147,7 +146,7 @@ CastMetricsServiceClient::CreateUploader(
new ::metrics::NetMetricsLogUploader(
request_context_,
uma_server_url,
- mime_type,
+ ::metrics::kDefaultMetricsMimeType,
on_upload_complete));
}
diff --git a/chromecast/browser/metrics/cast_metrics_service_client.h b/chromecast/browser/metrics/cast_metrics_service_client.h
index af71a1c..72ceede 100644
--- a/chromecast/browser/metrics/cast_metrics_service_client.h
+++ b/chromecast/browser/metrics/cast_metrics_service_client.h
@@ -61,8 +61,6 @@ class CastMetricsServiceClient : public ::metrics::MetricsServiceClient {
void StartGatheringMetrics(const base::Closure& done_callback) override;
void CollectFinalMetrics(const base::Closure& done_callback) override;
scoped_ptr< ::metrics::MetricsLogUploader> CreateUploader(
- const std::string& server_url,
- const std::string& mime_type,
const base::Callback<void(int)>& on_upload_complete) override;
// Starts/stops the metrics service.
diff --git a/components/metrics.gypi b/components/metrics.gypi
index c723a15..9a8f19d 100644
--- a/components/metrics.gypi
+++ b/components/metrics.gypi
@@ -66,6 +66,8 @@
'metrics/metrics_switches.h',
'metrics/persisted_logs.cc',
'metrics/persisted_logs.h',
+ 'metrics/url_constants.cc',
+ 'metrics/url_constants.h',
],
'conditions': [
['chromeos==1', {
diff --git a/components/metrics/BUILD.gn b/components/metrics/BUILD.gn
index 69d0af4..7f4b9b5 100644
--- a/components/metrics/BUILD.gn
+++ b/components/metrics/BUILD.gn
@@ -48,6 +48,8 @@ source_set("metrics") {
"metrics_switches.h",
"persisted_logs.cc",
"persisted_logs.h",
+ "url_constants.cc",
+ "url_constants.h",
]
public_deps = [
diff --git a/components/metrics/metrics_service.cc b/components/metrics/metrics_service.cc
index 18ec2e5..962d836 100644
--- a/components/metrics/metrics_service.cc
+++ b/components/metrics/metrics_service.cc
@@ -227,12 +227,6 @@ const size_t kUploadLogAvoidRetransmitSize = 100 * 1024;
// Interval, in minutes, between state saves.
const int kSaveStateIntervalMinutes = 5;
-// The metrics server's URL.
-const char kServerUrl[] = "https://clients4.google.com/uma/v2";
-
-// The MIME type for the uploaded metrics data.
-const char kMimeType[] = "application/vnd.chrome.uma";
-
enum ResponseStatus {
UNKNOWN_FAILURE,
SUCCESS,
@@ -1021,7 +1015,6 @@ void MetricsService::SendStagedLog() {
if (!log_uploader_) {
log_uploader_ = client_->CreateUploader(
- kServerUrl, kMimeType,
base::Bind(&MetricsService::OnLogUploadComplete,
self_ptr_factory_.GetWeakPtr()));
}
diff --git a/components/metrics/metrics_service_client.h b/components/metrics/metrics_service_client.h
index 4289bae..fa31c5e 100644
--- a/components/metrics/metrics_service_client.h
+++ b/components/metrics/metrics_service_client.h
@@ -64,8 +64,6 @@ class MetricsServiceClient {
// Creates a MetricsLogUploader with the specified parameters (see comments on
// MetricsLogUploader for details).
virtual scoped_ptr<MetricsLogUploader> CreateUploader(
- const std::string& server_url,
- const std::string& mime_type,
const base::Callback<void(int)>& on_upload_complete) = 0;
// Returns the name of a key under HKEY_CURRENT_USER that can be used to store
diff --git a/components/metrics/test_metrics_service_client.cc b/components/metrics/test_metrics_service_client.cc
index c60db0b..53cb1d9 100644
--- a/components/metrics/test_metrics_service_client.cc
+++ b/components/metrics/test_metrics_service_client.cc
@@ -65,8 +65,6 @@ void TestMetricsServiceClient::CollectFinalMetrics(
}
scoped_ptr<MetricsLogUploader> TestMetricsServiceClient::CreateUploader(
- const std::string& server_url,
- const std::string& mime_type,
const base::Callback<void(int)>& on_upload_complete) {
return scoped_ptr<MetricsLogUploader>();
}
diff --git a/components/metrics/test_metrics_service_client.h b/components/metrics/test_metrics_service_client.h
index c46ac4e..14c5518 100644
--- a/components/metrics/test_metrics_service_client.h
+++ b/components/metrics/test_metrics_service_client.h
@@ -32,8 +32,6 @@ class TestMetricsServiceClient : public MetricsServiceClient {
void StartGatheringMetrics(const base::Closure& done_callback) override;
void CollectFinalMetrics(const base::Closure& done_callback) override;
scoped_ptr<MetricsLogUploader> CreateUploader(
- const std::string& server_url,
- const std::string& mime_type,
const base::Callback<void(int)>& on_upload_complete) override;
const std::string& get_client_id() const { return client_id_; }
diff --git a/components/metrics/url_constants.cc b/components/metrics/url_constants.cc
new file mode 100644
index 0000000..55d9e13
--- /dev/null
+++ b/components/metrics/url_constants.cc
@@ -0,0 +1,13 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/metrics/url_constants.h"
+
+namespace metrics {
+
+const char kDefaultMetricsServerUrl[] = "https://clients4.google.com/uma/v2";
+const char kDefaultMetricsMimeType[] = "application/vnd.chrome.uma";
+
+} // namespace metrics
+
diff --git a/components/metrics/url_constants.h b/components/metrics/url_constants.h
new file mode 100644
index 0000000..b52ddef
--- /dev/null
+++ b/components/metrics/url_constants.h
@@ -0,0 +1,18 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_METRICS_URL_CONSTANTS_H_
+#define COMPONENTS_METRICS_URL_CONSTANTS_H_
+
+namespace metrics {
+
+// The default metrics server's URL.
+extern const char kDefaultMetricsServerUrl[];
+
+// The default MIME type for the uploaded metrics data.
+extern const char kDefaultMetricsMimeType[];
+
+} // namespace metrics
+
+#endif // COMPONENTS_METRICS_URL_CONSTANTS_H_