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

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

Issue 15774010: Add TRACE_EVENT_IS_NEW_TRACE as a way to snapshot objects at start of recording (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 months 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 | Annotate | Revision Log
« 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/bind.h" 9 #include "base/bind.h"
10 #include "base/debug/leak_annotations.h" 10 #include "base/debug/leak_annotations.h"
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 } 766 }
767 } 767 }
768 if (!(ret & RECORD_UNTIL_FULL) && !(ret & RECORD_CONTINUOUSLY)) 768 if (!(ret & RECORD_UNTIL_FULL) && !(ret & RECORD_CONTINUOUSLY))
769 ret |= RECORD_UNTIL_FULL; // Default when no options are specified. 769 ret |= RECORD_UNTIL_FULL; // Default when no options are specified.
770 770
771 return static_cast<Options>(ret); 771 return static_cast<Options>(ret);
772 } 772 }
773 773
774 TraceLog::TraceLog() 774 TraceLog::TraceLog()
775 : enable_count_(0), 775 : enable_count_(0),
776 num_traces_recorded_(0),
776 logged_events_(NULL), 777 logged_events_(NULL),
777 dispatching_to_observer_list_(false), 778 dispatching_to_observer_list_(false),
778 watch_category_(NULL), 779 watch_category_(NULL),
779 trace_options_(RECORD_UNTIL_FULL), 780 trace_options_(RECORD_UNTIL_FULL),
780 sampling_thread_handle_(0), 781 sampling_thread_handle_(0),
781 category_filter_(CategoryFilter::kDefaultCategoryFilterString) { 782 category_filter_(CategoryFilter::kDefaultCategoryFilterString) {
782 // Trace is enabled or disabled on one thread while other threads are 783 // Trace is enabled or disabled on one thread while other threads are
783 // accessing the enabled flag. We don't care whether edge-case events are 784 // accessing the enabled flag. We don't care whether edge-case events are
784 // traced or not, so we allow races on the enabled flag to keep the trace 785 // traced or not, so we allow races on the enabled flag to keep the trace
785 // macros fast. 786 // macros fast.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 trace_options_ = options; 927 trace_options_ = options;
927 logged_events_.reset(GetTraceBuffer()); 928 logged_events_.reset(GetTraceBuffer());
928 } 929 }
929 930
930 if (dispatching_to_observer_list_) { 931 if (dispatching_to_observer_list_) {
931 DLOG(ERROR) << 932 DLOG(ERROR) <<
932 "Cannot manipulate TraceLog::Enabled state from an observer."; 933 "Cannot manipulate TraceLog::Enabled state from an observer.";
933 return; 934 return;
934 } 935 }
935 936
937 num_traces_recorded_++;
938
936 dispatching_to_observer_list_ = true; 939 dispatching_to_observer_list_ = true;
937 FOR_EACH_OBSERVER(EnabledStateChangedObserver, enabled_state_observer_list_, 940 FOR_EACH_OBSERVER(EnabledStateChangedObserver, enabled_state_observer_list_,
938 OnTraceLogWillEnable()); 941 OnTraceLogWillEnable());
939 dispatching_to_observer_list_ = false; 942 dispatching_to_observer_list_ = false;
940 943
941 category_filter_ = CategoryFilter(category_filter); 944 category_filter_ = CategoryFilter(category_filter);
942 EnableIncludedCategoryGroups(); 945 EnableIncludedCategoryGroups();
943 946
944 // Not supported in split-dll build. http://crbug.com/237249 947 // Not supported in split-dll build. http://crbug.com/237249
945 #if !defined(CHROME_SPLIT_DLL) 948 #if !defined(CHROME_SPLIT_DLL)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 dispatching_to_observer_list_ = false; 1003 dispatching_to_observer_list_ = false;
1001 1004
1002 category_filter_.Clear(); 1005 category_filter_.Clear();
1003 watch_category_ = NULL; 1006 watch_category_ = NULL;
1004 watch_event_name_ = ""; 1007 watch_event_name_ = "";
1005 for (int i = 0; i < g_category_index; i++) 1008 for (int i = 0; i < g_category_index; i++)
1006 SetCategoryGroupEnabled(i, false); 1009 SetCategoryGroupEnabled(i, false);
1007 AddThreadNameMetadataEvents(); 1010 AddThreadNameMetadataEvents();
1008 } 1011 }
1009 1012
1013 int TraceLog::GetNumTracesRecorded() {
1014 AutoLock lock(lock_);
1015 if (enable_count_ == 0)
1016 return -1;
1017 return num_traces_recorded_;
1018 }
1019
1010 void TraceLog::AddEnabledStateObserver(EnabledStateChangedObserver* listener) { 1020 void TraceLog::AddEnabledStateObserver(EnabledStateChangedObserver* listener) {
1011 enabled_state_observer_list_.AddObserver(listener); 1021 enabled_state_observer_list_.AddObserver(listener);
1012 } 1022 }
1013 1023
1014 void TraceLog::RemoveEnabledStateObserver( 1024 void TraceLog::RemoveEnabledStateObserver(
1015 EnabledStateChangedObserver* listener) { 1025 EnabledStateChangedObserver* listener) {
1016 enabled_state_observer_list_.RemoveObserver(listener); 1026 enabled_state_observer_list_.RemoveObserver(listener);
1017 } 1027 }
1018 1028
1019 float TraceLog::GetBufferPercentFull() const { 1029 float TraceLog::GetBufferPercentFull() const {
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 0, // num_args 1520 0, // num_args
1511 NULL, // arg_names 1521 NULL, // arg_names
1512 NULL, // arg_types 1522 NULL, // arg_types
1513 NULL, // arg_values 1523 NULL, // arg_values
1514 NULL, // convertable values 1524 NULL, // convertable values
1515 TRACE_EVENT_FLAG_NONE); // flags 1525 TRACE_EVENT_FLAG_NONE); // flags
1516 } 1526 }
1517 } 1527 }
1518 1528
1519 } // namespace trace_event_internal 1529 } // namespace trace_event_internal
1520
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