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 | 5 |
6 #ifndef BASE_DEBUG_TRACE_EVENT_IMPL_H_ | 6 #ifndef BASE_DEBUG_TRACE_EVENT_IMPL_H_ |
7 #define BASE_DEBUG_TRACE_EVENT_IMPL_H_ | 7 #define BASE_DEBUG_TRACE_EVENT_IMPL_H_ |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 199 |
200 // Retieves the categories set via a prior call to SetEnabled(). Only | 200 // Retieves the categories set via a prior call to SetEnabled(). Only |
201 // meaningful if |IsEnabled()| is true. | 201 // meaningful if |IsEnabled()| is true. |
202 void GetEnabledTraceCategories(std::vector<std::string>* included_out, | 202 void GetEnabledTraceCategories(std::vector<std::string>* included_out, |
203 std::vector<std::string>* excluded_out); | 203 std::vector<std::string>* excluded_out); |
204 | 204 |
205 // Disable tracing for all categories. | 205 // Disable tracing for all categories. |
206 void SetDisabled(); | 206 void SetDisabled(); |
207 // Helper method to enable/disable tracing for all categories. | 207 // Helper method to enable/disable tracing for all categories. |
208 void SetEnabled(bool enabled); | 208 void SetEnabled(bool enabled); |
209 bool IsEnabled() { return enabled_; } | 209 bool IsEnabled() { return enable_count_; } |
210 | 210 |
211 #if defined(OS_ANDROID) | 211 #if defined(OS_ANDROID) |
212 static void InitATrace(); | 212 static void InitATrace(); |
213 #endif | 213 #endif |
214 | 214 |
215 // Enabled state listeners give a callback when tracing is enabled or | 215 // Enabled state listeners give a callback when tracing is enabled or |
216 // disabled. This can be used to tie into other library's tracing systems | 216 // disabled. This can be used to tie into other library's tracing systems |
217 // on-demand. | 217 // on-demand. |
218 class EnabledStateChangedObserver { | 218 class EnabledStateChangedObserver { |
219 public: | 219 public: |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 const unsigned char* arg_types, | 360 const unsigned char* arg_types, |
361 const unsigned long long* arg_values); | 361 const unsigned long long* arg_values); |
362 void AddClockSyncMetadataEvents(); | 362 void AddClockSyncMetadataEvents(); |
363 static void ApplyATraceEnabledFlag(unsigned char* category_enabled); | 363 static void ApplyATraceEnabledFlag(unsigned char* category_enabled); |
364 #endif | 364 #endif |
365 | 365 |
366 // TODO(nduca): switch to per-thread trace buffers to reduce thread | 366 // TODO(nduca): switch to per-thread trace buffers to reduce thread |
367 // synchronization. | 367 // synchronization. |
368 // This lock protects TraceLog member accesses from arbitrary threads. | 368 // This lock protects TraceLog member accesses from arbitrary threads. |
369 Lock lock_; | 369 Lock lock_; |
370 bool enabled_; | 370 int enable_count_; |
371 NotificationCallback notification_callback_; | 371 NotificationCallback notification_callback_; |
372 std::vector<TraceEvent> logged_events_; | 372 std::vector<TraceEvent> logged_events_; |
373 std::vector<std::string> included_categories_; | 373 std::vector<std::string> included_categories_; |
374 std::vector<std::string> excluded_categories_; | 374 std::vector<std::string> excluded_categories_; |
375 bool dispatching_to_observer_list_; | 375 bool dispatching_to_observer_list_; |
376 ObserverList<EnabledStateChangedObserver> enabled_state_observer_list_; | 376 ObserverList<EnabledStateChangedObserver> enabled_state_observer_list_; |
377 | 377 |
378 base::hash_map<int, std::string> thread_names_; | 378 base::hash_map<int, std::string> thread_names_; |
379 | 379 |
380 // XORed with TraceID to make it unlikely to collide with other processes. | 380 // XORed with TraceID to make it unlikely to collide with other processes. |
381 unsigned long long process_id_hash_; | 381 unsigned long long process_id_hash_; |
382 | 382 |
383 int process_id_; | 383 int process_id_; |
384 | 384 |
385 TimeDelta time_offset_; | 385 TimeDelta time_offset_; |
386 | 386 |
387 // Allow tests to wake up when certain events occur. | 387 // Allow tests to wake up when certain events occur. |
388 const unsigned char* watch_category_; | 388 const unsigned char* watch_category_; |
389 std::string watch_event_name_; | 389 std::string watch_event_name_; |
390 | 390 |
391 DISALLOW_COPY_AND_ASSIGN(TraceLog); | 391 DISALLOW_COPY_AND_ASSIGN(TraceLog); |
392 }; | 392 }; |
393 | 393 |
394 } // namespace debug | 394 } // namespace debug |
395 } // namespace base | 395 } // namespace base |
396 | 396 |
397 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_ | 397 #endif // BASE_DEBUG_TRACE_EVENT_IMPL_H_ |
OLD | NEW |