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

Side by Side Diff: chrome/browser/task_manager/sampling/task_group.cc

Issue 2649063003: Revert of Query NaCl processes' GDB debug port on the correct thread. (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/task_manager/sampling/task_group.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/sampling/task_group.h" 5 #include "chrome/browser/task_manager/sampling/task_group.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "chrome/browser/task_manager/sampling/shared_sampler.h" 13 #include "chrome/browser/task_manager/sampling/shared_sampler.h"
14 #include "chrome/browser/task_manager/task_manager_observer.h" 14 #include "chrome/browser/task_manager/task_manager_observer.h"
15 #include "components/nacl/browser/nacl_browser.h" 15 #include "components/nacl/browser/nacl_browser.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/memory_coordinator.h" 17 #include "content/public/browser/memory_coordinator.h"
18 #include "content/public/common/content_features.h" 18 #include "content/public/common/content_features.h"
19 #include "gpu/ipc/common/memory_stats.h" 19 #include "gpu/ipc/common/memory_stats.h"
20 20
21 namespace task_manager { 21 namespace task_manager {
22 22
23 namespace { 23 namespace {
24 24
25 // A mask for the refresh types that are done in the background thread. 25 // A mask for the refresh types that are done in the background thread.
26 const int kBackgroundRefreshTypesMask = 26 const int kBackgroundRefreshTypesMask =
27 REFRESH_TYPE_CPU | REFRESH_TYPE_MEMORY | REFRESH_TYPE_IDLE_WAKEUPS | 27 REFRESH_TYPE_CPU | REFRESH_TYPE_MEMORY | REFRESH_TYPE_IDLE_WAKEUPS |
28 #if defined(OS_WIN) 28 #if defined(OS_WIN)
29 REFRESH_TYPE_START_TIME | REFRESH_TYPE_CPU_TIME | 29 REFRESH_TYPE_START_TIME | REFRESH_TYPE_CPU_TIME |
30 #endif // defined(OS_WIN) 30 #endif // defined(OS_WIN)
31 #if defined(OS_LINUX) 31 #if defined(OS_LINUX)
32 REFRESH_TYPE_FD_COUNT | 32 REFRESH_TYPE_FD_COUNT |
33 #endif // defined(OS_LINUX) 33 #endif // defined(OS_LINUX)
34 REFRESH_TYPE_NACL ||
35 REFRESH_TYPE_PRIORITY; 34 REFRESH_TYPE_PRIORITY;
36 35
37 #if defined(OS_WIN) 36 #if defined(OS_WIN)
38 // Gets the GDI and USER Handles on Windows at one shot. 37 // Gets the GDI and USER Handles on Windows at one shot.
39 void GetWindowsHandles(base::ProcessHandle handle, 38 void GetWindowsHandles(base::ProcessHandle handle,
40 int64_t* out_gdi_current, 39 int64_t* out_gdi_current,
41 int64_t* out_gdi_peak, 40 int64_t* out_gdi_peak,
42 int64_t* out_user_current, 41 int64_t* out_user_current,
43 int64_t* out_user_peak) { 42 int64_t* out_user_peak) {
44 *out_gdi_current = 0; 43 *out_gdi_current = 0;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 169 }
171 170
172 // 3- Refresh Windows handles (if enabled). 171 // 3- Refresh Windows handles (if enabled).
173 #if defined(OS_WIN) 172 #if defined(OS_WIN)
174 if (TaskManagerObserver::IsResourceRefreshEnabled(REFRESH_TYPE_HANDLES, 173 if (TaskManagerObserver::IsResourceRefreshEnabled(REFRESH_TYPE_HANDLES,
175 refresh_flags)) { 174 refresh_flags)) {
176 RefreshWindowsHandles(); 175 RefreshWindowsHandles();
177 } 176 }
178 #endif // defined(OS_WIN) 177 #endif // defined(OS_WIN)
179 178
180 // 4- Refresh the NACL debug stub port (if enabled). This calls out to 179 // 4- Refresh the NACL debug stub port (if enabled).
181 // NaClBrowser on the browser's IO thread, completing asynchronously.
182 #if !defined(DISABLE_NACL) 180 #if !defined(DISABLE_NACL)
183 if (TaskManagerObserver::IsResourceRefreshEnabled(REFRESH_TYPE_NACL, 181 if (TaskManagerObserver::IsResourceRefreshEnabled(REFRESH_TYPE_NACL,
184 refresh_flags) && 182 refresh_flags) &&
185 !tasks_.empty()) { 183 !tasks_.empty()) {
186 RefreshNaClDebugStubPort(tasks_[0]->GetChildProcessUniqueID()); 184 RefreshNaClDebugStubPort(tasks_[0]->GetChildProcessUniqueID());
187 } 185 }
188 #endif // !defined(DISABLE_NACL) 186 #endif // !defined(DISABLE_NACL)
189 187
190 int64_t shared_refresh_flags = 188 int64_t shared_refresh_flags =
191 refresh_flags & shared_sampler_->GetSupportedFlags(); 189 refresh_flags & shared_sampler_->GetSupportedFlags();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 void TaskGroup::RefreshWindowsHandles() { 248 void TaskGroup::RefreshWindowsHandles() {
251 #if defined(OS_WIN) 249 #if defined(OS_WIN)
252 GetWindowsHandles(process_handle_, 250 GetWindowsHandles(process_handle_,
253 &gdi_current_handles_, 251 &gdi_current_handles_,
254 &gdi_peak_handles_, 252 &gdi_peak_handles_,
255 &user_current_handles_, 253 &user_current_handles_,
256 &user_peak_handles_); 254 &user_peak_handles_);
257 #endif // defined(OS_WIN) 255 #endif // defined(OS_WIN)
258 } 256 }
259 257
258 void TaskGroup::RefreshNaClDebugStubPort(int child_process_unique_id) {
260 #if !defined(DISABLE_NACL) 259 #if !defined(DISABLE_NACL)
261 void TaskGroup::RefreshNaClDebugStubPort(int child_process_unique_id) {
262 nacl::NaClBrowser* nacl_browser = nacl::NaClBrowser::GetInstance(); 260 nacl::NaClBrowser* nacl_browser = nacl::NaClBrowser::GetInstance();
263 content::BrowserThread::PostTaskAndReplyWithResult( 261 nacl_debug_stub_port_ =
264 content::BrowserThread::IO, FROM_HERE, 262 nacl_browser->GetProcessGdbDebugStubPort(child_process_unique_id);
265 base::Bind(&nacl::NaClBrowser::GetProcessGdbDebugStubPort, 263 #endif // !defined(DISABLE_NACL)
266 base::Unretained(nacl_browser), child_process_unique_id),
267 base::Bind(&TaskGroup::OnRefreshNaClDebugStubPortDone,
268 weak_ptr_factory_.GetWeakPtr()));
269 } 264 }
270 265
271 void TaskGroup::OnRefreshNaClDebugStubPortDone(int nacl_debug_stub_port) {
272 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
273
274 nacl_debug_stub_port_ = nacl_debug_stub_port;
275 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_NACL);
276 }
277 #endif // !defined(DISABLE_NACL)
278
279 void TaskGroup::OnCpuRefreshDone(double cpu_usage) { 266 void TaskGroup::OnCpuRefreshDone(double cpu_usage) {
280 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 267 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
281 268
282 cpu_usage_ = cpu_usage; 269 cpu_usage_ = cpu_usage;
283 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_CPU); 270 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_CPU);
284 } 271 }
285 272
286 void TaskGroup::OnStartTimeRefreshDone(base::Time start_time) { 273 void TaskGroup::OnStartTimeRefreshDone(base::Time start_time) {
287 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 274 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
288 275
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 331
345 void TaskGroup::OnBackgroundRefreshTypeFinished(int64_t finished_refresh_type) { 332 void TaskGroup::OnBackgroundRefreshTypeFinished(int64_t finished_refresh_type) {
346 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 333 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
347 334
348 current_on_bg_done_flags_ |= finished_refresh_type; 335 current_on_bg_done_flags_ |= finished_refresh_type;
349 if (AreBackgroundCalculationsDone()) 336 if (AreBackgroundCalculationsDone())
350 on_background_calculations_done_.Run(); 337 on_background_calculations_done_.Run();
351 } 338 }
352 339
353 } // namespace task_manager 340 } // namespace task_manager
OLDNEW
« no previous file with comments | « chrome/browser/task_manager/sampling/task_group.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698