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

Side by Side Diff: base/debug/trace_event_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 unified diff | Download patch
OLDNEW
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 "base/debug/trace_event_impl.h" 5 #include "base/debug/trace_event_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 } 1579 }
1580 1580
1581 bool TraceLog::HasEnabledStateObserver(EnabledStateObserver* listener) const { 1581 bool TraceLog::HasEnabledStateObserver(EnabledStateObserver* listener) const {
1582 std::vector<EnabledStateObserver*>::const_iterator it = 1582 std::vector<EnabledStateObserver*>::const_iterator it =
1583 std::find(enabled_state_observer_list_.begin(), 1583 std::find(enabled_state_observer_list_.begin(),
1584 enabled_state_observer_list_.end(), 1584 enabled_state_observer_list_.end(),
1585 listener); 1585 listener);
1586 return it != enabled_state_observer_list_.end(); 1586 return it != enabled_state_observer_list_.end();
1587 } 1587 }
1588 1588
1589 float TraceLog::GetBufferPercentFull() const { 1589 TraceLog::BufferUsage TraceLog::GetBufferUsage() const {
1590 AutoLock lock(lock_); 1590 AutoLock lock(lock_);
1591 return static_cast<float>(static_cast<double>(logged_events_->Size()) / 1591 BufferUsage result;
1592 logged_events_->Capacity()); 1592 result.percent_full = static_cast<float>(
1593 static_cast<double>(logged_events_->Size()) / logged_events_->Capacity());
1594 result.approximate_event_count = logged_events_->Size();
1595 return result;
1593 } 1596 }
1594 1597
1595 bool TraceLog::BufferIsFull() const { 1598 bool TraceLog::BufferIsFull() const {
1596 AutoLock lock(lock_); 1599 AutoLock lock(lock_);
1597 return logged_events_->IsFull(); 1600 return logged_events_->IsFull();
1598 } 1601 }
1599 1602
1600 TraceBuffer* TraceLog::CreateTraceBuffer() { 1603 TraceBuffer* TraceLog::CreateTraceBuffer() {
1601 InternalTraceOptions options = trace_options(); 1604 InternalTraceOptions options = trace_options();
1602 if (options & kInternalRecordContinuously) 1605 if (options & kInternalRecordContinuously)
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
2564 } 2567 }
2565 2568
2566 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 2569 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
2567 if (*category_group_enabled_) { 2570 if (*category_group_enabled_) {
2568 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, 2571 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_,
2569 name_, event_handle_); 2572 name_, event_handle_);
2570 } 2573 }
2571 } 2574 }
2572 2575
2573 } // namespace trace_event_internal 2576 } // namespace trace_event_internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698