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

Unified Diff: content/renderer/render_thread_impl.cc

Issue 2687583002: Add support for single sample metrics. (Closed)
Patch Set: Fix ios hopefully; address comments. Created 3 years, 8 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
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..b1a42cbfb8cb2dd3c815c31072d7fbd1da7063e1 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_factory_impl.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,22 @@ bool IsRunningInMash() {
return cmdline->HasSwitch(switches::kIsRunningInMash);
}
+// Necessary since BindInterface() is a template and can't be bound directly.
+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 +632,14 @@ void RenderThreadImpl::Init(
// Register this object as the main thread.
ChildProcess::current()->set_main_thread(this);
+ // In single process mode we may already have a factory set.
+ if (!base::SingleSampleMetricsFactory::Get()) {
+ base::SingleSampleMetricsFactory::SetFactory(
+ new metrics::SingleSampleMetricsFactoryImpl(base::BindRepeating(
Alexei Svitkine (slow) 2017/05/03 21:18:48 Hmm, it seems strange that this is constructing an
DaleCurtis 2017/05/03 21:37:52 You mean something like a "static metrics::Initial
Alexei Svitkine (slow) 2017/05/03 21:45:08 Yep!
DaleCurtis 2017/05/04 02:28:59 Done.
Alexei Svitkine (slow) 2017/05/04 14:15:08 Hmm, did you forget to upload a patchset? Don't se
DaleCurtis 2017/05/04 18:55:27 No intentionally didn't upload since it was busted
+ &CreateSingleSampleMetricsProvider, message_loop()->task_runner(),
+ GetConnector())));
+ }
+
gpu_ = ui::Gpu::Create(
GetConnector(),
IsRunningInMash() ? ui::mojom::kServiceName : mojom::kBrowserServiceName,
« components/metrics/single_sample_metrics_factory_impl.cc ('K') | « content/renderer/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698