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

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

Issue 717083003: Report trace buffer usage as number of events, not only percentage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comment Created 6 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
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 3e8e1ac7cd1c0fc2d5aa5df1fbf84e88b5f626d9..2a1ceaafee577101a9ef230cdaac3e3101596a04 100644
--- a/content/browser/tracing/tracing_controller_impl.cc
+++ b/content/browser/tracing/tracing_controller_impl.cc
@@ -162,18 +162,19 @@ TracingController* TracingController::GetInstance() {
return TracingControllerImpl::GetInstance();
}
-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),
+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),
+ approximate_event_count_(0),
// Tracing may have been enabled by ContentMainRunner if kTraceStartup
// is specified in command line.
#if defined(OS_CHROMEOS) || defined(OS_WIN)
- is_system_tracing_(false),
+ is_system_tracing_(false),
#endif
- is_recording_(TraceLog::GetInstance()->IsEnabled()),
- is_monitoring_(false) {
+ is_recording_(TraceLog::GetInstance()->IsEnabled()),
+ is_monitoring_(false) {
}
TracingControllerImpl::~TracingControllerImpl() {
@@ -499,8 +500,8 @@ bool TracingControllerImpl::CaptureMonitoringSnapshot(
return true;
}
-bool TracingControllerImpl::GetTraceBufferPercentFull(
- const GetTraceBufferPercentFullCallback& callback) {
+bool TracingControllerImpl::GetTraceBufferUsage(
+ const GetTraceBufferUsageCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!can_get_trace_buffer_percent_full() || callback.is_null())
@@ -513,20 +514,24 @@ bool TracingControllerImpl::GetTraceBufferPercentFull(
trace_message_filters_.size() + 1;
pending_trace_buffer_percent_full_filters_ = trace_message_filters_;
maximum_trace_buffer_percent_full_ = 0;
+ approximate_event_count_ = 0;
- // Call OnTraceBufferPercentFullReply unconditionally for the browser process.
+ TraceLog::BufferUsage buffer_usage =
+ TraceLog::GetInstance()->GetBufferUsage();
+ // Call OnTraceBufferUsageReply unconditionally for the browser process.
// This will result in immediate execution of the callback if there are no
// child processes.
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(&TracingControllerImpl::OnTraceBufferPercentFullReply,
- base::Unretained(this),
- scoped_refptr<TraceMessageFilter>(),
- TraceLog::GetInstance()->GetBufferPercentFull()));
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&TracingControllerImpl::OnTraceBufferUsageReply,
+ base::Unretained(this), scoped_refptr<TraceMessageFilter>(),
+ buffer_usage.percent_full,
+ buffer_usage.approximate_event_count));
// Notify all child processes.
for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin();
it != trace_message_filters_.end(); ++it) {
- it->get()->SendGetTraceBufferPercentFull();
+ it->get()->SendGetTraceBufferUsage();
}
return true;
}
@@ -636,11 +641,11 @@ void TracingControllerImpl::RemoveTraceMessageFilter(
TraceMessageFilterSet::const_iterator it =
pending_trace_buffer_percent_full_filters_.find(trace_message_filter);
if (it != pending_trace_buffer_percent_full_filters_.end()) {
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(&TracingControllerImpl::OnTraceBufferPercentFullReply,
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&TracingControllerImpl::OnTraceBufferUsageReply,
base::Unretained(this),
- make_scoped_refptr(trace_message_filter),
- 0));
+ make_scoped_refptr(trace_message_filter), 0, 0));
}
}
@@ -815,15 +820,17 @@ void TracingControllerImpl::OnLocalMonitoringTraceDataCollected(
OnCaptureMonitoringSnapshotAcked(NULL);
}
-void TracingControllerImpl::OnTraceBufferPercentFullReply(
+void TracingControllerImpl::OnTraceBufferUsageReply(
TraceMessageFilter* trace_message_filter,
- float percent_full) {
+ float percent_full,
+ size_t approximate_event_count) {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(&TracingControllerImpl::OnTraceBufferPercentFullReply,
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&TracingControllerImpl::OnTraceBufferUsageReply,
base::Unretained(this),
- make_scoped_refptr(trace_message_filter),
- percent_full));
+ make_scoped_refptr(trace_message_filter), percent_full,
+ approximate_event_count));
return;
}
@@ -838,11 +845,12 @@ void TracingControllerImpl::OnTraceBufferPercentFullReply(
maximum_trace_buffer_percent_full_ =
std::max(maximum_trace_buffer_percent_full_, percent_full);
+ approximate_event_count_ += approximate_event_count;
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_);
+ maximum_trace_buffer_percent_full_, approximate_event_count_);
pending_trace_buffer_percent_full_callback_.Reset();
}
}

Powered by Google App Engine
This is Rietveld 408576698