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

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

Issue 11464005: Add trace event Pepper API (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Enable NaCl compilation Created 8 years 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_instance_shared.h" 5 #include "ppapi/shared_impl/ppb_instance_shared.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/debug/trace_event.h"
10 #include "base/threading/platform_thread.h"
9 #include "ppapi/c/pp_errors.h" 11 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/c/ppb_input_event.h" 12 #include "ppapi/c/ppb_input_event.h"
11 #include "ppapi/shared_impl/ppapi_globals.h" 13 #include "ppapi/shared_impl/ppapi_globals.h"
12 #include "ppapi/shared_impl/ppb_image_data_shared.h" 14 #include "ppapi/shared_impl/ppb_image_data_shared.h"
13 #include "ppapi/shared_impl/var.h" 15 #include "ppapi/shared_impl/var.h"
14 #include "ppapi/thunk/enter.h" 16 #include "ppapi/thunk/enter.h"
15 #include "ppapi/thunk/ppb_image_data_api.h" 17 #include "ppapi/thunk/ppb_image_data_api.h"
16 18
17 namespace ppapi { 19 namespace ppapi {
18 20
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 PP_INPUTEVENT_CLASS_KEYBOARD | 53 PP_INPUTEVENT_CLASS_KEYBOARD |
52 PP_INPUTEVENT_CLASS_WHEEL | 54 PP_INPUTEVENT_CLASS_WHEEL |
53 PP_INPUTEVENT_CLASS_TOUCH | 55 PP_INPUTEVENT_CLASS_TOUCH |
54 PP_INPUTEVENT_CLASS_IME)) 56 PP_INPUTEVENT_CLASS_IME))
55 return PP_ERROR_NOTSUPPORTED; 57 return PP_ERROR_NOTSUPPORTED;
56 58
57 // Everything else is valid. 59 // Everything else is valid.
58 return PP_OK; 60 return PP_OK;
59 } 61 }
60 62
63 // PPB_Trace_Events is a shared implementation because Trace Events can be sent
64 // from either the plugin process or renderer process depending on whether the
65 // plugin is in- or out-of-process. This will not currently work in NaCl
66 // because this code assumes we are in a chrome process space at this point. In
67 // order to make it work in NaCl, we will probably need some proxy-side
68 // management to make this work quickly without requiring IPCs for every call,
jbauman 2012/12/14 00:36:07 This isn't true anymore.
elijahtaylor1 2012/12/18 20:40:31 Done.
69 // and possibly a small re-write to the API.
70 void* PPB_Instance_Shared::GetCategoryEnabled(PP_Instance instance,
71 const char* category_name) {
72 // This casting is here because all mem_t return types in Pepper are void* and
73 // non-const. All mem_t parameters are const void* so there is no way to
74 // return a pointer type to the caller without some const_cast. The pointer
75 // type the tracing system works with is normally unsigned char*.
76 return const_cast<void*>(reinterpret_cast<const void*>(
77 base::debug::TraceLog::GetInstance()->GetCategoryEnabled(category_name)));
78 }
79
80 int32_t PPB_Instance_Shared::AddTraceEvent(PP_Instance instance,
81 int8_t phase,
82 const void* category_enabled,
83 const char* name,
84 uint64_t id,
85 uint32_t num_args,
86 const char* arg_names[],
87 const uint8_t arg_types[],
88 const uint64_t arg_values[],
89 int32_t threshold_begin_id,
90 int64_t threshold,
91 uint8_t flags) {
92 return base::debug::TraceLog::GetInstance()->AddTraceEvent(phase,
93 (const unsigned char*)category_enabled, name, id, num_args, arg_names,
94 arg_types, arg_values, threshold_begin_id, threshold, flags);
95 }
96
97 void PPB_Instance_Shared::SetThreadName(PP_Instance instance,
98 const char* thread_name) {
99 base::PlatformThread::SetName(thread_name);
100 }
101
61 bool PPB_Instance_Shared::ValidateSetCursorParams(PP_MouseCursor_Type type, 102 bool PPB_Instance_Shared::ValidateSetCursorParams(PP_MouseCursor_Type type,
62 PP_Resource image, 103 PP_Resource image,
63 const PP_Point* hot_spot) { 104 const PP_Point* hot_spot) {
64 if (static_cast<int>(type) < static_cast<int>(PP_MOUSECURSOR_TYPE_CUSTOM) || 105 if (static_cast<int>(type) < static_cast<int>(PP_MOUSECURSOR_TYPE_CUSTOM) ||
65 static_cast<int>(type) > static_cast<int>(PP_MOUSECURSOR_TYPE_GRABBING)) 106 static_cast<int>(type) > static_cast<int>(PP_MOUSECURSOR_TYPE_GRABBING))
66 return false; // Cursor type out of range. 107 return false; // Cursor type out of range.
67 if (type != PP_MOUSECURSOR_TYPE_CUSTOM) { 108 if (type != PP_MOUSECURSOR_TYPE_CUSTOM) {
68 // The image must not be specified if the type isn't custom. However, we 109 // The image must not be specified if the type isn't custom. However, we
69 // don't require that the hot spot be null since the C++ wrappers and proxy 110 // don't require that the hot spot be null since the C++ wrappers and proxy
70 // pass the point by reference and it will normally be specified. 111 // pass the point by reference and it will normally be specified.
(...skipping 21 matching lines...) Expand all
92 return false; 133 return false;
93 134
94 // Validate the hot spot location. 135 // Validate the hot spot location.
95 if (hot_spot->x < 0 || hot_spot->x >= desc.size.width || 136 if (hot_spot->x < 0 || hot_spot->x >= desc.size.width ||
96 hot_spot->y < 0 || hot_spot->y >= desc.size.height) 137 hot_spot->y < 0 || hot_spot->y >= desc.size.height)
97 return false; 138 return false;
98 return true; 139 return true;
99 } 140 }
100 141
101 } // namespace ppapi 142 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698