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" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 return; | 55 return; |
56 } | 56 } |
57 | 57 |
58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
59 if (subscriber_) { | 59 if (subscriber_) { |
60 subscriber_->OnProfilerDataCollected(sequence_number, profiler_data, | 60 subscriber_->OnProfilerDataCollected(sequence_number, profiler_data, |
61 process_type); | 61 process_type); |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
| 65 #if defined(USE_TCMALLOC) |
| 66 void ProfilerControllerImpl::OnTcmallocStatsCollected( |
| 67 base::ProcessId pid, |
| 68 ProcessType process_type, |
| 69 const std::string& output) { |
| 70 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 71 BrowserThread::PostTask( |
| 72 BrowserThread::UI, FROM_HERE, |
| 73 base::Bind(&ProfilerControllerImpl::OnTcmallocStatsCollected, |
| 74 base::Unretained(this), |
| 75 pid, |
| 76 process_type, |
| 77 output)); |
| 78 return; |
| 79 } |
| 80 |
| 81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 82 if (subscriber_) |
| 83 subscriber_->OnTcmallocStatsCollected(pid, process_type, output); |
| 84 } |
| 85 #endif |
| 86 |
65 void ProfilerControllerImpl::Register(ProfilerSubscriber* subscriber) { | 87 void ProfilerControllerImpl::Register(ProfilerSubscriber* subscriber) { |
66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
67 DCHECK(!subscriber_); | 89 DCHECK(!subscriber_); |
68 subscriber_ = subscriber; | 90 subscriber_ = subscriber; |
69 } | 91 } |
70 | 92 |
71 void ProfilerControllerImpl::Unregister(const ProfilerSubscriber* subscriber) { | 93 void ProfilerControllerImpl::Unregister(const ProfilerSubscriber* subscriber) { |
72 DCHECK_EQ(subscriber_, subscriber); | 94 DCHECK_EQ(subscriber_, subscriber); |
73 subscriber_ = NULL; | 95 subscriber_ = NULL; |
74 } | 96 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 133 |
112 BrowserThread::PostTask( | 134 BrowserThread::PostTask( |
113 BrowserThread::IO, | 135 BrowserThread::IO, |
114 FROM_HERE, | 136 FROM_HERE, |
115 base::Bind(&ProfilerControllerImpl::GetProfilerDataFromChildProcesses, | 137 base::Bind(&ProfilerControllerImpl::GetProfilerDataFromChildProcesses, |
116 base::Unretained(this), | 138 base::Unretained(this), |
117 sequence_number)); | 139 sequence_number)); |
118 } | 140 } |
119 | 141 |
120 } // namespace content | 142 } // namespace content |
OLD | NEW |