| OLD | NEW |
| 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 24 matching lines...) Expand all Loading... |
| 35 #endif | 35 #endif |
| 36 | 36 |
| 37 class DeleteTraceLogForTesting { | 37 class DeleteTraceLogForTesting { |
| 38 public: | 38 public: |
| 39 static void Delete() { | 39 static void Delete() { |
| 40 Singleton<base::debug::TraceLog, | 40 Singleton<base::debug::TraceLog, |
| 41 LeakySingletonTraits<base::debug::TraceLog> >::OnExit(0); | 41 LeakySingletonTraits<base::debug::TraceLog> >::OnExit(0); |
| 42 } | 42 } |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 // Not supported in split-dll build. http://crbug.com/237249 |
| 46 #if !defined(CHROME_SPLIT_DLL) |
| 45 // The thread buckets for the sampling profiler. | 47 // The thread buckets for the sampling profiler. |
| 46 BASE_EXPORT TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3]; | 48 BASE_EXPORT TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3]; |
| 49 #endif |
| 47 | 50 |
| 48 namespace base { | 51 namespace base { |
| 49 namespace debug { | 52 namespace debug { |
| 50 | 53 |
| 51 // Controls the number of trace events we will buffer in-memory | 54 // Controls the number of trace events we will buffer in-memory |
| 52 // before throwing them away. | 55 // before throwing them away. |
| 53 const size_t kTraceEventBufferSize = 500000; | 56 const size_t kTraceEventBufferSize = 500000; |
| 54 const size_t kTraceEventBatchSize = 1000; | 57 const size_t kTraceEventBatchSize = 1000; |
| 55 const size_t kTraceEventInitialBufferSize = 1024; | 58 const size_t kTraceEventInitialBufferSize = 1024; |
| 56 | 59 |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 DLOG(ERROR) << | 974 DLOG(ERROR) << |
| 972 "Cannot manipulate TraceLog::Enabled state from an observer."; | 975 "Cannot manipulate TraceLog::Enabled state from an observer."; |
| 973 return; | 976 return; |
| 974 } | 977 } |
| 975 | 978 |
| 976 num_traces_recorded_++; | 979 num_traces_recorded_++; |
| 977 | 980 |
| 978 category_filter_ = CategoryFilter(category_filter); | 981 category_filter_ = CategoryFilter(category_filter); |
| 979 EnableIncludedCategoryGroups(); | 982 EnableIncludedCategoryGroups(); |
| 980 | 983 |
| 984 // Not supported in split-dll build. http://crbug.com/237249 |
| 985 #if !defined(CHROME_SPLIT_DLL) |
| 981 if (options & ENABLE_SAMPLING) { | 986 if (options & ENABLE_SAMPLING) { |
| 982 sampling_thread_.reset(new TraceSamplingThread); | 987 sampling_thread_.reset(new TraceSamplingThread); |
| 983 sampling_thread_->RegisterSampleBucket( | 988 sampling_thread_->RegisterSampleBucket( |
| 984 &g_trace_state[0], | 989 &g_trace_state[0], |
| 985 "bucket0", | 990 "bucket0", |
| 986 Bind(&TraceSamplingThread::DefaultSampleCallback)); | 991 Bind(&TraceSamplingThread::DefaultSampleCallback)); |
| 987 sampling_thread_->RegisterSampleBucket( | 992 sampling_thread_->RegisterSampleBucket( |
| 988 &g_trace_state[1], | 993 &g_trace_state[1], |
| 989 "bucket1", | 994 "bucket1", |
| 990 Bind(&TraceSamplingThread::DefaultSampleCallback)); | 995 Bind(&TraceSamplingThread::DefaultSampleCallback)); |
| 991 sampling_thread_->RegisterSampleBucket( | 996 sampling_thread_->RegisterSampleBucket( |
| 992 &g_trace_state[2], | 997 &g_trace_state[2], |
| 993 "bucket2", | 998 "bucket2", |
| 994 Bind(&TraceSamplingThread::DefaultSampleCallback)); | 999 Bind(&TraceSamplingThread::DefaultSampleCallback)); |
| 995 if (!PlatformThread::Create( | 1000 if (!PlatformThread::Create( |
| 996 0, sampling_thread_.get(), &sampling_thread_handle_)) { | 1001 0, sampling_thread_.get(), &sampling_thread_handle_)) { |
| 997 DCHECK(false) << "failed to create thread"; | 1002 DCHECK(false) << "failed to create thread"; |
| 998 } | 1003 } |
| 999 } | 1004 } |
| 1005 #endif |
| 1000 | 1006 |
| 1001 dispatching_to_observer_list_ = true; | 1007 dispatching_to_observer_list_ = true; |
| 1002 observer_list = enabled_state_observer_list_; | 1008 observer_list = enabled_state_observer_list_; |
| 1003 } | 1009 } |
| 1004 // Notify observers outside the lock in case they trigger trace events. | 1010 // Notify observers outside the lock in case they trigger trace events. |
| 1005 for (size_t i = 0; i < observer_list.size(); ++i) | 1011 for (size_t i = 0; i < observer_list.size(); ++i) |
| 1006 observer_list[i]->OnTraceLogEnabled(); | 1012 observer_list[i]->OnTraceLogEnabled(); |
| 1007 | 1013 |
| 1008 { | 1014 { |
| 1009 AutoLock lock(lock_); | 1015 AutoLock lock(lock_); |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1669 0, // num_args | 1675 0, // num_args |
| 1670 NULL, // arg_names | 1676 NULL, // arg_names |
| 1671 NULL, // arg_types | 1677 NULL, // arg_types |
| 1672 NULL, // arg_values | 1678 NULL, // arg_values |
| 1673 NULL, // convertable values | 1679 NULL, // convertable values |
| 1674 TRACE_EVENT_FLAG_NONE); // flags | 1680 TRACE_EVENT_FLAG_NONE); // flags |
| 1675 } | 1681 } |
| 1676 } | 1682 } |
| 1677 | 1683 |
| 1678 } // namespace trace_event_internal | 1684 } // namespace trace_event_internal |
| OLD | NEW |