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

Unified Diff: content/browser/tracing/tracing_controller_impl.cc

Issue 24355002: Overhaul tracing_ui to use XHR and new tracing_controller (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix wrong usages of RefCountedString::TakeString Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/tracing/tracing_controller_impl.h ('k') | content/browser/tracing/tracing_ui.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/tracing/tracing_controller_impl.cc
diff --git a/content/browser/tracing/tracing_controller_impl.cc b/content/browser/tracing/tracing_controller_impl.cc
index 6bb6c06093d1ad4693309042aad0a22bc148ba9a..9b2e4466c4bc085c1624fef123707db9a4518b58 100644
--- a/content/browser/tracing/tracing_controller_impl.cc
+++ b/content/browser/tracing/tracing_controller_impl.cc
@@ -94,6 +94,8 @@ void TracingControllerImpl::ResultFile::Close() {
TracingControllerImpl::TracingControllerImpl() :
pending_disable_recording_ack_count_(0),
pending_capture_monitoring_snapshot_ack_count_(0),
+ pending_trace_buffer_percent_full_ack_count_(0),
+ maximum_trace_buffer_percent_full_(0),
// Tracing may have been enabled by ContentMainRunner if kTraceStartup
// is specified in command line.
is_recording_(TraceLog::GetInstance()->IsEnabled()),
@@ -139,9 +141,15 @@ bool TracingControllerImpl::EnableRecording(
TraceLog::GetInstance()->AddClockSyncMetadataEvent();
#endif
- TraceLog::Options trace_options = TraceLog::GetInstance()->trace_options();
- TraceLog::GetInstance()->SetEnabled(filter, trace_options);
+ TraceLog::Options trace_options = (options & RECORD_CONTINUOUSLY) ?
+ TraceLog::RECORD_CONTINUOUSLY : TraceLog::RECORD_UNTIL_FULL;
+ if (options & ENABLE_SAMPLING) {
+ trace_options = static_cast<TraceLog::Options>(
+ trace_options | TraceLog::ENABLE_SAMPLING);
+ }
+ // TODO(haraken): How to handle ENABLE_SYSTRACE?
+ TraceLog::GetInstance()->SetEnabled(filter, trace_options);
is_recording_ = true;
category_filter_ = TraceLog::GetInstance()->GetCurrentCategoryFilter();
@@ -295,6 +303,33 @@ void TracingControllerImpl::CaptureMonitoringSnapshot(
#endif
}
+bool TracingControllerImpl::GetTraceBufferPercentFull(
+ const GetTraceBufferPercentFullCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (!can_get_trace_buffer_percent_full() || callback.is_null())
+ return false;
+
+ pending_trace_buffer_percent_full_callback_ = callback;
+
+ // Count myself in pending_trace_buffer_percent_full_ack_count_, acked below.
+ pending_trace_buffer_percent_full_ack_count_ = filters_.size() + 1;
+
+ // Handle special case of zero child processes.
+ if (pending_trace_buffer_percent_full_ack_count_ == 1) {
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ base::Bind(&TracingControllerImpl::OnTraceBufferPercentFullReply,
+ base::Unretained(this),
+ TraceLog::GetInstance()->GetBufferPercentFull()));
+ }
+
+ // Notify all child processes.
+ for (FilterMap::iterator it = filters_.begin(); it != filters_.end(); ++it) {
+ it->get()->SendGetTraceBufferPercentFull();
+ }
+ return true;
+}
+
void TracingControllerImpl::AddFilter(TraceMessageFilter* filter) {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
@@ -457,4 +492,35 @@ void TracingControllerImpl::OnLocalMonitoringTraceDataCollected(
OnCaptureMonitoringSnapshotAcked();
}
+void TracingControllerImpl::OnTraceBufferPercentFullReply(float percent_full) {
+ if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ base::Bind(&TracingControllerImpl::OnTraceBufferPercentFullReply,
+ base::Unretained(this), percent_full));
+ return;
+ }
+
+ if (pending_trace_buffer_percent_full_ack_count_ == 0)
+ return;
+
+ maximum_trace_buffer_percent_full_ =
+ std::max(maximum_trace_buffer_percent_full_, percent_full);
+
+ if (--pending_trace_buffer_percent_full_ack_count_ == 0) {
+ // Trigger callback if one is set.
+ pending_trace_buffer_percent_full_callback_.Run(
+ maximum_trace_buffer_percent_full_);
+ pending_trace_buffer_percent_full_callback_.Reset();
+ }
+
+ if (pending_trace_buffer_percent_full_ack_count_ == 1) {
+ // The last ack represents local trace, so we need to ack it now. Note that
+ // this code only executes if there were child processes.
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ base::Bind(&TracingControllerImpl::OnTraceBufferPercentFullReply,
+ base::Unretained(this),
+ TraceLog::GetInstance()->GetBufferPercentFull()));
+ }
+}
+
} // namespace content
« no previous file with comments | « content/browser/tracing/tracing_controller_impl.h ('k') | content/browser/tracing/tracing_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698