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

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

Issue 12676007: Skip default categories when getting known categories. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 9 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
« no previous file with comments | « no previous file | 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 "tracing already shutdown", 67 "tracing already shutdown",
68 "tracing categories exhausted; must increase TRACE_EVENT_MAX_CATEGORIES", 68 "tracing categories exhausted; must increase TRACE_EVENT_MAX_CATEGORIES",
69 "__metadata", 69 "__metadata",
70 }; 70 };
71 71
72 // The enabled flag is char instead of bool so that the API can be used from C. 72 // The enabled flag is char instead of bool so that the API can be used from C.
73 unsigned char g_category_enabled[TRACE_EVENT_MAX_CATEGORIES] = { 0 }; 73 unsigned char g_category_enabled[TRACE_EVENT_MAX_CATEGORIES] = { 0 };
74 const int g_category_already_shutdown = 0; 74 const int g_category_already_shutdown = 0;
75 const int g_category_categories_exhausted = 1; 75 const int g_category_categories_exhausted = 1;
76 const int g_category_metadata = 2; 76 const int g_category_metadata = 2;
77 int g_category_index = 3; // skip initial 3 categories 77 const int g_num_builtin_categories = 3;
78 int g_category_index = g_num_builtin_categories; // Skip default categories.
78 79
79 // The name of the current thread. This is used to decide if the current 80 // The name of the current thread. This is used to decide if the current
80 // thread name has changed. We combine all the seen thread names into the 81 // thread name has changed. We combine all the seen thread names into the
81 // output name for the thread. 82 // output name for the thread.
82 LazyInstance<ThreadLocalPointer<const char> >::Leaky 83 LazyInstance<ThreadLocalPointer<const char> >::Leaky
83 g_current_thread_name = LAZY_INSTANCE_INITIALIZER; 84 g_current_thread_name = LAZY_INSTANCE_INITIALIZER;
84 85
85 const char kRecordUntilFull[] = "record-until-full"; 86 const char kRecordUntilFull[] = "record-until-full";
86 const char kRecordContinuously[] = "record-continuously"; 87 const char kRecordContinuously[] = "record-continuously";
87 88
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 } 776 }
776 } 777 }
777 #if defined(OS_ANDROID) 778 #if defined(OS_ANDROID)
778 ApplyATraceEnabledFlag(category_enabled); 779 ApplyATraceEnabledFlag(category_enabled);
779 #endif 780 #endif
780 return category_enabled; 781 return category_enabled;
781 } 782 }
782 783
783 void TraceLog::GetKnownCategories(std::vector<std::string>* categories) { 784 void TraceLog::GetKnownCategories(std::vector<std::string>* categories) {
784 AutoLock lock(lock_); 785 AutoLock lock(lock_);
785 for (int i = 0; i < g_category_index; i++) 786 for (int i = g_num_builtin_categories; i < g_category_index; i++)
786 categories->push_back(g_categories[i]); 787 categories->push_back(g_categories[i]);
787 } 788 }
788 789
789 void TraceLog::SetEnabled(const std::vector<std::string>& included_categories, 790 void TraceLog::SetEnabled(const std::vector<std::string>& included_categories,
790 const std::vector<std::string>& excluded_categories, 791 const std::vector<std::string>& excluded_categories,
791 Options options) { 792 Options options) {
792 AutoLock lock(lock_); 793 AutoLock lock(lock_);
793 794
794 if (enable_count_++ > 0) { 795 if (enable_count_++ > 0) {
795 if (options != trace_options_) { 796 if (options != trace_options_) {
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 0, // num_args 1238 0, // num_args
1238 NULL, // arg_names 1239 NULL, // arg_names
1239 NULL, // arg_types 1240 NULL, // arg_types
1240 NULL, // arg_values 1241 NULL, // arg_values
1241 TRACE_EVENT_FLAG_NONE); // flags 1242 TRACE_EVENT_FLAG_NONE); // flags
1242 } 1243 }
1243 } 1244 }
1244 1245
1245 } // namespace trace_event_internal 1246 } // namespace trace_event_internal
1246 1247
OLDNEW
« no previous file with comments | « no previous file | base/debug/trace_event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698