| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/task_manager/child_process_resource_provider.h" | 5 #include "chrome/browser/task_manager/child_process_resource_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "chrome/browser/process_resource_usage.h" | 15 #include "chrome/browser/process_resource_usage.h" |
| 16 #include "chrome/browser/task_manager/resource_provider.h" | 16 #include "chrome/browser/task_manager/resource_provider.h" |
| 17 #include "chrome/browser/task_manager/task_manager.h" | 17 #include "chrome/browser/task_manager/task_manager.h" |
| 18 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 91 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 92 content::BrowserChildProcessHost* host = | 92 content::BrowserChildProcessHost* host = |
| 93 content::BrowserChildProcessHost::FromID(id); | 93 content::BrowserChildProcessHost::FromID(id); |
| 94 if (!host) | 94 if (!host) |
| 95 return; | 95 return; |
| 96 | 96 |
| 97 content::ServiceRegistry* registry = host->GetServiceRegistry(); | 97 content::ServiceRegistry* registry = host->GetServiceRegistry(); |
| 98 if (!registry) | 98 if (!registry) |
| 99 return; | 99 return; |
| 100 | 100 |
| 101 registry->ConnectToRemoteService(req.Pass()); | 101 registry->ConnectToRemoteService(std::move(req)); |
| 102 } | 102 } |
| 103 | 103 |
| 104 ChildProcessResource::ChildProcessResource(int process_type, | 104 ChildProcessResource::ChildProcessResource(int process_type, |
| 105 const base::string16& name, | 105 const base::string16& name, |
| 106 base::ProcessHandle handle, | 106 base::ProcessHandle handle, |
| 107 int unique_process_id) | 107 int unique_process_id) |
| 108 : process_type_(process_type), | 108 : process_type_(process_type), |
| 109 name_(name), | 109 name_(name), |
| 110 handle_(handle), | 110 handle_(handle), |
| 111 unique_process_id_(unique_process_id), | 111 unique_process_id_(unique_process_id), |
| 112 network_usage_support_(false) { | 112 network_usage_support_(false) { |
| 113 // We cache the process id because it's not cheap to calculate, and it won't | 113 // We cache the process id because it's not cheap to calculate, and it won't |
| 114 // be available when we get the plugin disconnected notification. | 114 // be available when we get the plugin disconnected notification. |
| 115 pid_ = base::GetProcId(handle); | 115 pid_ = base::GetProcId(handle); |
| 116 if (!default_icon_) { | 116 if (!default_icon_) { |
| 117 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 117 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 118 default_icon_ = rb.GetImageSkiaNamed(IDR_PLUGINS_FAVICON); | 118 default_icon_ = rb.GetImageSkiaNamed(IDR_PLUGINS_FAVICON); |
| 119 // TODO(jabdelmalek): use different icon for web workers. | 119 // TODO(jabdelmalek): use different icon for web workers. |
| 120 } | 120 } |
| 121 ResourceUsageReporterPtr service; | 121 ResourceUsageReporterPtr service; |
| 122 mojo::InterfaceRequest<ResourceUsageReporter> request = | 122 mojo::InterfaceRequest<ResourceUsageReporter> request = |
| 123 mojo::GetProxy(&service); | 123 mojo::GetProxy(&service); |
| 124 BrowserThread::PostTask( | 124 BrowserThread::PostTask( |
| 125 BrowserThread::IO, FROM_HERE, | 125 BrowserThread::IO, FROM_HERE, |
| 126 base::Bind(&ChildProcessResource::ConnectResourceReporterOnIOThread, | 126 base::Bind(&ChildProcessResource::ConnectResourceReporterOnIOThread, |
| 127 unique_process_id, base::Passed(&request))); | 127 unique_process_id, base::Passed(&request))); |
| 128 resource_usage_.reset(new ProcessResourceUsage(service.Pass())); | 128 resource_usage_.reset(new ProcessResourceUsage(std::move(service))); |
| 129 } | 129 } |
| 130 | 130 |
| 131 ChildProcessResource::~ChildProcessResource() { | 131 ChildProcessResource::~ChildProcessResource() { |
| 132 } | 132 } |
| 133 | 133 |
| 134 // Resource methods: | 134 // Resource methods: |
| 135 base::string16 ChildProcessResource::GetTitle() const { | 135 base::string16 ChildProcessResource::GetTitle() const { |
| 136 if (title_.empty()) | 136 if (title_.empty()) |
| 137 title_ = GetLocalizedTitle(); | 137 title_ = GetLocalizedTitle(); |
| 138 | 138 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 // This is called on the UI thread. | 388 // This is called on the UI thread. |
| 389 void ChildProcessResourceProvider::ChildProcessDataRetreived( | 389 void ChildProcessResourceProvider::ChildProcessDataRetreived( |
| 390 const std::vector<content::ChildProcessData>& child_processes) { | 390 const std::vector<content::ChildProcessData>& child_processes) { |
| 391 for (size_t i = 0; i < child_processes.size(); ++i) | 391 for (size_t i = 0; i < child_processes.size(); ++i) |
| 392 AddToTaskManager(child_processes[i]); | 392 AddToTaskManager(child_processes[i]); |
| 393 | 393 |
| 394 task_manager_->model()->NotifyDataReady(); | 394 task_manager_->model()->NotifyDataReady(); |
| 395 } | 395 } |
| 396 | 396 |
| 397 } // namespace task_manager | 397 } // namespace task_manager |
| OLD | NEW |