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

Side by Side Diff: base/debug/trace_event.h

Issue 9234007: Cleanup trace_event.h, fix webkit API naming. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed BASE_EXPORT from inline TraceID Created 8 years, 11 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 | « no previous file | webkit/glue/webkitplatformsupport_impl.h » ('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 // This header is designed to give you trace_event macros without specifying 5 // This header is designed to give you trace_event macros without specifying
6 // how the events actually get collected and stored. If you need to expose trace 6 // how the events actually get collected and stored. If you need to expose trace
7 // event to some other universe, you can copy-and-paste this file, 7 // event to some other universe, you can copy-and-paste this file,
8 // implement the TRACE_EVENT_API macros, and do any other necessary fixup for 8 // implement the TRACE_EVENT_API macros, and do any other necessary fixup for
9 // the target platform. The end result is that multiple libraries can funnel 9 // the target platform. The end result is that multiple libraries can funnel
10 // events through to a shared trace event collector. 10 // events through to a shared trace event collector.
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 #define TRACE_EVENT_COPY_FINISH2(category, name, id, arg1_name, arg1_val, \ 435 #define TRACE_EVENT_COPY_FINISH2(category, name, id, arg1_name, arg1_val, \
436 arg2_name, arg2_val) \ 436 arg2_name, arg2_val) \
437 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ 437 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \
438 category, name, id, TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_COPY, \ 438 category, name, id, TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_COPY, \
439 arg1_name, arg1_val, arg2_name, arg2_val) 439 arg1_name, arg1_val, arg2_name, arg2_val)
440 440
441 441
442 //////////////////////////////////////////////////////////////////////////////// 442 ////////////////////////////////////////////////////////////////////////////////
443 // Implementation specific tracing API definitions. 443 // Implementation specific tracing API definitions.
444 444
445 // Get a pointer to the enabled state of the given trace category. Only
446 // long-lived literal strings should be given as the category name. The returned
447 // pointer can be held permanently in a local static for example. If the
448 // unsigned char is non-zero, tracing is enabled. If tracing is enabled,
449 // TRACE_EVENT_API_ADD_TRACE_EVENT can be called. It's OK if tracing is disabled
450 // between the load of the tracing state and the call to
451 // TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out
452 // for best performance when tracing is disabled.
445 // const unsigned char* 453 // const unsigned char*
446 // TRACE_EVENT_API_GET_CATEGORY_ENABLED(const char* category_name) 454 // TRACE_EVENT_API_GET_CATEGORY_ENABLED(const char* category_name)
447 #define TRACE_EVENT_API_GET_CATEGORY_ENABLED \ 455 #define TRACE_EVENT_API_GET_CATEGORY_ENABLED \
448 base::debug::TraceLog::GetCategoryEnabled 456 base::debug::TraceLog::GetCategoryEnabled
449 457
450 // Returns the threshold_begin_id used by TRACE_IF_LONGER_THAN macros. 458 // Add a trace event to the platform tracing system. Returns thresholdBeginId
459 // for use in a corresponding end TRACE_EVENT_API_ADD_TRACE_EVENT call.
451 // int TRACE_EVENT_API_ADD_TRACE_EVENT( 460 // int TRACE_EVENT_API_ADD_TRACE_EVENT(
452 // char phase, 461 // char phase,
453 // const unsigned char* category_enabled, 462 // const unsigned char* category_enabled,
454 // const char* name, 463 // const char* name,
455 // unsigned long long id, 464 // unsigned long long id,
456 // int num_args, 465 // int num_args,
457 // const char** arg_names, 466 // const char** arg_names,
458 // const unsigned char* arg_types, 467 // const unsigned char* arg_types,
459 // const unsigned long long* arg_values, 468 // const unsigned long long* arg_values,
460 // int threshold_begin_id, 469 // int threshold_begin_id,
461 // long long threshold, 470 // long long threshold,
462 // unsigned char flags) 471 // unsigned char flags)
463 #define TRACE_EVENT_API_ADD_TRACE_EVENT \ 472 #define TRACE_EVENT_API_ADD_TRACE_EVENT \
464 base::debug::TraceLog::GetInstance()->AddTraceEvent 473 base::debug::TraceLog::GetInstance()->AddTraceEvent
465 474
466 // void TRACE_EVENT_API_ADD_COUNTER_EVENT( 475 // Mangle pointer with a hash so that if it occurs on more than one process,
467 // const unsigned char* category_enabled, 476 // it will not collide in the trace data. Pass the returned value to
468 // const char* name, 477 // TRACE_EVENT_API_ADD_TRACE_EVENT as the id parameter.
469 // unsigned long long id,
470 // const char* arg1_name, int arg1_val,
471 // const char* arg2_name, int arg2_val,
472 // unsigned char flags)
473 #define TRACE_EVENT_API_ADD_COUNTER_EVENT \
474 base::debug::TraceLog::GetInstance()->AddCounterEvent
475
476 // Mangle |pointer| with a process ID hash so that if |pointer| occurs on more
477 // than one process, it will not collide in the trace data.
478 // unsigned long long TRACE_EVENT_API_GET_ID_FROM_POINTER(void* pointer) 478 // unsigned long long TRACE_EVENT_API_GET_ID_FROM_POINTER(void* pointer)
479 #define TRACE_EVENT_API_GET_ID_FROM_POINTER \ 479 #define TRACE_EVENT_API_GET_ID_FROM_POINTER \
480 base::debug::TraceLog::GetInstance()->GetInterProcessID 480 base::debug::TraceLog::GetInstance()->GetInterProcessID
481 481
482 //////////////////////////////////////////////////////////////////////////////// 482 ////////////////////////////////////////////////////////////////////////////////
483 483
484 // Implementation detail: trace event macros create temporary variables 484 // Implementation detail: trace event macros create temporary variables
485 // to keep instrumentation overhead low. These macros give each temporary 485 // to keep instrumentation overhead low. These macros give each temporary
486 // variable a unique name based on the line number to prevent name collissions. 486 // variable a unique name based on the line number to prevent name collissions.
487 #define INTERNAL_TRACE_EVENT_UID3(a,b) \ 487 #define INTERNAL_TRACE_EVENT_UID3(a,b) \
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 // Specify these values when the corresponding argument of AddTraceEvent is not 593 // Specify these values when the corresponding argument of AddTraceEvent is not
594 // used. 594 // used.
595 const int kZeroNumArgs = 0; 595 const int kZeroNumArgs = 0;
596 const int kNoThreshholdBeginId = -1; 596 const int kNoThreshholdBeginId = -1;
597 const long long kNoThresholdValue = 0; 597 const long long kNoThresholdValue = 0;
598 const unsigned long long kNoEventId = 0; 598 const unsigned long long kNoEventId = 0;
599 599
600 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers 600 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers
601 // are mangled with the Process ID so that they are unlikely to collide when the 601 // are mangled with the Process ID so that they are unlikely to collide when the
602 // same pointer is used on different processes. 602 // same pointer is used on different processes.
603 class BASE_EXPORT TraceID { 603 class TraceID {
604 public: 604 public:
605 explicit TraceID(void* rhs) : 605 explicit TraceID(void* rhs) :
606 data_(TRACE_EVENT_API_GET_ID_FROM_POINTER(rhs)) {} 606 data_(TRACE_EVENT_API_GET_ID_FROM_POINTER(rhs)) {}
607 explicit TraceID(unsigned long long rhs) : data_(rhs) {} 607 explicit TraceID(unsigned long long rhs) : data_(rhs) {}
608 explicit TraceID(unsigned long rhs) : data_(rhs) {} 608 explicit TraceID(unsigned long rhs) : data_(rhs) {}
609 explicit TraceID(unsigned int rhs) : data_(rhs) {} 609 explicit TraceID(unsigned int rhs) : data_(rhs) {}
610 explicit TraceID(unsigned short rhs) : data_(rhs) {} 610 explicit TraceID(unsigned short rhs) : data_(rhs) {}
611 explicit TraceID(unsigned char rhs) : data_(rhs) {} 611 explicit TraceID(unsigned char rhs) : data_(rhs) {}
612 explicit TraceID(long long rhs) : 612 explicit TraceID(long long rhs) :
613 data_(static_cast<unsigned long long>(rhs)) {} 613 data_(static_cast<unsigned long long>(rhs)) {}
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 const char* name; 815 const char* name;
816 int threshold_begin_id; 816 int threshold_begin_id;
817 }; 817 };
818 Data* p_data_; 818 Data* p_data_;
819 Data data_; 819 Data data_;
820 }; 820 };
821 821
822 } // namespace trace_event_internal 822 } // namespace trace_event_internal
823 823
824 #endif // BASE_DEBUG_TRACE_EVENT_H_ 824 #endif // BASE_DEBUG_TRACE_EVENT_H_
OLDNEW
« no previous file with comments | « no previous file | webkit/glue/webkitplatformsupport_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698