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

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

Issue 12047066: Reland: Add trace event Pepper API (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 7 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
« no previous file with comments | « ppapi/shared_impl/ppb_trace_event_impl.h ('k') | ppapi/tests/all_c_includes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ppapi/shared_impl/ppb_trace_event_impl.h"
6
7 #include "base/debug/trace_event.h"
8 #include "ppapi/thunk/thunk.h"
9
10
11 namespace ppapi {
12
13 // PPB_Trace_Event_Dev is a shared implementation because Trace Events can be
14 // sent from either the plugin process or renderer process depending on whether
15 // the plugin is in- or out-of-process. Also, for NaCl plugins these functions
16 // will be executed from untrusted code and handled appropriately by tracing
17 // functionality in the IRT.
18
19 // static
20 void* TraceEventImpl::GetCategoryEnabled(const char* category_name) {
21 // This casting is here because all mem_t return types in Pepper are void* and
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
24 // type the tracing system works with is normally unsigned char*.
25 return const_cast<void*>(static_cast<const void*>(
26 base::debug::TraceLog::GetInstance()->GetCategoryEnabled(category_name)));
27 }
28
29 // static
30 void TraceEventImpl::AddTraceEvent(int8_t phase,
31 const void* category_enabled,
32 const char* name,
33 uint64_t id,
34 uint32_t num_args,
35 const char* arg_names[],
36 const uint8_t arg_types[],
37 const uint64_t arg_values[],
38 uint8_t flags) {
39 base::debug::TraceLog::GetInstance()->AddTraceEvent(phase,
40 static_cast<const unsigned char*>(category_enabled), name, id, num_args,
41 arg_names, arg_types,
42 // This cast is necessary for LP64 systems, where uint64_t is defined as
43 // an unsigned long int, but trace_event internals are hermetic and
44 // accepts an |unsigned long long*|. The pointer types are compatible but
45 // the compiler throws an error without an explicit cast.
46 reinterpret_cast<const unsigned long long*>(arg_values), flags);
47 }
48
49 // static
50 void TraceEventImpl::SetThreadName(const char* thread_name) {
51 base::PlatformThread::SetName(thread_name);
52 }
53
54 namespace {
55
56 const PPB_Trace_Event_Dev g_ppb_trace_event_thunk = {
57 &TraceEventImpl::GetCategoryEnabled,
58 &TraceEventImpl::AddTraceEvent,
59 &TraceEventImpl::SetThreadName,
60 };
61
62 } // namespace ppapi
63
64 } // namespace
65
66 namespace ppapi {
67 namespace thunk {
68
69 const PPB_Trace_Event_Dev_0_1* GetPPB_Trace_Event_Dev_0_1_Thunk() {
70 return &g_ppb_trace_event_thunk;
71 }
72
73 } // namespace thunk
74 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/ppb_trace_event_impl.h ('k') | ppapi/tests/all_c_includes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698