Chromium Code Reviews| 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/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" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 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 || | 34 REFRESH_TYPE_NACL || |
|
Wez
2017/01/23 19:21:02
Ick, I think this indentation got messed-up by git
Wez
2017/01/23 19:44:27
OK, worse than that, the indentation is missed up
| |
| 35 REFRESH_TYPE_PRIORITY; | 35 REFRESH_TYPE_PRIORITY; |
| 36 | 36 |
| 37 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
| 38 // Gets the GDI and USER Handles on Windows at one shot. | 38 // Gets the GDI and USER Handles on Windows at one shot. |
| 39 void GetWindowsHandles(base::ProcessHandle handle, | 39 void GetWindowsHandles(base::ProcessHandle handle, |
| 40 int64_t* out_gdi_current, | 40 int64_t* out_gdi_current, |
| 41 int64_t* out_gdi_peak, | 41 int64_t* out_gdi_peak, |
| 42 int64_t* out_user_current, | 42 int64_t* out_user_current, |
| 43 int64_t* out_user_peak) { | 43 int64_t* out_user_peak) { |
| 44 *out_gdi_current = 0; | 44 *out_gdi_current = 0; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 gpu_memory_(-1), | 83 gpu_memory_(-1), |
| 84 memory_state_(base::MemoryState::UNKNOWN), | 84 memory_state_(base::MemoryState::UNKNOWN), |
| 85 per_process_network_usage_(-1), | 85 per_process_network_usage_(-1), |
| 86 #if defined(OS_WIN) | 86 #if defined(OS_WIN) |
| 87 gdi_current_handles_(-1), | 87 gdi_current_handles_(-1), |
| 88 gdi_peak_handles_(-1), | 88 gdi_peak_handles_(-1), |
| 89 user_current_handles_(-1), | 89 user_current_handles_(-1), |
| 90 user_peak_handles_(-1), | 90 user_peak_handles_(-1), |
| 91 #endif // defined(OS_WIN) | 91 #endif // defined(OS_WIN) |
| 92 #if !defined(DISABLE_NACL) | 92 #if !defined(DISABLE_NACL) |
| 93 nacl_debug_stub_port_(-1), | 93 nacl_debug_stub_port_(nacl::kGdbDebugStubPortUnknown), |
| 94 #endif // !defined(DISABLE_NACL) | 94 #endif // !defined(DISABLE_NACL) |
| 95 idle_wakeups_per_second_(-1), | 95 idle_wakeups_per_second_(-1), |
| 96 #if defined(OS_LINUX) | 96 #if defined(OS_LINUX) |
| 97 open_fd_count_(-1), | 97 open_fd_count_(-1), |
| 98 #endif // defined(OS_LINUX) | 98 #endif // defined(OS_LINUX) |
| 99 gpu_memory_has_duplicates_(false), | 99 gpu_memory_has_duplicates_(false), |
| 100 is_backgrounded_(false), | 100 is_backgrounded_(false), |
| 101 weak_ptr_factory_(this) { | 101 weak_ptr_factory_(this) { |
| 102 scoped_refptr<TaskGroupSampler> sampler( | 102 scoped_refptr<TaskGroupSampler> sampler( |
| 103 new TaskGroupSampler(base::Process::Open(proc_id), | 103 new TaskGroupSampler(base::Process::Open(proc_id), |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 #endif // defined(OS_WIN) | 178 #endif // defined(OS_WIN) |
| 179 | 179 |
| 180 // 4- Refresh the NACL debug stub port (if enabled). This calls out to | 180 // 4- Refresh the NACL debug stub port (if enabled). This calls out to |
| 181 // NaClBrowser on the browser's IO thread, completing asynchronously. | 181 // NaClBrowser on the browser's IO thread, completing asynchronously. |
| 182 #if !defined(DISABLE_NACL) | 182 #if !defined(DISABLE_NACL) |
| 183 if (TaskManagerObserver::IsResourceRefreshEnabled(REFRESH_TYPE_NACL, | 183 if (TaskManagerObserver::IsResourceRefreshEnabled(REFRESH_TYPE_NACL, |
| 184 refresh_flags) && | 184 refresh_flags) && |
| 185 !tasks_.empty()) { | 185 !tasks_.empty()) { |
| 186 RefreshNaClDebugStubPort(tasks_[0]->GetChildProcessUniqueID()); | 186 RefreshNaClDebugStubPort(tasks_[0]->GetChildProcessUniqueID()); |
| 187 } | 187 } |
| 188 #endif // !defined(DISABLE_NACL) | 188 #endif // !defined(DISABLE_NACL) |
|
Wez
2017/01/23 19:21:02
nit: REFRESH_TYPE_NACL exists even in DISABLE_NACL
afakhry
2017/02/09 01:26:59
We just used to ignore it since it used to be perf
Wez
2017/02/10 02:51:56
Acknowledged.
| |
| 189 | 189 |
| 190 int64_t shared_refresh_flags = | 190 int64_t shared_refresh_flags = |
| 191 refresh_flags & shared_sampler_->GetSupportedFlags(); | 191 refresh_flags & shared_sampler_->GetSupportedFlags(); |
| 192 | 192 |
| 193 // 5- Refresh resources via SharedSampler if the current platform | 193 // 5- Refresh resources via SharedSampler if the current platform |
| 194 // implementation supports that. The actual work is done on the worker thread. | 194 // implementation supports that. The actual work is done on the worker thread. |
| 195 // At the moment this is supported only on OS_WIN. | 195 // At the moment this is supported only on OS_WIN. |
| 196 if (shared_refresh_flags != 0) { | 196 if (shared_refresh_flags != 0) { |
| 197 shared_sampler_->Refresh(process_id_, shared_refresh_flags); | 197 shared_sampler_->Refresh(process_id_, shared_refresh_flags); |
| 198 refresh_flags &= ~shared_refresh_flags; | 198 refresh_flags &= ~shared_refresh_flags; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 #if defined(OS_WIN) | 251 #if defined(OS_WIN) |
| 252 GetWindowsHandles(process_handle_, | 252 GetWindowsHandles(process_handle_, |
| 253 &gdi_current_handles_, | 253 &gdi_current_handles_, |
| 254 &gdi_peak_handles_, | 254 &gdi_peak_handles_, |
| 255 &user_current_handles_, | 255 &user_current_handles_, |
| 256 &user_peak_handles_); | 256 &user_peak_handles_); |
| 257 #endif // defined(OS_WIN) | 257 #endif // defined(OS_WIN) |
| 258 } | 258 } |
| 259 | 259 |
| 260 #if !defined(DISABLE_NACL) | 260 #if !defined(DISABLE_NACL) |
| 261 static int GetNaClDebugStubPortOnIoThread(int process_id) { | |
| 262 return nacl::NaClBrowser::GetInstance()->GetProcessGdbDebugStubPort( | |
| 263 process_id); | |
| 264 } | |
| 265 | |
| 261 void TaskGroup::RefreshNaClDebugStubPort(int child_process_unique_id) { | 266 void TaskGroup::RefreshNaClDebugStubPort(int child_process_unique_id) { |
| 262 nacl::NaClBrowser* nacl_browser = nacl::NaClBrowser::GetInstance(); | |
| 263 content::BrowserThread::PostTaskAndReplyWithResult( | 267 content::BrowserThread::PostTaskAndReplyWithResult( |
| 264 content::BrowserThread::IO, FROM_HERE, | 268 content::BrowserThread::IO, FROM_HERE, |
| 265 base::Bind(&nacl::NaClBrowser::GetProcessGdbDebugStubPort, | 269 base::Bind(&GetNaClDebugStubPortOnIoThread, child_process_unique_id), |
| 266 base::Unretained(nacl_browser), child_process_unique_id), | |
| 267 base::Bind(&TaskGroup::OnRefreshNaClDebugStubPortDone, | 270 base::Bind(&TaskGroup::OnRefreshNaClDebugStubPortDone, |
| 268 weak_ptr_factory_.GetWeakPtr())); | 271 weak_ptr_factory_.GetWeakPtr())); |
| 269 } | 272 } |
| 270 | 273 |
| 271 void TaskGroup::OnRefreshNaClDebugStubPortDone(int nacl_debug_stub_port) { | 274 void TaskGroup::OnRefreshNaClDebugStubPortDone(int nacl_debug_stub_port) { |
| 272 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 275 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 273 | 276 |
| 274 nacl_debug_stub_port_ = nacl_debug_stub_port; | 277 nacl_debug_stub_port_ = nacl_debug_stub_port; |
| 275 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_NACL); | 278 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_NACL); |
| 276 } | 279 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 | 347 |
| 345 void TaskGroup::OnBackgroundRefreshTypeFinished(int64_t finished_refresh_type) { | 348 void TaskGroup::OnBackgroundRefreshTypeFinished(int64_t finished_refresh_type) { |
| 346 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 349 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 347 | 350 |
| 348 current_on_bg_done_flags_ |= finished_refresh_type; | 351 current_on_bg_done_flags_ |= finished_refresh_type; |
| 349 if (AreBackgroundCalculationsDone()) | 352 if (AreBackgroundCalculationsDone()) |
| 350 on_background_calculations_done_.Run(); | 353 on_background_calculations_done_.Run(); |
| 351 } | 354 } |
| 352 | 355 |
| 353 } // namespace task_manager | 356 } // namespace task_manager |
| OLD | NEW |