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

Unified Diff: chrome/browser/task_manager/child_process_resource_provider.cc

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/task_manager/child_process_resource_provider.cc
diff --git a/chrome/browser/task_manager/child_process_resource_provider.cc b/chrome/browser/task_manager/child_process_resource_provider.cc
index 38d7b06d80002595b821ea236f8ef1a3cccccdd6..b460125701462d9f0a923b49db3ed3169db7516b 100644
--- a/chrome/browser/task_manager/child_process_resource_provider.cc
+++ b/chrome/browser/task_manager/child_process_resource_provider.cc
@@ -60,11 +60,8 @@ class ChildProcessResource : public Resource {
// process would be "Plugin: Flash" when name is "Flash".
base::string16 GetLocalizedTitle() const;
- static mojo::InterfacePtrInfo<ResourceUsageReporter>
- GetProcessUsageOnIOThread(int id);
-
- void OnGetProcessUsageDone(
- mojo::InterfacePtrInfo<ResourceUsageReporter> info);
+ static void ConnectResourceReporterOnIOThread(
+ int id, mojo::InterfaceRequest<ResourceUsageReporter> req);
int process_type_;
base::string16 name_;
@@ -88,21 +85,19 @@ class ChildProcessResource : public Resource {
gfx::ImageSkia* ChildProcessResource::default_icon_ = NULL;
// static
-mojo::InterfacePtrInfo<ResourceUsageReporter>
-ChildProcessResource::GetProcessUsageOnIOThread(int id) {
+void ChildProcessResource::ConnectResourceReporterOnIOThread(
+ int id, mojo::InterfaceRequest<ResourceUsageReporter> req) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
content::BrowserChildProcessHost* host =
content::BrowserChildProcessHost::FromID(id);
if (!host)
- return mojo::InterfacePtrInfo<ResourceUsageReporter>();
+ return;
content::ServiceRegistry* registry = host->GetServiceRegistry();
if (!registry)
- return mojo::InterfacePtrInfo<ResourceUsageReporter>();
+ return;
- ResourceUsageReporterPtr service;
- registry->ConnectToRemoteService(&service);
- return service.PassInterface().Pass();
+ registry->ConnectToRemoteService(req.Pass());
}
ChildProcessResource::ChildProcessResource(int process_type,
@@ -123,27 +118,19 @@ ChildProcessResource::ChildProcessResource(int process_type,
default_icon_ = rb.GetImageSkiaNamed(IDR_PLUGINS_FAVICON);
// TODO(jabdelmalek): use different icon for web workers.
}
- BrowserThread::PostTaskAndReplyWithResult(
+ ResourceUsageReporterPtr service;
+ mojo::InterfaceRequest<ResourceUsageReporter> request =
+ mojo::GetProxy(&service);
+ BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- base::Bind(&ChildProcessResource::GetProcessUsageOnIOThread,
- unique_process_id),
- base::Bind(&ChildProcessResource::OnGetProcessUsageDone,
- weak_factory_.GetWeakPtr()));
+ base::Bind(&ChildProcessResource::ConnectResourceReporterOnIOThread,
+ unique_process_id, base::Passed(&request)));
+ resource_usage_.reset(new ProcessResourceUsage(service.Pass()));
Sam McNally 2015/05/20 02:53:12 This change will cause ProcessResourceUsages to be
Anand Mistry (off Chromium) 2015/05/20 03:14:59 It will, as soon as I submit https://codereview.ch
}
ChildProcessResource::~ChildProcessResource() {
}
-void ChildProcessResource::OnGetProcessUsageDone(
- mojo::InterfacePtrInfo<ResourceUsageReporter> info) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- if (info.is_valid()) {
- ResourceUsageReporterPtr service;
- service.Bind(info.Pass());
- resource_usage_.reset(new ProcessResourceUsage(service.Pass()));
- }
-}
-
// Resource methods:
base::string16 ChildProcessResource::GetTitle() const {
if (title_.empty())

Powered by Google App Engine
This is Rietveld 408576698