Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Unified Diff: content/renderer/render_thread_impl.cc

Issue 2687583002: Add support for single sample metrics. (Closed)
Patch Set: Address comments. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/DEPS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_thread_impl.cc
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 3cd25f1ebba73068fdcfec0e57e0bcb32d4fc927..efeb21abff80f2a2b1ba8fddd2bb045f9bc7583c 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -51,6 +51,8 @@
#include "cc/trees/layer_tree_host_common.h"
#include "cc/trees/layer_tree_settings.h"
#include "components/discardable_memory/client/client_discardable_shared_memory_manager.h"
+#include "components/metrics/public/interfaces/single_sample_metrics.mojom.h"
+#include "components/metrics/single_sample_metrics.h"
#include "content/child/appcache/appcache_dispatcher.h"
#include "content/child/appcache/appcache_frontend_impl.h"
#include "content/child/blob_storage/blob_message_filter.h"
@@ -393,6 +395,23 @@ bool IsRunningInMash() {
return cmdline->HasSwitch(switches::kIsRunningInMash);
}
+// Hook that allows single-sample metric code from //components/metrics to
+// connect from the renderer process to the browser process.
+void CreateSingleSampleMetricsProvider(
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ service_manager::Connector* connector,
+ metrics::mojom::SingleSampleMetricsProviderRequest request) {
+ if (task_runner->BelongsToCurrentThread()) {
+ connector->BindInterface(mojom::kBrowserServiceName, std::move(request));
+ return;
+ }
+
+ task_runner->PostTask(
+ FROM_HERE,
+ base::Bind(&CreateSingleSampleMetricsProvider, std::move(task_runner),
+ connector, base::Passed(&request)));
+}
+
} // namespace
// For measuring memory usage after each task. Behind a command line flag.
@@ -614,6 +633,10 @@ void RenderThreadImpl::Init(
// Register this object as the main thread.
ChildProcess::current()->set_main_thread(this);
+ metrics::InitializeSingleSampleMetricsFactory(
+ base::BindRepeating(&CreateSingleSampleMetricsProvider,
+ message_loop()->task_runner(), GetConnector()));
+
gpu_ = ui::Gpu::Create(
GetConnector(),
IsRunningInMash() ? ui::mojom::kServiceName : mojom::kBrowserServiceName,
« no previous file with comments | « content/renderer/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698