OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/tracing_controller_impl.h" | 5 #include "content/browser/tracing/tracing_controller_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/json/string_escape.h" | 9 #include "base/json/string_escape.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 file_ = NULL; | 107 file_ = NULL; |
108 | 108 |
109 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); | 109 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); |
110 } | 110 } |
111 | 111 |
112 | 112 |
113 TracingControllerImpl::TracingControllerImpl() : | 113 TracingControllerImpl::TracingControllerImpl() : |
114 pending_disable_recording_ack_count_(0), | 114 pending_disable_recording_ack_count_(0), |
115 pending_capture_monitoring_snapshot_ack_count_(0), | 115 pending_capture_monitoring_snapshot_ack_count_(0), |
116 pending_trace_buffer_percent_full_ack_count_(0), | 116 pending_trace_buffer_percent_full_ack_count_(0), |
117 pending_configure_synthetic_delay_ack_count_(0), | |
117 maximum_trace_buffer_percent_full_(0), | 118 maximum_trace_buffer_percent_full_(0), |
118 // Tracing may have been enabled by ContentMainRunner if kTraceStartup | 119 // Tracing may have been enabled by ContentMainRunner if kTraceStartup |
119 // is specified in command line. | 120 // is specified in command line. |
120 is_recording_(TraceLog::GetInstance()->IsEnabled()), | 121 is_recording_(TraceLog::GetInstance()->IsEnabled()), |
121 is_monitoring_(false), | 122 is_monitoring_(false), |
122 category_filter_( | 123 category_filter_( |
123 base::debug::CategoryFilter::kDefaultCategoryFilterString) { | 124 base::debug::CategoryFilter::kDefaultCategoryFilterString) { |
124 } | 125 } |
125 | 126 |
126 TracingControllerImpl::~TracingControllerImpl() { | 127 TracingControllerImpl::~TracingControllerImpl() { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 TraceLog::GetInstance()->GetBufferPercentFull())); | 350 TraceLog::GetInstance()->GetBufferPercentFull())); |
350 } | 351 } |
351 | 352 |
352 // Notify all child processes. | 353 // Notify all child processes. |
353 for (FilterMap::iterator it = filters_.begin(); it != filters_.end(); ++it) { | 354 for (FilterMap::iterator it = filters_.begin(); it != filters_.end(); ++it) { |
354 it->get()->SendGetTraceBufferPercentFull(); | 355 it->get()->SendGetTraceBufferPercentFull(); |
355 } | 356 } |
356 return true; | 357 return true; |
357 } | 358 } |
358 | 359 |
360 void TracingControllerImpl::ConfigureSyntheticDelay( | |
nduca
2013/11/24 19:42:00
i think you need to configure them all in one go,
| |
361 const std::string& name, | |
362 base::TimeDelta target_duration, | |
363 base::debug::TraceEventSyntheticDelay::Mode mode, | |
364 const ConfigureSyntheticDelayCallback& callback) { | |
365 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
366 | |
367 base::debug::TraceEventSyntheticDelay* delay = | |
368 base::debug::TraceEventSyntheticDelay::Lookup(name); | |
369 delay->SetTargetDuration(target_duration); | |
370 delay->SetMode(mode); | |
371 | |
372 pending_configure_synthetic_delay_callback_ = callback; | |
373 pending_configure_synthetic_delay_ack_count_ = filters_.size() + 1; | |
374 | |
375 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | |
376 base::Bind(&TracingControllerImpl::OnConfigureSyntheticDelayAcked, | |
377 base::Unretained(this))); | |
378 | |
379 // Notify all child processes. | |
380 for (FilterMap::iterator it = filters_.begin(); it != filters_.end(); ++it) { | |
381 it->get()->SendConfigureSyntheticDelay(name, target_duration, mode); | |
382 } | |
383 } | |
384 | |
359 void TracingControllerImpl::AddFilter(TraceMessageFilter* filter) { | 385 void TracingControllerImpl::AddFilter(TraceMessageFilter* filter) { |
360 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 386 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
361 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 387 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
362 base::Bind(&TracingControllerImpl::AddFilter, base::Unretained(this), | 388 base::Bind(&TracingControllerImpl::AddFilter, base::Unretained(this), |
363 make_scoped_refptr(filter))); | 389 make_scoped_refptr(filter))); |
364 return; | 390 return; |
365 } | 391 } |
366 | 392 |
367 filters_.insert(filter); | 393 filters_.insert(filter); |
368 if (can_disable_recording()) { | 394 if (can_disable_recording()) { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
562 if (pending_trace_buffer_percent_full_ack_count_ == 1) { | 588 if (pending_trace_buffer_percent_full_ack_count_ == 1) { |
563 // The last ack represents local trace, so we need to ack it now. Note that | 589 // The last ack represents local trace, so we need to ack it now. Note that |
564 // this code only executes if there were child processes. | 590 // this code only executes if there were child processes. |
565 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 591 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
566 base::Bind(&TracingControllerImpl::OnTraceBufferPercentFullReply, | 592 base::Bind(&TracingControllerImpl::OnTraceBufferPercentFullReply, |
567 base::Unretained(this), | 593 base::Unretained(this), |
568 TraceLog::GetInstance()->GetBufferPercentFull())); | 594 TraceLog::GetInstance()->GetBufferPercentFull())); |
569 } | 595 } |
570 } | 596 } |
571 | 597 |
598 void TracingControllerImpl::OnConfigureSyntheticDelayAcked() { | |
599 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | |
600 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | |
601 base::Bind(&TracingControllerImpl::OnConfigureSyntheticDelayAcked, | |
602 base::Unretained(this))); | |
603 return; | |
604 } | |
605 | |
606 if (pending_configure_synthetic_delay_ack_count_ == 0) | |
607 return; | |
608 | |
609 if (--pending_configure_synthetic_delay_ack_count_ != 0) | |
610 return; | |
611 | |
612 pending_configure_synthetic_delay_callback_.Run(); | |
613 } | |
614 | |
572 } // namespace content | 615 } // namespace content |
OLD | NEW |