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

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

Issue 11464005: Add trace event Pepper API (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Deleted thunk, renamed, other feedback Created 7 years, 12 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
(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 int32_t 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 int32_t threshold_begin_id,
39 int64_t threshold,
40 uint8_t flags) {
41 return base::debug::TraceLog::GetInstance()->AddTraceEvent(phase,
42 static_cast<const unsigned char*>(category_enabled), name, id, num_args,
43 arg_names, arg_types, arg_values, threshold_begin_id, threshold, flags);
44 }
45
46 // static
47 void TraceEventImpl::SetThreadName(const char* thread_name) {
48 base::PlatformThread::SetName(thread_name);
49 }
50
51 namespace {
52
53 const PPB_Trace_Event_Dev g_ppb_trace_event_thunk = {
54 &TraceEventImpl::GetCategoryEnabled,
55 &TraceEventImpl::AddTraceEvent,
56 &TraceEventImpl::SetThreadName,
57 };
58
59 } // namespace ppapi
60
61 } // namespace
62
63 namespace ppapi {
64 namespace thunk {
65
66 const PPB_Trace_Event_Dev_0_1* GetPPB_Trace_Event_Dev_0_1_Thunk() {
67 return &g_ppb_trace_event_thunk;
68 }
69
70 } // namespace thunk
71 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698