OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/profiler_controller_impl.h" | 5 #include "content/browser/profiler_controller_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/tracked_objects.h" | 8 #include "base/tracked_objects.h" |
9 #include "content/common/child_process_messages.h" | 9 #include "content/common/child_process_messages.h" |
10 #include "content/public/browser/browser_child_process_host_iterator.h" | 10 #include "content/public/browser/browser_child_process_host_iterator.h" |
11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
12 #include "content/public/browser/child_process_data.h" | 12 #include "content/public/browser/child_process_data.h" |
13 #include "content/public/browser/profiler_subscriber.h" | 13 #include "content/public/browser/profiler_subscriber.h" |
14 #include "content/public/browser/render_process_host.h" | 14 #include "content/public/browser/render_process_host.h" |
15 | 15 |
16 using content::BrowserChildProcessHostIterator; | |
17 using content::BrowserThread; | |
18 | |
19 namespace content { | 16 namespace content { |
20 | 17 |
21 content::ProfilerController* content::ProfilerController::GetInstance() { | 18 ProfilerController* ProfilerController::GetInstance() { |
22 return ProfilerControllerImpl::GetInstance(); | 19 return ProfilerControllerImpl::GetInstance(); |
23 } | 20 } |
24 | 21 |
25 ProfilerControllerImpl* ProfilerControllerImpl::GetInstance() { | 22 ProfilerControllerImpl* ProfilerControllerImpl::GetInstance() { |
26 return Singleton<ProfilerControllerImpl>::get(); | 23 return Singleton<ProfilerControllerImpl>::get(); |
27 } | 24 } |
28 | 25 |
29 ProfilerControllerImpl::ProfilerControllerImpl() : subscriber_(NULL) { | 26 ProfilerControllerImpl::ProfilerControllerImpl() : subscriber_(NULL) { |
30 } | 27 } |
31 | 28 |
32 ProfilerControllerImpl::~ProfilerControllerImpl() { | 29 ProfilerControllerImpl::~ProfilerControllerImpl() { |
33 } | 30 } |
34 | 31 |
35 void ProfilerControllerImpl::OnPendingProcesses(int sequence_number, | 32 void ProfilerControllerImpl::OnPendingProcesses(int sequence_number, |
36 int pending_processes, | 33 int pending_processes, |
37 bool end) { | 34 bool end) { |
38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
39 if (subscriber_) | 36 if (subscriber_) |
40 subscriber_->OnPendingProcesses(sequence_number, pending_processes, end); | 37 subscriber_->OnPendingProcesses(sequence_number, pending_processes, end); |
41 } | 38 } |
42 | 39 |
43 void ProfilerControllerImpl::OnProfilerDataCollected( | 40 void ProfilerControllerImpl::OnProfilerDataCollected( |
44 int sequence_number, | 41 int sequence_number, |
45 const tracked_objects::ProcessDataSnapshot& profiler_data, | 42 const tracked_objects::ProcessDataSnapshot& profiler_data, |
46 content::ProcessType process_type) { | 43 ProcessType process_type) { |
47 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 44 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
48 BrowserThread::PostTask( | 45 BrowserThread::PostTask( |
49 BrowserThread::UI, FROM_HERE, | 46 BrowserThread::UI, FROM_HERE, |
50 base::Bind(&ProfilerControllerImpl::OnProfilerDataCollected, | 47 base::Bind(&ProfilerControllerImpl::OnProfilerDataCollected, |
51 base::Unretained(this), | 48 base::Unretained(this), |
52 sequence_number, | 49 sequence_number, |
53 profiler_data, | 50 profiler_data, |
54 process_type)); | 51 process_type)); |
55 return; | 52 return; |
56 } | 53 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 108 |
112 BrowserThread::PostTask( | 109 BrowserThread::PostTask( |
113 BrowserThread::IO, | 110 BrowserThread::IO, |
114 FROM_HERE, | 111 FROM_HERE, |
115 base::Bind(&ProfilerControllerImpl::GetProfilerDataFromChildProcesses, | 112 base::Bind(&ProfilerControllerImpl::GetProfilerDataFromChildProcesses, |
116 base::Unretained(this), | 113 base::Unretained(this), |
117 sequence_number)); | 114 sequence_number)); |
118 } | 115 } |
119 | 116 |
120 } // namespace content | 117 } // namespace content |
OLD | NEW |