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

Unified Diff: chrome/browser/process_resource_usage.h

Issue 1137803005: Add a ServiceRegistry::ConnectToRemoteService that takes an InterfaceRequest<>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@utility-process-report-js-memory
Patch Set: Rebase and update comment. Created 5 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
Index: chrome/browser/process_resource_usage.h
diff --git a/chrome/browser/process_resource_usage.h b/chrome/browser/process_resource_usage.h
index ad295a6bf5528c37f95045821f9c0870a50706fe..a2956e1c0e4df033def1aca7c27514585a686ec0 100644
--- a/chrome/browser/process_resource_usage.h
+++ b/chrome/browser/process_resource_usage.h
@@ -18,13 +18,31 @@
// about://memory-internals.
//
// To create:
-// 1. Obtain a ResourceUsageReporter connection using the child process's
-// service registry. i.e:
-// ResourceUsageReporterPtr service;
-// process->GetServiceRegistry()->ConnectToRemoteService(&service);
-// 2. If needed, the connection can be passed to another thread using
-// ResourceUsageReporterPtr::PassInterface().
-// 3. Pass the service to the constructor.
+// 1. Create a ResourceUsageReporterPtr and obtain an InterfaceRequest<> using
+// mojo::GetProxy.
+// 2. Use the child process's service registry to connect to the service using
+// the InterfaceRequest<>. Note, ServiceRegistry is thread hostile and
+// must always be accessed from the same thread. However, InterfaceRequest<>
+// can be passed safely between threads, and therefore a task can be posted
+// to the ServiceRegistry thread to connect to the remote service.
+// 3. Pass the ResourceUsageReporterPtr to the constructor.
+//
+// Example:
+// void Foo::ConnectToService(
+// mojo::InterfaceRequest<ResourceUsageReporter> req) {
+// content::ServiceRegistry* registry = host_->GetServiceRegistry();
+// registry->ConnectToRemoteService(req.Pass());
+// }
+//
+// ...
+// ResourceUsageReporterPtr service;
+// mojo::InterfaceRequest<ResourceUsageReporter> request =
+// mojo::GetProxy(&service);
+// content::BrowserThread::PostTask(
+// content::BrowserThread::IO, FROM_HERE,
+// base::Bind(&Foo::ConnectToService, this, base::Passed(&request)));
+// resource_usage_.reset(new ProcessResourceUsage(service.Pass()));
+// ...
//
// Note: ProcessResourceUsage is thread-hostile and must live on a single
// thread.

Powered by Google App Engine
This is Rietveld 408576698