OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/providers/child_process_task.h" | 5 #include "chrome/browser/task_manager/providers/child_process_task.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/process_resource_usage.h" | 13 #include "chrome/browser/process_resource_usage.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "chrome/browser/task_manager/task_manager_observer.h" | 15 #include "chrome/browser/task_manager/task_manager_observer.h" |
16 #include "chrome/grit/generated_resources.h" | 16 #include "chrome/grit/generated_resources.h" |
17 #include "components/nacl/common/nacl_process_type.h" | 17 #include "components/nacl/common/nacl_process_type.h" |
18 #include "content/public/browser/browser_child_process_host.h" | 18 #include "content/public/browser/browser_child_process_host.h" |
19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/browser/child_process_data.h" | 20 #include "content/public/browser/child_process_data.h" |
| 21 #include "content/public/common/child_process_host.h" |
21 #include "content/public/common/process_type.h" | 22 #include "content/public/common/process_type.h" |
22 #include "extensions/browser/extension_registry.h" | 23 #include "extensions/browser/extension_registry.h" |
23 #include "extensions/common/extension_set.h" | 24 #include "extensions/common/extension_set.h" |
24 #include "grit/theme_resources.h" | 25 #include "grit/theme_resources.h" |
25 #include "services/shell/public/cpp/interface_provider.h" | 26 #include "services/shell/public/cpp/interface_provider.h" |
26 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
27 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
28 | 29 |
29 namespace task_manager { | 30 namespace task_manager { |
30 | 31 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 case content::PROCESS_TYPE_SANDBOX_HELPER: | 105 case content::PROCESS_TYPE_SANDBOX_HELPER: |
105 case content::PROCESS_TYPE_MAX: | 106 case content::PROCESS_TYPE_MAX: |
106 break; | 107 break; |
107 case content::PROCESS_TYPE_UNKNOWN: | 108 case content::PROCESS_TYPE_UNKNOWN: |
108 NOTREACHED() << "Need localized name for child process type."; | 109 NOTREACHED() << "Need localized name for child process type."; |
109 } | 110 } |
110 | 111 |
111 return result_title; | 112 return result_title; |
112 } | 113 } |
113 | 114 |
114 // Connects the |resource_reporter| to the ServiceRegistry of the | 115 // Connects the |resource_reporter| to the InterfaceRegistry of the |
115 // BrowserChildProcessHost whose unique ID is |unique_child_process_id|. | 116 // BrowserChildProcessHost whose unique ID is |unique_child_process_id|. |
116 void ConnectResourceReporterOnIOThread( | 117 void ConnectResourceReporterOnIOThread( |
117 int unique_child_process_id, | 118 int unique_child_process_id, |
118 mojo::InterfaceRequest<mojom::ResourceUsageReporter> resource_reporter) { | 119 mojom::ResourceUsageReporterRequest resource_reporter) { |
119 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 120 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
120 | 121 |
121 content::BrowserChildProcessHost* host = | 122 content::BrowserChildProcessHost* host = |
122 content::BrowserChildProcessHost::FromID(unique_child_process_id); | 123 content::BrowserChildProcessHost::FromID(unique_child_process_id); |
123 if (!host) | 124 if (!host) |
124 return; | 125 return; |
125 | 126 |
126 shell::InterfaceProvider* interfaces = host->GetRemoteInterfaces(); | 127 shell::InterfaceProvider* interfaces = host->GetHost()->GetRemoteInterfaces(); |
127 if (interfaces) | 128 if (interfaces) |
128 interfaces->GetInterface(std::move(resource_reporter)); | 129 interfaces->GetInterface(std::move(resource_reporter)); |
129 } | 130 } |
130 | 131 |
131 // Creates the Mojo service wrapper that will be used to sample the V8 memory | 132 // Creates the Mojo service wrapper that will be used to sample the V8 memory |
132 // usage of the browser child process whose unique ID is | 133 // usage of the browser child process whose unique ID is |
133 // |unique_child_process_id|. | 134 // |unique_child_process_id|. |
134 ProcessResourceUsage* CreateProcessResourcesSampler( | 135 ProcessResourceUsage* CreateProcessResourcesSampler( |
135 int unique_child_process_id) { | 136 int unique_child_process_id) { |
136 mojom::ResourceUsageReporterPtr service; | 137 mojom::ResourceUsageReporterPtr usage_reporter; |
137 mojo::InterfaceRequest<mojom::ResourceUsageReporter> usage_reporter = | 138 mojom::ResourceUsageReporterRequest request = mojo::GetProxy(&usage_reporter); |
138 mojo::GetProxy(&service); | |
139 | |
140 content::BrowserThread::PostTask( | 139 content::BrowserThread::PostTask( |
141 content::BrowserThread::IO, | 140 content::BrowserThread::IO, |
142 FROM_HERE, | 141 FROM_HERE, |
143 base::Bind(&ConnectResourceReporterOnIOThread, | 142 base::Bind(&ConnectResourceReporterOnIOThread, |
144 unique_child_process_id, | 143 unique_child_process_id, base::Passed(&request))); |
145 base::Passed(&usage_reporter))); | |
146 | 144 |
147 return new ProcessResourceUsage(std::move(service)); | 145 return new ProcessResourceUsage(std::move(usage_reporter)); |
148 } | 146 } |
149 | 147 |
150 bool UsesV8Memory(int process_type) { | 148 bool UsesV8Memory(int process_type) { |
151 switch (process_type) { | 149 switch (process_type) { |
152 case content::PROCESS_TYPE_UTILITY: | 150 case content::PROCESS_TYPE_UTILITY: |
153 case content::PROCESS_TYPE_BROWSER: | 151 case content::PROCESS_TYPE_BROWSER: |
154 case content::PROCESS_TYPE_RENDERER: | 152 case content::PROCESS_TYPE_RENDERER: |
155 return true; | 153 return true; |
156 | 154 |
157 default: | 155 default: |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 229 |
232 int64_t ChildProcessTask::GetV8MemoryAllocated() const { | 230 int64_t ChildProcessTask::GetV8MemoryAllocated() const { |
233 return v8_memory_allocated_; | 231 return v8_memory_allocated_; |
234 } | 232 } |
235 | 233 |
236 int64_t ChildProcessTask::GetV8MemoryUsed() const { | 234 int64_t ChildProcessTask::GetV8MemoryUsed() const { |
237 return v8_memory_used_; | 235 return v8_memory_used_; |
238 } | 236 } |
239 | 237 |
240 } // namespace task_manager | 238 } // namespace task_manager |
OLD | NEW |