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

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: Remove Pass(). 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
« no previous file with comments | « no previous file | chrome/browser/task_manager/child_process_resource_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/process_resource_usage.h
diff --git a/chrome/browser/process_resource_usage.h b/chrome/browser/process_resource_usage.h
index bf38c813be270bbe985eea0004beecc4292d7fa7..841bc232b7122afa1e6a6af80fc70481467bd0dd 100644
--- a/chrome/browser/process_resource_usage.h
+++ b/chrome/browser/process_resource_usage.h
@@ -22,13 +22,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.
« no previous file with comments | « no previous file | chrome/browser/task_manager/child_process_resource_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698