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 #include "ppapi/proxy/ppp_class_proxy.h" | 5 #include "ppapi/proxy/ppp_class_proxy.h" |
6 | 6 |
7 #include "ppapi/c/dev/ppb_var_deprecated.h" | 7 #include "ppapi/c/dev/ppb_var_deprecated.h" |
8 #include "ppapi/c/dev/ppp_class_deprecated.h" | 8 #include "ppapi/c/dev/ppp_class_deprecated.h" |
9 #include "ppapi/proxy/dispatcher.h" | 9 #include "ppapi/proxy/dispatcher.h" |
10 #include "ppapi/proxy/interface_id.h" | |
11 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
12 #include "ppapi/proxy/serialized_var.h" | 11 #include "ppapi/proxy/serialized_var.h" |
| 12 #include "ppapi/shared_impl/api_id.h" |
13 | 13 |
14 namespace ppapi { | 14 namespace ppapi { |
15 namespace proxy { | 15 namespace proxy { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 // PPP_Class in the browser implementation ------------------------------------- | 19 // PPP_Class in the browser implementation ------------------------------------- |
20 | 20 |
21 // Represents a plugin-implemented class in the browser process. This just | 21 // Represents a plugin-implemented class in the browser process. This just |
22 // stores the data necessary to call back the plugin. | 22 // stores the data necessary to call back the plugin. |
(...skipping 11 matching lines...) Expand all Loading... |
34 | 34 |
35 ObjectProxy* ToObjectProxy(void* data) { | 35 ObjectProxy* ToObjectProxy(void* data) { |
36 return reinterpret_cast<ObjectProxy*>(data); | 36 return reinterpret_cast<ObjectProxy*>(data); |
37 } | 37 } |
38 | 38 |
39 bool HasProperty(void* object, PP_Var name, PP_Var* exception) { | 39 bool HasProperty(void* object, PP_Var name, PP_Var* exception) { |
40 ObjectProxy* obj = ToObjectProxy(object); | 40 ObjectProxy* obj = ToObjectProxy(object); |
41 bool result = false; | 41 bool result = false; |
42 ReceiveSerializedException se(obj->dispatcher, exception); | 42 ReceiveSerializedException se(obj->dispatcher, exception); |
43 obj->dispatcher->Send(new PpapiMsg_PPPClass_HasProperty( | 43 obj->dispatcher->Send(new PpapiMsg_PPPClass_HasProperty( |
44 INTERFACE_ID_PPP_CLASS, obj->ppp_class, obj->user_data, | 44 API_ID_PPP_CLASS, obj->ppp_class, obj->user_data, |
45 SerializedVarSendInput(obj->dispatcher, name), &se, &result)); | 45 SerializedVarSendInput(obj->dispatcher, name), &se, &result)); |
46 return result; | 46 return result; |
47 } | 47 } |
48 | 48 |
49 bool HasMethod(void* object, PP_Var name, PP_Var* exception) { | 49 bool HasMethod(void* object, PP_Var name, PP_Var* exception) { |
50 ObjectProxy* obj = ToObjectProxy(object); | 50 ObjectProxy* obj = ToObjectProxy(object); |
51 bool result = false; | 51 bool result = false; |
52 ReceiveSerializedException se(obj->dispatcher, exception); | 52 ReceiveSerializedException se(obj->dispatcher, exception); |
53 obj->dispatcher->Send(new PpapiMsg_PPPClass_HasMethod( | 53 obj->dispatcher->Send(new PpapiMsg_PPPClass_HasMethod( |
54 INTERFACE_ID_PPP_CLASS, obj->ppp_class, obj->user_data, | 54 API_ID_PPP_CLASS, obj->ppp_class, obj->user_data, |
55 SerializedVarSendInput(obj->dispatcher, name), &se, &result)); | 55 SerializedVarSendInput(obj->dispatcher, name), &se, &result)); |
56 return result; | 56 return result; |
57 } | 57 } |
58 | 58 |
59 PP_Var GetProperty(void* object, | 59 PP_Var GetProperty(void* object, |
60 PP_Var name, | 60 PP_Var name, |
61 PP_Var* exception) { | 61 PP_Var* exception) { |
62 ObjectProxy* obj = ToObjectProxy(object); | 62 ObjectProxy* obj = ToObjectProxy(object); |
63 ReceiveSerializedException se(obj->dispatcher, exception); | 63 ReceiveSerializedException se(obj->dispatcher, exception); |
64 ReceiveSerializedVarReturnValue result; | 64 ReceiveSerializedVarReturnValue result; |
65 obj->dispatcher->Send(new PpapiMsg_PPPClass_GetProperty( | 65 obj->dispatcher->Send(new PpapiMsg_PPPClass_GetProperty( |
66 INTERFACE_ID_PPP_CLASS, obj->ppp_class, obj->user_data, | 66 API_ID_PPP_CLASS, obj->ppp_class, obj->user_data, |
67 SerializedVarSendInput(obj->dispatcher, name), &se, &result)); | 67 SerializedVarSendInput(obj->dispatcher, name), &se, &result)); |
68 return result.Return(obj->dispatcher); | 68 return result.Return(obj->dispatcher); |
69 } | 69 } |
70 | 70 |
71 void GetAllPropertyNames(void* object, | 71 void GetAllPropertyNames(void* object, |
72 uint32_t* property_count, | 72 uint32_t* property_count, |
73 PP_Var** properties, | 73 PP_Var** properties, |
74 PP_Var* exception) { | 74 PP_Var* exception) { |
75 NOTIMPLEMENTED(); | 75 NOTIMPLEMENTED(); |
76 // TODO(brettw) implement this. | 76 // TODO(brettw) implement this. |
77 } | 77 } |
78 | 78 |
79 void SetProperty(void* object, | 79 void SetProperty(void* object, |
80 PP_Var name, | 80 PP_Var name, |
81 PP_Var value, | 81 PP_Var value, |
82 PP_Var* exception) { | 82 PP_Var* exception) { |
83 ObjectProxy* obj = ToObjectProxy(object); | 83 ObjectProxy* obj = ToObjectProxy(object); |
84 ReceiveSerializedException se(obj->dispatcher, exception); | 84 ReceiveSerializedException se(obj->dispatcher, exception); |
85 obj->dispatcher->Send(new PpapiMsg_PPPClass_SetProperty( | 85 obj->dispatcher->Send(new PpapiMsg_PPPClass_SetProperty( |
86 INTERFACE_ID_PPP_CLASS, obj->ppp_class, obj->user_data, | 86 API_ID_PPP_CLASS, obj->ppp_class, obj->user_data, |
87 SerializedVarSendInput(obj->dispatcher, name), | 87 SerializedVarSendInput(obj->dispatcher, name), |
88 SerializedVarSendInput(obj->dispatcher, value), &se)); | 88 SerializedVarSendInput(obj->dispatcher, value), &se)); |
89 } | 89 } |
90 | 90 |
91 void RemoveProperty(void* object, | 91 void RemoveProperty(void* object, |
92 PP_Var name, | 92 PP_Var name, |
93 PP_Var* exception) { | 93 PP_Var* exception) { |
94 ObjectProxy* obj = ToObjectProxy(object); | 94 ObjectProxy* obj = ToObjectProxy(object); |
95 ReceiveSerializedException se(obj->dispatcher, exception); | 95 ReceiveSerializedException se(obj->dispatcher, exception); |
96 obj->dispatcher->Send(new PpapiMsg_PPPClass_RemoveProperty( | 96 obj->dispatcher->Send(new PpapiMsg_PPPClass_RemoveProperty( |
97 INTERFACE_ID_PPP_CLASS, obj->ppp_class, obj->user_data, | 97 API_ID_PPP_CLASS, obj->ppp_class, obj->user_data, |
98 SerializedVarSendInput(obj->dispatcher, name), &se)); | 98 SerializedVarSendInput(obj->dispatcher, name), &se)); |
99 } | 99 } |
100 | 100 |
101 PP_Var Call(void* object, | 101 PP_Var Call(void* object, |
102 PP_Var method_name, | 102 PP_Var method_name, |
103 uint32_t argc, | 103 uint32_t argc, |
104 PP_Var* argv, | 104 PP_Var* argv, |
105 PP_Var* exception) { | 105 PP_Var* exception) { |
106 ObjectProxy* obj = ToObjectProxy(object); | 106 ObjectProxy* obj = ToObjectProxy(object); |
107 | 107 |
108 ReceiveSerializedVarReturnValue result; | 108 ReceiveSerializedVarReturnValue result; |
109 ReceiveSerializedException se(obj->dispatcher, exception); | 109 ReceiveSerializedException se(obj->dispatcher, exception); |
110 std::vector<SerializedVar> argv_vect; | 110 std::vector<SerializedVar> argv_vect; |
111 SerializedVarSendInput::ConvertVector(obj->dispatcher, argv, argc, | 111 SerializedVarSendInput::ConvertVector(obj->dispatcher, argv, argc, |
112 &argv_vect); | 112 &argv_vect); |
113 | 113 |
114 obj->dispatcher->Send(new PpapiMsg_PPPClass_Call( | 114 obj->dispatcher->Send(new PpapiMsg_PPPClass_Call( |
115 INTERFACE_ID_PPP_CLASS, obj->ppp_class, obj->user_data, | 115 API_ID_PPP_CLASS, obj->ppp_class, obj->user_data, |
116 SerializedVarSendInput(obj->dispatcher, method_name), argv_vect, | 116 SerializedVarSendInput(obj->dispatcher, method_name), argv_vect, |
117 &se, &result)); | 117 &se, &result)); |
118 return result.Return(obj->dispatcher); | 118 return result.Return(obj->dispatcher); |
119 } | 119 } |
120 | 120 |
121 PP_Var Construct(void* object, | 121 PP_Var Construct(void* object, |
122 uint32_t argc, | 122 uint32_t argc, |
123 PP_Var* argv, | 123 PP_Var* argv, |
124 PP_Var* exception) { | 124 PP_Var* exception) { |
125 ObjectProxy* obj = ToObjectProxy(object); | 125 ObjectProxy* obj = ToObjectProxy(object); |
126 | 126 |
127 ReceiveSerializedVarReturnValue result; | 127 ReceiveSerializedVarReturnValue result; |
128 ReceiveSerializedException se(obj->dispatcher, exception); | 128 ReceiveSerializedException se(obj->dispatcher, exception); |
129 std::vector<SerializedVar> argv_vect; | 129 std::vector<SerializedVar> argv_vect; |
130 SerializedVarSendInput::ConvertVector(obj->dispatcher, argv, argc, | 130 SerializedVarSendInput::ConvertVector(obj->dispatcher, argv, argc, |
131 &argv_vect); | 131 &argv_vect); |
132 | 132 |
133 obj->dispatcher->Send(new PpapiMsg_PPPClass_Construct( | 133 obj->dispatcher->Send(new PpapiMsg_PPPClass_Construct( |
134 INTERFACE_ID_PPP_CLASS, | 134 API_ID_PPP_CLASS, |
135 obj->ppp_class, obj->user_data, argv_vect, &se, &result)); | 135 obj->ppp_class, obj->user_data, argv_vect, &se, &result)); |
136 return result.Return(obj->dispatcher); | 136 return result.Return(obj->dispatcher); |
137 } | 137 } |
138 | 138 |
139 void Deallocate(void* object) { | 139 void Deallocate(void* object) { |
140 ObjectProxy* obj = ToObjectProxy(object); | 140 ObjectProxy* obj = ToObjectProxy(object); |
141 obj->dispatcher->Send(new PpapiMsg_PPPClass_Deallocate( | 141 obj->dispatcher->Send(new PpapiMsg_PPPClass_Deallocate( |
142 INTERFACE_ID_PPP_CLASS, obj->ppp_class, obj->user_data)); | 142 API_ID_PPP_CLASS, obj->ppp_class, obj->user_data)); |
143 delete obj; | 143 delete obj; |
144 } | 144 } |
145 | 145 |
146 const PPP_Class_Deprecated class_interface = { | 146 const PPP_Class_Deprecated class_interface = { |
147 &HasProperty, | 147 &HasProperty, |
148 &HasMethod, | 148 &HasMethod, |
149 &GetProperty, | 149 &GetProperty, |
150 &GetAllPropertyNames, | 150 &GetAllPropertyNames, |
151 &SetProperty, | 151 &SetProperty, |
152 &RemoveProperty, | 152 &RemoveProperty, |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 result.Return(dispatcher(), ToPPPClass(ppp_class)->Construct( | 294 result.Return(dispatcher(), ToPPPClass(ppp_class)->Construct( |
295 ToUserData(object), arg_count, args, exception.OutParam(dispatcher()))); | 295 ToUserData(object), arg_count, args, exception.OutParam(dispatcher()))); |
296 } | 296 } |
297 | 297 |
298 void PPP_Class_Proxy::OnMsgDeallocate(int64 ppp_class, int64 object) { | 298 void PPP_Class_Proxy::OnMsgDeallocate(int64 ppp_class, int64 object) { |
299 ToPPPClass(ppp_class)->Deallocate(ToUserData(object)); | 299 ToPPPClass(ppp_class)->Deallocate(ToUserData(object)); |
300 } | 300 } |
301 | 301 |
302 } // namespace proxy | 302 } // namespace proxy |
303 } // namespace ppapi | 303 } // namespace ppapi |
OLD | NEW |