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