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

Side by Side Diff: base/debug/trace_event_impl.cc

Issue 734063004: Update from https://crrev.com/304418 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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
« no previous file with comments | « base/debug/trace_event_impl.h ('k') | base/debug/trace_event_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 1178
1179 trace_log_->lock_.AssertAcquired(); 1179 trace_log_->lock_.AssertAcquired();
1180 if (trace_log_->CheckGeneration(generation_)) { 1180 if (trace_log_->CheckGeneration(generation_)) {
1181 // Return the chunk to the buffer only if the generation matches. 1181 // Return the chunk to the buffer only if the generation matches.
1182 trace_log_->logged_events_->ReturnChunk(chunk_index_, chunk_.Pass()); 1182 trace_log_->logged_events_->ReturnChunk(chunk_index_, chunk_.Pass());
1183 } 1183 }
1184 // Otherwise this method may be called from the destructor, or TraceLog will 1184 // Otherwise this method may be called from the destructor, or TraceLog will
1185 // find the generation mismatch and delete this buffer soon. 1185 // find the generation mismatch and delete this buffer soon.
1186 } 1186 }
1187 1187
1188 TraceLogStatus::TraceLogStatus() : event_capacity(0), event_count(0) {
1189 }
1190
1191 TraceLogStatus::~TraceLogStatus() {
1192 }
1193
1188 // static 1194 // static
1189 TraceLog* TraceLog::GetInstance() { 1195 TraceLog* TraceLog::GetInstance() {
1190 return Singleton<TraceLog, LeakySingletonTraits<TraceLog> >::get(); 1196 return Singleton<TraceLog, LeakySingletonTraits<TraceLog> >::get();
1191 } 1197 }
1192 1198
1193 TraceLog::TraceLog() 1199 TraceLog::TraceLog()
1194 : mode_(DISABLED), 1200 : mode_(DISABLED),
1195 num_traces_recorded_(0), 1201 num_traces_recorded_(0),
1196 event_callback_(0), 1202 event_callback_(0),
1197 dispatching_to_observer_list_(false), 1203 dispatching_to_observer_list_(false),
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 } 1585 }
1580 1586
1581 bool TraceLog::HasEnabledStateObserver(EnabledStateObserver* listener) const { 1587 bool TraceLog::HasEnabledStateObserver(EnabledStateObserver* listener) const {
1582 std::vector<EnabledStateObserver*>::const_iterator it = 1588 std::vector<EnabledStateObserver*>::const_iterator it =
1583 std::find(enabled_state_observer_list_.begin(), 1589 std::find(enabled_state_observer_list_.begin(),
1584 enabled_state_observer_list_.end(), 1590 enabled_state_observer_list_.end(),
1585 listener); 1591 listener);
1586 return it != enabled_state_observer_list_.end(); 1592 return it != enabled_state_observer_list_.end();
1587 } 1593 }
1588 1594
1589 float TraceLog::GetBufferPercentFull() const { 1595 TraceLogStatus TraceLog::GetStatus() const {
1590 AutoLock lock(lock_); 1596 AutoLock lock(lock_);
1591 return static_cast<float>(static_cast<double>(logged_events_->Size()) / 1597 TraceLogStatus result;
1592 logged_events_->Capacity()); 1598 result.event_capacity = logged_events_->Capacity();
1599 result.event_count = logged_events_->Size();
1600 return result;
1593 } 1601 }
1594 1602
1595 bool TraceLog::BufferIsFull() const { 1603 bool TraceLog::BufferIsFull() const {
1596 AutoLock lock(lock_); 1604 AutoLock lock(lock_);
1597 return logged_events_->IsFull(); 1605 return logged_events_->IsFull();
1598 } 1606 }
1599 1607
1600 TraceBuffer* TraceLog::CreateTraceBuffer() { 1608 TraceBuffer* TraceLog::CreateTraceBuffer() {
1601 InternalTraceOptions options = trace_options(); 1609 InternalTraceOptions options = trace_options();
1602 if (options & kInternalRecordContinuously) 1610 if (options & kInternalRecordContinuously)
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
2564 } 2572 }
2565 2573
2566 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 2574 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
2567 if (*category_group_enabled_) { 2575 if (*category_group_enabled_) {
2568 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, 2576 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_,
2569 name_, event_handle_); 2577 name_, event_handle_);
2570 } 2578 }
2571 } 2579 }
2572 2580
2573 } // namespace trace_event_internal 2581 } // namespace trace_event_internal
OLDNEW
« no previous file with comments | « base/debug/trace_event_impl.h ('k') | base/debug/trace_event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698