Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Trace events are for tracking application performance. | 5 // Trace events are for tracking application performance. |
| 6 // | 6 // |
| 7 // Events are issued against categories. Whereas LOG's | 7 // Events are issued against categories. Whereas LOG's |
| 8 // categories are statically defined, TRACE categories are created | 8 // categories are statically defined, TRACE categories are created |
| 9 // implicitly with a string. For example: | 9 // implicitly with a string. For example: |
| 10 // TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent") | 10 // TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent") |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 481 std::vector<TraceEvent> logged_events_; | 481 std::vector<TraceEvent> logged_events_; |
| 482 | 482 |
| 483 DISALLOW_COPY_AND_ASSIGN(TraceLog); | 483 DISALLOW_COPY_AND_ASSIGN(TraceLog); |
| 484 }; | 484 }; |
| 485 | 485 |
| 486 namespace internal { | 486 namespace internal { |
| 487 | 487 |
| 488 // Used by TRACE_EVENTx macro. Do not use directly. | 488 // Used by TRACE_EVENTx macro. Do not use directly. |
| 489 class BASE_API TraceEndOnScopeClose { | 489 class BASE_API TraceEndOnScopeClose { |
| 490 public: | 490 public: |
| 491 TraceEndOnScopeClose() : p_data_(NULL) {} | 491 TraceEndOnScopeClose() |
| 492 : p_data_(NULL) { | |
|
vandebo (ex-Chrome)
2011/06/21 22:34:44
nit: IIRC this can stay on the previous line.
James Hawkins
2011/06/21 22:45:05
On 2011/06/21 22:34:44, vandebo wrote:
Done.
| |
| 493 memset(&data_, 0, sizeof(data)); | |
| 494 } | |
| 492 ~TraceEndOnScopeClose() { | 495 ~TraceEndOnScopeClose() { |
| 493 if (p_data_) | 496 if (p_data_) |
| 494 AddEventIfEnabled(); | 497 AddEventIfEnabled(); |
| 495 } | 498 } |
| 496 | 499 |
| 497 void Initialize(const TraceCategory* category, | 500 void Initialize(const TraceCategory* category, |
| 498 const char* name); | 501 const char* name); |
| 499 | 502 |
| 500 private: | 503 private: |
| 501 // Add the end event if the category is still enabled. | 504 // Add the end event if the category is still enabled. |
| 502 void AddEventIfEnabled(); | 505 void AddEventIfEnabled(); |
| 503 | 506 |
| 504 // This Data struct workaround is to avoid initializing all the members | 507 // This Data struct workaround is to avoid initializing all the members |
|
vandebo (ex-Chrome)
2011/06/21 22:34:44
Is this comment saying we shouldn't add the memset
James Hawkins
2011/06/21 22:45:05
On 2011/06/21 22:34:44, vandebo wrote:
I've pinge
| |
| 505 // in Data during construction of this object, since this object is always | 508 // in Data during construction of this object, since this object is always |
| 506 // constructed, even when tracing is disabled. If the members of Data were | 509 // constructed, even when tracing is disabled. If the members of Data were |
| 507 // members of this class instead, compiler warnings occur about potential | 510 // members of this class instead, compiler warnings occur about potential |
| 508 // uninitialized accesses. | 511 // uninitialized accesses. |
| 509 struct Data { | 512 struct Data { |
| 510 const TraceCategory* category; | 513 const TraceCategory* category; |
| 511 const char* name; | 514 const char* name; |
| 512 }; | 515 }; |
| 513 Data* p_data_; | 516 Data* p_data_; |
| 514 Data data_; | 517 Data data_; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 Data* p_data_; | 551 Data* p_data_; |
| 549 Data data_; | 552 Data data_; |
| 550 }; | 553 }; |
| 551 | 554 |
| 552 } // namespace internal | 555 } // namespace internal |
| 553 | 556 |
| 554 } // namespace debug | 557 } // namespace debug |
| 555 } // namespace base | 558 } // namespace base |
| 556 | 559 |
| 557 #endif // BASE_DEBUG_TRACE_EVENT_H_ | 560 #endif // BASE_DEBUG_TRACE_EVENT_H_ |
| OLD | NEW |