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

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

Issue 2646623004: 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 | « no previous file | 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"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 refresh_flags)) { 175 refresh_flags)) {
176 RefreshWindowsHandles(); 176 RefreshWindowsHandles();
177 } 177 }
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 nacl_debug_stub_port_ == nacl::kGdbDebugStubPortUnknown &&
Wez 2017/01/20 03:25:28 bradnelson: I thought of adding this, but I think
185 !tasks_.empty()) { 186 !tasks_.empty()) {
186 RefreshNaClDebugStubPort(tasks_[0]->GetChildProcessUniqueID()); 187 RefreshNaClDebugStubPort(tasks_[0]->GetChildProcessUniqueID());
187 } 188 }
188 #endif // !defined(DISABLE_NACL) 189 #endif // !defined(DISABLE_NACL)
189 190
190 int64_t shared_refresh_flags = 191 int64_t shared_refresh_flags =
191 refresh_flags & shared_sampler_->GetSupportedFlags(); 192 refresh_flags & shared_sampler_->GetSupportedFlags();
192 193
193 // 5- Refresh resources via SharedSampler if the current platform 194 // 5- Refresh resources via SharedSampler if the current platform
194 // implementation supports that. The actual work is done on the worker thread. 195 // implementation supports that. The actual work is done on the worker thread.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 #if defined(OS_WIN) 252 #if defined(OS_WIN)
252 GetWindowsHandles(process_handle_, 253 GetWindowsHandles(process_handle_,
253 &gdi_current_handles_, 254 &gdi_current_handles_,
254 &gdi_peak_handles_, 255 &gdi_peak_handles_,
255 &user_current_handles_, 256 &user_current_handles_,
256 &user_peak_handles_); 257 &user_peak_handles_);
257 #endif // defined(OS_WIN) 258 #endif // defined(OS_WIN)
258 } 259 }
259 260
260 #if !defined(DISABLE_NACL) 261 #if !defined(DISABLE_NACL)
262 static int GetNaClDebugStubPort(int process_id) {
263 return nacl::NaClBrowser::GetInstance()->GetProcessGdbDebugStubPort(
264 process_id);
265 }
266
261 void TaskGroup::RefreshNaClDebugStubPort(int child_process_unique_id) { 267 void TaskGroup::RefreshNaClDebugStubPort(int child_process_unique_id) {
262 nacl::NaClBrowser* nacl_browser = nacl::NaClBrowser::GetInstance();
263 content::BrowserThread::PostTaskAndReplyWithResult( 268 content::BrowserThread::PostTaskAndReplyWithResult(
264 content::BrowserThread::IO, FROM_HERE, 269 content::BrowserThread::IO, FROM_HERE,
265 base::Bind(&nacl::NaClBrowser::GetProcessGdbDebugStubPort, 270 base::Bind(&GetNaClDebugStubPort, child_process_unique_id),
266 base::Unretained(nacl_browser), child_process_unique_id),
267 base::Bind(&TaskGroup::OnRefreshNaClDebugStubPortDone, 271 base::Bind(&TaskGroup::OnRefreshNaClDebugStubPortDone,
268 weak_ptr_factory_.GetWeakPtr())); 272 weak_ptr_factory_.GetWeakPtr()));
269 } 273 }
270 274
271 void TaskGroup::OnRefreshNaClDebugStubPortDone(int nacl_debug_stub_port) { 275 void TaskGroup::OnRefreshNaClDebugStubPortDone(int nacl_debug_stub_port) {
272 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 276 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
273 277
274 nacl_debug_stub_port_ = nacl_debug_stub_port; 278 nacl_debug_stub_port_ = nacl_debug_stub_port;
275 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_NACL); 279 OnBackgroundRefreshTypeFinished(REFRESH_TYPE_NACL);
276 } 280 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 348
345 void TaskGroup::OnBackgroundRefreshTypeFinished(int64_t finished_refresh_type) { 349 void TaskGroup::OnBackgroundRefreshTypeFinished(int64_t finished_refresh_type) {
346 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 350 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
347 351
348 current_on_bg_done_flags_ |= finished_refresh_type; 352 current_on_bg_done_flags_ |= finished_refresh_type;
349 if (AreBackgroundCalculationsDone()) 353 if (AreBackgroundCalculationsDone())
350 on_background_calculations_done_.Run(); 354 on_background_calculations_done_.Run();
351 } 355 }
352 356
353 } // namespace task_manager 357 } // namespace task_manager
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698