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/tracing/trace_controller_impl.h" | 5 #include "content/browser/tracing/trace_controller_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 // Enable tracing | 131 // Enable tracing |
132 TraceLog::GetInstance()->SetEnabled(included_categories, excluded_categories); | 132 TraceLog::GetInstance()->SetEnabled(included_categories, excluded_categories); |
133 OnTracingBegan(subscriber); | 133 OnTracingBegan(subscriber); |
134 | 134 |
135 return true; | 135 return true; |
136 } | 136 } |
137 | 137 |
138 bool TraceControllerImpl::BeginTracing(TraceSubscriber* subscriber, | 138 bool TraceControllerImpl::BeginTracing(TraceSubscriber* subscriber, |
139 const std::string& categories) { | 139 const std::string& categories) { |
| 140 return BeginTracing(subscriber, categories, false); |
| 141 } |
| 142 |
| 143 bool TraceControllerImpl::BeginTracing(TraceSubscriber* subscriber, |
| 144 const std::string& categories, |
| 145 bool continuous_tracing) { |
140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
141 | 147 |
142 if (!can_begin_tracing(subscriber)) | 148 if (!can_begin_tracing(subscriber)) |
143 return false; | 149 return false; |
144 | 150 |
145 // Enable tracing | 151 // Enable tracing |
146 TraceLog::GetInstance()->SetEnabled(categories); | 152 TraceLog::GetInstance()->SetEnabled(categories); |
| 153 TraceLog::GetInstance()->SetContinuousTracing(continuous_tracing); |
147 | 154 |
148 OnTracingBegan(subscriber); | 155 OnTracingBegan(subscriber); |
149 | 156 |
150 return true; | 157 return true; |
151 } | 158 } |
152 | 159 |
153 bool TraceControllerImpl::EndTracingAsync(TraceSubscriber* subscriber) { | 160 bool TraceControllerImpl::EndTracingAsync(TraceSubscriber* subscriber) { |
154 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 161 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
155 | 162 |
156 if (!can_end_tracing() || subscriber != subscriber_) | 163 if (!can_end_tracing() || subscriber != subscriber_) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 void TraceControllerImpl::AddFilter(TraceMessageFilter* filter) { | 261 void TraceControllerImpl::AddFilter(TraceMessageFilter* filter) { |
255 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 262 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
256 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 263 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
257 base::Bind(&TraceControllerImpl::AddFilter, base::Unretained(this), | 264 base::Bind(&TraceControllerImpl::AddFilter, base::Unretained(this), |
258 make_scoped_refptr(filter))); | 265 make_scoped_refptr(filter))); |
259 return; | 266 return; |
260 } | 267 } |
261 | 268 |
262 filters_.insert(filter); | 269 filters_.insert(filter); |
263 if (is_tracing_enabled()) { | 270 if (is_tracing_enabled()) { |
264 filter->SendBeginTracing(included_categories_, excluded_categories_); | 271 filter->SendBeginTracing(included_categories_, excluded_categories_, |
| 272 continuous_tracing_); |
265 if (!watch_category_.empty()) | 273 if (!watch_category_.empty()) |
266 filter->SendSetWatchEvent(watch_category_, watch_name_); | 274 filter->SendSetWatchEvent(watch_category_, watch_name_); |
267 } | 275 } |
268 } | 276 } |
269 | 277 |
270 void TraceControllerImpl::RemoveFilter(TraceMessageFilter* filter) { | 278 void TraceControllerImpl::RemoveFilter(TraceMessageFilter* filter) { |
271 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 279 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
272 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 280 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
273 base::Bind(&TraceControllerImpl::RemoveFilter, base::Unretained(this), | 281 base::Bind(&TraceControllerImpl::RemoveFilter, base::Unretained(this), |
274 make_scoped_refptr(filter))); | 282 make_scoped_refptr(filter))); |
275 return; | 283 return; |
276 } | 284 } |
277 | 285 |
278 filters_.erase(filter); | 286 filters_.erase(filter); |
279 } | 287 } |
280 | 288 |
281 void TraceControllerImpl::OnTracingBegan(TraceSubscriber* subscriber) { | 289 void TraceControllerImpl::OnTracingBegan(TraceSubscriber* subscriber) { |
282 is_tracing_ = true; | 290 is_tracing_ = true; |
283 | 291 |
284 subscriber_ = subscriber; | 292 subscriber_ = subscriber; |
285 | 293 |
286 TraceLog::GetInstance()->GetEnabledTraceCategories(&included_categories_, | 294 TraceLog::GetInstance()->GetEnabledTraceCategories(&included_categories_, |
287 &excluded_categories_); | 295 &excluded_categories_); |
| 296 continuous_tracing_ = TraceLog::GetInstance()->GetContinuousTracing(); |
| 297 |
288 // Notify all child processes. | 298 // Notify all child processes. |
289 for (FilterMap::iterator it = filters_.begin(); it != filters_.end(); ++it) { | 299 for (FilterMap::iterator it = filters_.begin(); it != filters_.end(); ++it) { |
290 it->get()->SendBeginTracing(included_categories_, excluded_categories_); | 300 it->get()->SendBeginTracing(included_categories_, excluded_categories_, |
| 301 continuous_tracing_); |
291 } | 302 } |
292 } | 303 } |
293 | 304 |
294 void TraceControllerImpl::OnEndTracingAck( | 305 void TraceControllerImpl::OnEndTracingAck( |
295 const std::vector<std::string>& known_categories) { | 306 const std::vector<std::string>& known_categories) { |
296 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 307 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
297 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 308 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
298 base::Bind(&TraceControllerImpl::OnEndTracingAck, | 309 base::Bind(&TraceControllerImpl::OnEndTracingAck, |
299 base::Unretained(this), known_categories)); | 310 base::Unretained(this), known_categories)); |
300 return; | 311 return; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 // The last ack represents local trace, so we need to ack it now. Note that | 416 // The last ack represents local trace, so we need to ack it now. Note that |
406 // this code only executes if there were child processes. | 417 // this code only executes if there were child processes. |
407 float bpf = TraceLog::GetInstance()->GetBufferPercentFull(); | 418 float bpf = TraceLog::GetInstance()->GetBufferPercentFull(); |
408 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 419 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
409 base::Bind(&TraceControllerImpl::OnTraceBufferPercentFullReply, | 420 base::Bind(&TraceControllerImpl::OnTraceBufferPercentFullReply, |
410 base::Unretained(this), bpf)); | 421 base::Unretained(this), bpf)); |
411 } | 422 } |
412 } | 423 } |
413 | 424 |
414 } // namespace content | 425 } // namespace content |
OLD | NEW |