Chromium Code Reviews| Index: chrome/browser/task_manager/sampling/task_group.cc |
| diff --git a/chrome/browser/task_manager/sampling/task_group.cc b/chrome/browser/task_manager/sampling/task_group.cc |
| index a7a0d11116ec0b15b4f361873cfdc146174b294e..4cb387ab5f2f9974a08450ad8dfcecada9fe14ef 100644 |
| --- a/chrome/browser/task_manager/sampling/task_group.cc |
| +++ b/chrome/browser/task_manager/sampling/task_group.cc |
| @@ -31,7 +31,7 @@ const int kBackgroundRefreshTypesMask = |
| #if defined(OS_LINUX) |
| REFRESH_TYPE_FD_COUNT | |
| #endif // defined(OS_LINUX) |
| - REFRESH_TYPE_PRIORITY; |
| + REFRESH_TYPE_NACL | REFRESH_TYPE_PRIORITY; |
|
afakhry
2017/02/10 20:08:52
You still need to wrap REFRESH_TYPE_NACL inside:
Wez
2017/02/13 01:22:19
Done.
|
| #if defined(OS_WIN) |
| // Gets the GDI and USER Handles on Windows at one shot. |
| @@ -89,7 +89,7 @@ TaskGroup::TaskGroup( |
| user_peak_handles_(-1), |
| #endif // defined(OS_WIN) |
| #if !defined(DISABLE_NACL) |
| - nacl_debug_stub_port_(-1), |
| + nacl_debug_stub_port_(nacl::kGdbDebugStubPortUnknown), |
| #endif // !defined(DISABLE_NACL) |
| idle_wakeups_per_second_(-1), |
| #if defined(OS_LINUX) |
| @@ -176,12 +176,16 @@ void TaskGroup::Refresh(const gpu::VideoMemoryUsageStats& gpu_memory_stats, |
| } |
| #endif // defined(OS_WIN) |
| - // 4- Refresh the NACL debug stub port (if enabled). |
| +// 4- Refresh the NACL debug stub port (if enabled). This calls out to |
| +// NaClBrowser on the browser's IO thread, completing asynchronously. |
| #if !defined(DISABLE_NACL) |
| if (TaskManagerObserver::IsResourceRefreshEnabled(REFRESH_TYPE_NACL, |
| - refresh_flags) && |
| - !tasks_.empty()) { |
| - RefreshNaClDebugStubPort(tasks_[0]->GetChildProcessUniqueID()); |
| + refresh_flags)) { |
| + if (!tasks_.empty()) { |
| + RefreshNaClDebugStubPort(tasks_[0]->GetChildProcessUniqueID()); |
| + } else { |
| + expected_on_bg_done_flags_ &= ~REFRESH_TYPE_NACL; |
|
afakhry
2017/02/10 20:08:52
Thanks for adding this!
Nit: Can you please remov
Wez
2017/02/13 01:22:19
I thought there was a general preference for inclu
afakhry
2017/02/15 02:58:19
That shouldn't happen (See my comment on the unitt
Wez
2017/02/16 22:44:19
Looking at TaskManagerImpl, it's clear that TaskGr
|
| + } |
| } |
| #endif // !defined(DISABLE_NACL) |
| @@ -255,14 +259,28 @@ void TaskGroup::RefreshWindowsHandles() { |
| #endif // defined(OS_WIN) |
| } |
| -void TaskGroup::RefreshNaClDebugStubPort(int child_process_unique_id) { |
| #if !defined(DISABLE_NACL) |
| - nacl::NaClBrowser* nacl_browser = nacl::NaClBrowser::GetInstance(); |
| - nacl_debug_stub_port_ = |
| - nacl_browser->GetProcessGdbDebugStubPort(child_process_unique_id); |
| -#endif // !defined(DISABLE_NACL) |
| +static int GetNaClDebugStubPortOnIoThread(int process_id) { |
|
afakhry
2017/02/10 20:08:52
No DCHECK for IO?
Ideally the DCHECK should be pl
Wez
2017/02/13 01:22:19
Yes, that's the change that prompted this patch, i
afakhry
2017/02/15 02:58:19
Acknowledged.
|
| + return nacl::NaClBrowser::GetInstance()->GetProcessGdbDebugStubPort( |
| + process_id); |
| } |
| +void TaskGroup::RefreshNaClDebugStubPort(int child_process_unique_id) { |
| + content::BrowserThread::PostTaskAndReplyWithResult( |
| + content::BrowserThread::IO, FROM_HERE, |
| + base::Bind(&GetNaClDebugStubPortOnIoThread, child_process_unique_id), |
| + base::Bind(&TaskGroup::OnRefreshNaClDebugStubPortDone, |
| + weak_ptr_factory_.GetWeakPtr())); |
| +} |
| + |
| +void TaskGroup::OnRefreshNaClDebugStubPortDone(int nacl_debug_stub_port) { |
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| + |
| + nacl_debug_stub_port_ = nacl_debug_stub_port; |
| + OnBackgroundRefreshTypeFinished(REFRESH_TYPE_NACL); |
| +} |
| +#endif // !defined(DISABLE_NACL) |
| + |
| void TaskGroup::OnCpuRefreshDone(double cpu_usage) { |
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |