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

Side by Side Diff: ppapi/shared_impl/ppb_trace_event_impl.cc

Issue 17555005: Add events with custom timestamps and thread id to PPAPI dev tracing interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: edits Created 7 years, 6 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
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 #include "ppapi/shared_impl/ppb_trace_event_impl.h" 5 #include "ppapi/shared_impl/ppb_trace_event_impl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "ppapi/thunk/thunk.h" 8 #include "ppapi/thunk/thunk.h"
9 9
10 10
(...skipping 11 matching lines...) Expand all
22 // non-const. All mem_t parameters are const void* so there is no way to 22 // non-const. All mem_t parameters are const void* so there is no way to
23 // return a pointer type to the caller without some const_cast. The pointer 23 // return a pointer type to the caller without some const_cast. The pointer
24 // type the tracing system works with is normally unsigned char*. 24 // type the tracing system works with is normally unsigned char*.
25 return const_cast<void*>(static_cast<const void*>( 25 return const_cast<void*>(static_cast<const void*>(
26 base::debug::TraceLog::GetInstance()->GetCategoryGroupEnabled( 26 base::debug::TraceLog::GetInstance()->GetCategoryGroupEnabled(
27 category_name))); 27 category_name)));
28 } 28 }
29 29
30 // static 30 // static
31 void TraceEventImpl::AddTraceEvent(int8_t phase, 31 void TraceEventImpl::AddTraceEvent(int8_t phase,
32 const void* category_enabled, 32 const void* category_enabled,
bradn 2013/06/21 21:49:18 Fix the identation
grosse 2013/06/24 23:16:46 Done.
33 const char* name, 33 const char* name,
34 uint64_t id, 34 uint64_t id,
35 uint32_t num_args, 35 uint32_t num_args,
36 const char* arg_names[], 36 const char* arg_names[],
37 const uint8_t arg_types[], 37 const uint8_t arg_types[],
38 const uint64_t arg_values[], 38 const uint64_t arg_values[],
39 uint8_t flags) { 39 uint8_t flags) {
40 base::debug::TraceLog::GetInstance()->AddTraceEvent(phase, 40 base::debug::TraceLog::GetInstance()->AddTraceEvent(phase,
41 static_cast<const unsigned char*>(category_enabled), name, id, num_args, 41 static_cast<const unsigned char*>(category_enabled), name, id, num_args,
42 arg_names, arg_types, 42 arg_names, arg_types,
43 // This cast is necessary for LP64 systems, where uint64_t is defined as 43 // This cast is necessary for LP64 systems, where uint64_t is defined as
44 // an unsigned long int, but trace_event internals are hermetic and 44 // an unsigned long int, but trace_event internals are hermetic and
45 // accepts an |unsigned long long*|. The pointer types are compatible but 45 // accepts an |unsigned long long*|. The pointer types are compatible but
46 // the compiler throws an error without an explicit cast. 46 // the compiler throws an error without an explicit cast.
47 reinterpret_cast<const unsigned long long*>(arg_values), NULL, flags); 47 reinterpret_cast<const unsigned long long*>(arg_values), NULL, flags);
48 } 48 }
49 49
50 // static 50 // static
51 void TraceEventImpl::AddTraceEventWithThreadIdAndTimestamp(int8_t phase,
52 const void* category_enabled,
bradn 2013/06/21 21:49:18 indentation
grosse 2013/06/24 23:16:46 Done.
53 const char* name,
54 uint64_t id,
55 int32_t thread_id,
56 int64_t timestamp,
57 uint32_t num_args,
58 const char* arg_names[],
59 const uint8_t arg_types[],
60 const uint64_t arg_values[],
61 uint8_t flags) {
62 base::TimeTicks ticks;
63 ticks += base::TimeDelta::FromMicroseconds(timestamp);
bradn 2013/06/21 21:49:18 I think we're going to need to string through Time
grosse 2013/06/24 23:16:46 Added Now() method.
64 base::debug::TraceLog::GetInstance()->AddTraceEventWithThreadIdAndTimestamp(
65 phase,
66 static_cast<const unsigned char*>(category_enabled), name, id,
67 thread_id, ticks, num_args,
68 arg_names, arg_types,
69 // This cast is necessary for LP64 systems, where uint64_t is defined as
70 // an unsigned long int, but trace_event internals are hermetic and
71 // accepts an |unsigned long long*|. The pointer types are compatible but
72 // the compiler throws an error without an explicit cast.
73 reinterpret_cast<const unsigned long long*>(arg_values), NULL, flags);
74 }
75
76 // static
51 void TraceEventImpl::SetThreadName(const char* thread_name) { 77 void TraceEventImpl::SetThreadName(const char* thread_name) {
52 base::PlatformThread::SetName(thread_name); 78 base::PlatformThread::SetName(thread_name);
53 } 79 }
54 80
55 namespace { 81 namespace {
56 82
57 const PPB_Trace_Event_Dev g_ppb_trace_event_thunk = { 83 const PPB_Trace_Event_Dev g_ppb_trace_event_thunk = {
58 &TraceEventImpl::GetCategoryEnabled, 84 &TraceEventImpl::GetCategoryEnabled,
59 &TraceEventImpl::AddTraceEvent, 85 &TraceEventImpl::AddTraceEvent,
86 &TraceEventImpl::AddTraceEventWithThreadIdAndTimestamp,
60 &TraceEventImpl::SetThreadName, 87 &TraceEventImpl::SetThreadName,
61 }; 88 };
62 89
63 } // namespace ppapi 90 } // namespace ppapi
64 91
65 } // namespace 92 } // namespace
66 93
67 namespace ppapi { 94 namespace ppapi {
68 namespace thunk { 95 namespace thunk {
69 96
70 const PPB_Trace_Event_Dev_0_1* GetPPB_Trace_Event_Dev_0_1_Thunk() { 97 const PPB_Trace_Event_Dev_0_2* GetPPB_Trace_Event_Dev_0_2_Thunk() {
71 return &g_ppb_trace_event_thunk; 98 return &g_ppb_trace_event_thunk;
72 } 99 }
73 100
74 } // namespace thunk 101 } // namespace thunk
75 } // namespace ppapi 102 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698