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

Side by Side Diff: content/browser/profiler_controller.cc

Issue 8588023: Collect profiler stats from browser child processes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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 | Annotate | Revision Log
Property Changes:
Added: svn:executable
+ *
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
jam 2011/11/30 00:22:25 this stuff should really be in profiler_controller
ramant (doing other things) 2011/11/30 19:37:21 Done.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/public/browser/profiler_controller.h"
6
7 #include "base/bind.h"
8 #include "content/browser/browser_child_process_host.h"
9 #include "content/browser/profiler_controller_impl.h"
10 #include "content/common/child_process_info.h"
11 #include "content/common/child_process_messages.h"
12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/render_process_host.h"
14
15 namespace content {
16
17 // static
18 void GetProfilerDataFromChildProcesses(int sequence_number) {
19 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
20
21 int pending_processes = 0;
22 for (BrowserChildProcessHost::Iterator child_process_host;
23 !child_process_host.Done(); ++child_process_host) {
24 const std::string process_type =
25 ChildProcessInfo::GetTypeNameInEnglish(child_process_host->type());
26
27 ++pending_processes;
28 if (!child_process_host->Send(new ChildProcessMsg_GetChildProfilerData(
29 sequence_number, process_type))) {
30 --pending_processes;
31 }
32 }
33
34 BrowserThread::PostTask(
35 BrowserThread::UI,
36 FROM_HERE,
37 base::Bind(
38 &ProfilerControllerImpl::OnPendingProcesses,
39 base::Unretained(content::ProfilerControllerImpl::GetInstance()),
40 sequence_number,
41 pending_processes));
42 }
43
44 // static
45 int GetProfilerData(int sequence_number) {
46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
47
48 BrowserThread::PostTask(
49 BrowserThread::IO,
50 FROM_HERE,
51 base::Bind(&GetProfilerDataFromChildProcesses, sequence_number));
52
53 int pending_processes = 0;
54 const std::string render_process_type =
55 ChildProcessInfo::GetTypeNameInEnglish(ChildProcessInfo::RENDER_PROCESS);
56
57 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
58 !it.IsAtEnd(); it.Advance()) {
59 ++pending_processes;
60 if (!it.GetCurrentValue()->Send(new ChildProcessMsg_GetChildProfilerData(
61 sequence_number, render_process_type))) {
62 --pending_processes;
63 }
64 }
65
66 content::ProfilerControllerImpl::GetInstance()->OnPendingProcesses(
67 sequence_number, pending_processes);
68
69 // Returns 2 to indicate that OnPendingProcesses will be called once for
70 // renderer processes and another for browser child processes.
71 return 2;
72 }
73
74 // static
75 void SetProfilerStatusInChildProcesses(bool enable) {
76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
77
78 for (BrowserChildProcessHost::Iterator child_process_host;
79 !child_process_host.Done(); ++child_process_host) {
80 child_process_host->Send(new ChildProcessMsg_SetProfilerStatus(enable));
81 }
82 }
83
84 // static
85 void SetProfilerStatus(bool enable) {
86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
87
88 BrowserThread::PostTask(
89 BrowserThread::IO,
90 FROM_HERE,
91 base::Bind(
92 &SetProfilerStatusInChildProcesses, enable));
93
94 for (content::RenderProcessHost::iterator it(
95 content::RenderProcessHost::AllHostsIterator());
96 !it.IsAtEnd(); it.Advance()) {
97 it.GetCurrentValue()->Send(new ChildProcessMsg_SetProfilerStatus(enable));
98 }
99 }
100 } // content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698