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

Side by Side Diff: ppapi/proxy/resource_creation_proxy.cc

Issue 8790004: Rename the shared impl files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: New one Created 9 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 | Annotate | Revision Log
OLDNEW
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/resource_creation_proxy.h" 5 #include "ppapi/proxy/resource_creation_proxy.h"
6 6
7 #include "ppapi/c/pp_errors.h" 7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/pp_size.h" 8 #include "ppapi/c/pp_size.h"
9 #include "ppapi/c/trusted/ppb_image_data_trusted.h" 9 #include "ppapi/c/trusted/ppb_image_data_trusted.h"
10 #include "ppapi/proxy/plugin_dispatcher.h" 10 #include "ppapi/proxy/plugin_dispatcher.h"
(...skipping 11 matching lines...) Expand all
22 #include "ppapi/proxy/ppb_font_proxy.h" 22 #include "ppapi/proxy/ppb_font_proxy.h"
23 #include "ppapi/proxy/ppb_graphics_2d_proxy.h" 23 #include "ppapi/proxy/ppb_graphics_2d_proxy.h"
24 #include "ppapi/proxy/ppb_graphics_3d_proxy.h" 24 #include "ppapi/proxy/ppb_graphics_3d_proxy.h"
25 #include "ppapi/proxy/ppb_image_data_proxy.h" 25 #include "ppapi/proxy/ppb_image_data_proxy.h"
26 #include "ppapi/proxy/ppb_tcp_socket_private_proxy.h" 26 #include "ppapi/proxy/ppb_tcp_socket_private_proxy.h"
27 #include "ppapi/proxy/ppb_udp_socket_private_proxy.h" 27 #include "ppapi/proxy/ppb_udp_socket_private_proxy.h"
28 #include "ppapi/proxy/ppb_url_loader_proxy.h" 28 #include "ppapi/proxy/ppb_url_loader_proxy.h"
29 #include "ppapi/proxy/ppb_video_capture_proxy.h" 29 #include "ppapi/proxy/ppb_video_capture_proxy.h"
30 #include "ppapi/proxy/ppb_video_decoder_proxy.h" 30 #include "ppapi/proxy/ppb_video_decoder_proxy.h"
31 #include "ppapi/shared_impl/api_id.h" 31 #include "ppapi/shared_impl/api_id.h"
32 #include "ppapi/shared_impl/audio_config_impl.h"
33 #include "ppapi/shared_impl/font_impl.h"
34 #include "ppapi/shared_impl/function_group_base.h" 32 #include "ppapi/shared_impl/function_group_base.h"
35 #include "ppapi/shared_impl/host_resource.h" 33 #include "ppapi/shared_impl/host_resource.h"
36 #include "ppapi/shared_impl/input_event_impl.h" 34 #include "ppapi/shared_impl/ppb_audio_config_shared.h"
37 #include "ppapi/shared_impl/url_request_info_impl.h" 35 #include "ppapi/shared_impl/ppb_font_shared.h"
36 #include "ppapi/shared_impl/ppb_input_event_shared.h"
37 #include "ppapi/shared_impl/ppb_url_request_info_shared.h"
38 #include "ppapi/shared_impl/var.h" 38 #include "ppapi/shared_impl/var.h"
39 #include "ppapi/thunk/enter.h" 39 #include "ppapi/thunk/enter.h"
40 #include "ppapi/thunk/ppb_image_data_api.h" 40 #include "ppapi/thunk/ppb_image_data_api.h"
41 41
42 using ppapi::thunk::ResourceCreationAPI; 42 using ppapi::thunk::ResourceCreationAPI;
43 43
44 namespace ppapi { 44 namespace ppapi {
45 namespace proxy { 45 namespace proxy {
46 46
47 ResourceCreationProxy::ResourceCreationProxy(Dispatcher* dispatcher) 47 ResourceCreationProxy::ResourceCreationProxy(Dispatcher* dispatcher)
(...skipping 18 matching lines...) Expand all
66 PPB_Audio_Callback audio_callback, 66 PPB_Audio_Callback audio_callback,
67 void* user_data) { 67 void* user_data) {
68 return PPB_Audio_Proxy::CreateProxyResource(instance, config_id, 68 return PPB_Audio_Proxy::CreateProxyResource(instance, config_id,
69 audio_callback, user_data); 69 audio_callback, user_data);
70 } 70 }
71 71
72 PP_Resource ResourceCreationProxy::CreateAudioConfig( 72 PP_Resource ResourceCreationProxy::CreateAudioConfig(
73 PP_Instance instance, 73 PP_Instance instance,
74 PP_AudioSampleRate sample_rate, 74 PP_AudioSampleRate sample_rate,
75 uint32_t sample_frame_count) { 75 uint32_t sample_frame_count) {
76 return AudioConfigImpl::CreateAsProxy( 76 return PPB_AudioConfig_Shared::CreateAsProxy(
77 instance, sample_rate, sample_frame_count); 77 instance, sample_rate, sample_frame_count);
78 } 78 }
79 79
80 PP_Resource ResourceCreationProxy::CreateAudioTrusted(PP_Instance instance) { 80 PP_Resource ResourceCreationProxy::CreateAudioTrusted(PP_Instance instance) {
81 // Proxied plugins can't created trusted audio devices. 81 // Proxied plugins can't created trusted audio devices.
82 return 0; 82 return 0;
83 } 83 }
84 84
85 PP_Resource ResourceCreationProxy::CreateAudioInput( 85 PP_Resource ResourceCreationProxy::CreateAudioInput(
86 PP_Instance instance, 86 PP_Instance instance,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 144 }
145 145
146 PP_Resource ResourceCreationProxy::CreateFlashNetConnector( 146 PP_Resource ResourceCreationProxy::CreateFlashNetConnector(
147 PP_Instance instance) { 147 PP_Instance instance) {
148 return PPB_Flash_NetConnector_Proxy::CreateProxyResource(instance); 148 return PPB_Flash_NetConnector_Proxy::CreateProxyResource(instance);
149 } 149 }
150 150
151 PP_Resource ResourceCreationProxy::CreateFontObject( 151 PP_Resource ResourceCreationProxy::CreateFontObject(
152 PP_Instance instance, 152 PP_Instance instance,
153 const PP_FontDescription_Dev* description) { 153 const PP_FontDescription_Dev* description) {
154 if (!ppapi::FontImpl::IsPPFontDescriptionValid(*description)) 154 if (!PPB_Font_Shared::IsPPFontDescriptionValid(*description))
155 return 0; 155 return 0;
156 return (new Font(HostResource::MakeInstanceOnly(instance), *description))-> 156 return (new Font(HostResource::MakeInstanceOnly(instance), *description))->
157 GetReference(); 157 GetReference();
158 } 158 }
159 159
160 PP_Resource ResourceCreationProxy::CreateGraphics2D(PP_Instance instance, 160 PP_Resource ResourceCreationProxy::CreateGraphics2D(PP_Instance instance,
161 const PP_Size& size, 161 const PP_Size& size,
162 PP_Bool is_always_opaque) { 162 PP_Bool is_always_opaque) {
163 return PPB_Graphics2D_Proxy::CreateProxyResource(instance, size, 163 return PPB_Graphics2D_Proxy::CreateProxyResource(instance, size,
164 is_always_opaque); 164 is_always_opaque);
(...skipping 29 matching lines...) Expand all
194 PP_InputEvent_Type type, 194 PP_InputEvent_Type type,
195 PP_TimeTicks time_stamp, 195 PP_TimeTicks time_stamp,
196 uint32_t modifiers, 196 uint32_t modifiers,
197 uint32_t key_code, 197 uint32_t key_code,
198 struct PP_Var character_text) { 198 struct PP_Var character_text) {
199 if (type != PP_INPUTEVENT_TYPE_RAWKEYDOWN && 199 if (type != PP_INPUTEVENT_TYPE_RAWKEYDOWN &&
200 type != PP_INPUTEVENT_TYPE_KEYDOWN && 200 type != PP_INPUTEVENT_TYPE_KEYDOWN &&
201 type != PP_INPUTEVENT_TYPE_KEYUP && 201 type != PP_INPUTEVENT_TYPE_KEYUP &&
202 type != PP_INPUTEVENT_TYPE_CHAR) 202 type != PP_INPUTEVENT_TYPE_CHAR)
203 return 0; 203 return 0;
204 ppapi::InputEventData data; 204 InputEventData data;
205 data.event_type = type; 205 data.event_type = type;
206 data.event_time_stamp = time_stamp; 206 data.event_time_stamp = time_stamp;
207 data.event_modifiers = modifiers; 207 data.event_modifiers = modifiers;
208 data.key_code = key_code; 208 data.key_code = key_code;
209 if (character_text.type == PP_VARTYPE_STRING) { 209 if (character_text.type == PP_VARTYPE_STRING) {
210 StringVar* text_str = StringVar::FromPPVar(character_text); 210 StringVar* text_str = StringVar::FromPPVar(character_text);
211 if (!text_str) 211 if (!text_str)
212 return 0; 212 return 0;
213 data.character_text = text_str->value(); 213 data.character_text = text_str->value();
214 } 214 }
215 215
216 return (new InputEventImpl(InputEventImpl::InitAsProxy(), 216 return (new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsProxy(),
217 instance, data))->GetReference(); 217 instance, data))->GetReference();
218 } 218 }
219 219
220 PP_Resource ResourceCreationProxy::CreateMouseInputEvent( 220 PP_Resource ResourceCreationProxy::CreateMouseInputEvent(
221 PP_Instance instance, 221 PP_Instance instance,
222 PP_InputEvent_Type type, 222 PP_InputEvent_Type type,
223 PP_TimeTicks time_stamp, 223 PP_TimeTicks time_stamp,
224 uint32_t modifiers, 224 uint32_t modifiers,
225 PP_InputEvent_MouseButton mouse_button, 225 PP_InputEvent_MouseButton mouse_button,
226 const PP_Point* mouse_position, 226 const PP_Point* mouse_position,
227 int32_t click_count, 227 int32_t click_count,
228 const PP_Point* mouse_movement) { 228 const PP_Point* mouse_movement) {
229 if (type != PP_INPUTEVENT_TYPE_MOUSEDOWN && 229 if (type != PP_INPUTEVENT_TYPE_MOUSEDOWN &&
230 type != PP_INPUTEVENT_TYPE_MOUSEUP && 230 type != PP_INPUTEVENT_TYPE_MOUSEUP &&
231 type != PP_INPUTEVENT_TYPE_MOUSEMOVE && 231 type != PP_INPUTEVENT_TYPE_MOUSEMOVE &&
232 type != PP_INPUTEVENT_TYPE_MOUSEENTER && 232 type != PP_INPUTEVENT_TYPE_MOUSEENTER &&
233 type != PP_INPUTEVENT_TYPE_MOUSELEAVE) 233 type != PP_INPUTEVENT_TYPE_MOUSELEAVE)
234 return 0; 234 return 0;
235 235
236 ppapi::InputEventData data; 236 InputEventData data;
237 data.event_type = type; 237 data.event_type = type;
238 data.event_time_stamp = time_stamp; 238 data.event_time_stamp = time_stamp;
239 data.event_modifiers = modifiers; 239 data.event_modifiers = modifiers;
240 data.mouse_button = mouse_button; 240 data.mouse_button = mouse_button;
241 data.mouse_position = *mouse_position; 241 data.mouse_position = *mouse_position;
242 data.mouse_click_count = click_count; 242 data.mouse_click_count = click_count;
243 data.mouse_movement = *mouse_movement; 243 data.mouse_movement = *mouse_movement;
244 244
245 return (new InputEventImpl(InputEventImpl::InitAsProxy(), 245 return (new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsProxy(),
246 instance, data))->GetReference(); 246 instance, data))->GetReference();
247 } 247 }
248 248
249 PP_Resource ResourceCreationProxy::CreateGraphics3D( 249 PP_Resource ResourceCreationProxy::CreateGraphics3D(
250 PP_Instance instance, 250 PP_Instance instance,
251 PP_Resource share_context, 251 PP_Resource share_context,
252 const int32_t* attrib_list) { 252 const int32_t* attrib_list) {
253 return PPB_Graphics3D_Proxy::CreateProxyResource( 253 return PPB_Graphics3D_Proxy::CreateProxyResource(
254 instance, share_context, attrib_list); 254 instance, share_context, attrib_list);
255 } 255 }
256 256
(...skipping 29 matching lines...) Expand all
286 return PPB_UDPSocket_Private_Proxy::CreateProxyResource(instance); 286 return PPB_UDPSocket_Private_Proxy::CreateProxyResource(instance);
287 } 287 }
288 288
289 PP_Resource ResourceCreationProxy::CreateURLLoader(PP_Instance instance) { 289 PP_Resource ResourceCreationProxy::CreateURLLoader(PP_Instance instance) {
290 return PPB_URLLoader_Proxy::CreateProxyResource(instance); 290 return PPB_URLLoader_Proxy::CreateProxyResource(instance);
291 } 291 }
292 292
293 PP_Resource ResourceCreationProxy::CreateURLRequestInfo( 293 PP_Resource ResourceCreationProxy::CreateURLRequestInfo(
294 PP_Instance instance, 294 PP_Instance instance,
295 const PPB_URLRequestInfo_Data& data) { 295 const PPB_URLRequestInfo_Data& data) {
296 return (new URLRequestInfoImpl( 296 return (new PPB_URLRequestInfo_Shared(
297 HostResource::MakeInstanceOnly(instance), data))->GetReference(); 297 HostResource::MakeInstanceOnly(instance), data))->GetReference();
298 } 298 }
299 299
300 PP_Resource ResourceCreationProxy::CreateVideoCapture(PP_Instance instance) { 300 PP_Resource ResourceCreationProxy::CreateVideoCapture(PP_Instance instance) {
301 return PPB_VideoCapture_Proxy::CreateProxyResource(instance); 301 return PPB_VideoCapture_Proxy::CreateProxyResource(instance);
302 } 302 }
303 303
304 PP_Resource ResourceCreationProxy::CreateVideoDecoder( 304 PP_Resource ResourceCreationProxy::CreateVideoDecoder(
305 PP_Instance instance, 305 PP_Instance instance,
306 PP_Resource context3d_id, 306 PP_Resource context3d_id,
(...skipping 14 matching lines...) Expand all
321 return 0; 321 return 0;
322 } 322 }
323 323
324 PP_Resource ResourceCreationProxy::CreateWheelInputEvent( 324 PP_Resource ResourceCreationProxy::CreateWheelInputEvent(
325 PP_Instance instance, 325 PP_Instance instance,
326 PP_TimeTicks time_stamp, 326 PP_TimeTicks time_stamp,
327 uint32_t modifiers, 327 uint32_t modifiers,
328 const PP_FloatPoint* wheel_delta, 328 const PP_FloatPoint* wheel_delta,
329 const PP_FloatPoint* wheel_ticks, 329 const PP_FloatPoint* wheel_ticks,
330 PP_Bool scroll_by_page) { 330 PP_Bool scroll_by_page) {
331 ppapi::InputEventData data; 331 InputEventData data;
332 data.event_type = PP_INPUTEVENT_TYPE_WHEEL; 332 data.event_type = PP_INPUTEVENT_TYPE_WHEEL;
333 data.event_time_stamp = time_stamp; 333 data.event_time_stamp = time_stamp;
334 data.event_modifiers = modifiers; 334 data.event_modifiers = modifiers;
335 data.wheel_delta = *wheel_delta; 335 data.wheel_delta = *wheel_delta;
336 data.wheel_ticks = *wheel_ticks; 336 data.wheel_ticks = *wheel_ticks;
337 data.wheel_scroll_by_page = PP_ToBool(scroll_by_page); 337 data.wheel_scroll_by_page = PP_ToBool(scroll_by_page);
338 338
339 return (new InputEventImpl(InputEventImpl::InitAsProxy(), 339 return (new PPB_InputEvent_Shared(PPB_InputEvent_Shared::InitAsProxy(),
340 instance, data))->GetReference(); 340 instance, data))->GetReference();
341 } 341 }
342 342
343 bool ResourceCreationProxy::Send(IPC::Message* msg) { 343 bool ResourceCreationProxy::Send(IPC::Message* msg) {
344 return dispatcher()->Send(msg); 344 return dispatcher()->Send(msg);
345 } 345 }
346 346
347 bool ResourceCreationProxy::OnMessageReceived(const IPC::Message& msg) { 347 bool ResourceCreationProxy::OnMessageReceived(const IPC::Message& msg) {
348 bool handled = true; 348 bool handled = true;
349 IPC_BEGIN_MESSAGE_MAP(ResourceCreationProxy, msg) 349 IPC_BEGIN_MESSAGE_MAP(ResourceCreationProxy, msg)
350 IPC_MESSAGE_HANDLER(PpapiHostMsg_ResourceCreation_Graphics2D, 350 IPC_MESSAGE_HANDLER(PpapiHostMsg_ResourceCreation_Graphics2D,
351 OnMsgCreateGraphics2D) 351 OnMsgCreateGraphics2D)
352 IPC_MESSAGE_HANDLER(PpapiHostMsg_ResourceCreation_ImageData, 352 IPC_MESSAGE_HANDLER(PpapiHostMsg_ResourceCreation_ImageData,
353 OnMsgCreateImageData) 353 OnMsgCreateImageData)
354 IPC_MESSAGE_UNHANDLED(handled = false) 354 IPC_MESSAGE_UNHANDLED(handled = false)
355 IPC_END_MESSAGE_MAP() 355 IPC_END_MESSAGE_MAP()
356 return handled; 356 return handled;
357 } 357 }
358 358
359 void ResourceCreationProxy::OnMsgCreateGraphics2D(PP_Instance instance, 359 void ResourceCreationProxy::OnMsgCreateGraphics2D(PP_Instance instance,
360 const PP_Size& size, 360 const PP_Size& size,
361 PP_Bool is_always_opaque, 361 PP_Bool is_always_opaque,
362 HostResource* result) { 362 HostResource* result) {
363 ppapi::thunk::EnterFunction<ResourceCreationAPI> enter(instance, false); 363 thunk::EnterFunction<ResourceCreationAPI> enter(instance, false);
364 if (enter.succeeded()) { 364 if (enter.succeeded()) {
365 result->SetHostResource(instance, enter.functions()->CreateGraphics2D( 365 result->SetHostResource(instance, enter.functions()->CreateGraphics2D(
366 instance, size, is_always_opaque)); 366 instance, size, is_always_opaque));
367 } 367 }
368 } 368 }
369 369
370 void ResourceCreationProxy::OnMsgCreateImageData( 370 void ResourceCreationProxy::OnMsgCreateImageData(
371 PP_Instance instance, 371 PP_Instance instance,
372 int32_t format, 372 int32_t format,
373 const PP_Size& size, 373 const PP_Size& size,
374 PP_Bool init_to_zero, 374 PP_Bool init_to_zero,
375 HostResource* result, 375 HostResource* result,
376 std::string* image_data_desc, 376 std::string* image_data_desc,
377 ImageHandle* result_image_handle) { 377 ImageHandle* result_image_handle) {
378 *result_image_handle = ImageData::NullHandle; 378 *result_image_handle = ImageData::NullHandle;
379 379
380 ppapi::thunk::EnterFunction<ResourceCreationAPI> enter(instance, false); 380 thunk::EnterFunction<ResourceCreationAPI> enter(instance, false);
381 if (enter.failed()) 381 if (enter.failed())
382 return; 382 return;
383 383
384 PP_Resource resource = enter.functions()->CreateImageData( 384 PP_Resource resource = enter.functions()->CreateImageData(
385 instance, static_cast<PP_ImageDataFormat>(format), size, init_to_zero); 385 instance, static_cast<PP_ImageDataFormat>(format), size, init_to_zero);
386 if (!resource) 386 if (!resource)
387 return; 387 return;
388 result->SetHostResource(instance, resource); 388 result->SetHostResource(instance, resource);
389 389
390 // Get the description, it's just serialized as a string. 390 // Get the description, it's just serialized as a string.
391 ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_ImageData_API> 391 thunk::EnterResourceNoLock<thunk::PPB_ImageData_API> enter_resource(
392 enter_resource(resource, false); 392 resource, false);
393 PP_ImageDataDesc desc; 393 PP_ImageDataDesc desc;
394 if (enter_resource.object()->Describe(&desc) == PP_TRUE) { 394 if (enter_resource.object()->Describe(&desc) == PP_TRUE) {
395 image_data_desc->resize(sizeof(PP_ImageDataDesc)); 395 image_data_desc->resize(sizeof(PP_ImageDataDesc));
396 memcpy(&(*image_data_desc)[0], &desc, sizeof(PP_ImageDataDesc)); 396 memcpy(&(*image_data_desc)[0], &desc, sizeof(PP_ImageDataDesc));
397 } 397 }
398 398
399 // Get the shared memory handle. 399 // Get the shared memory handle.
400 const PPB_ImageDataTrusted* trusted = 400 const PPB_ImageDataTrusted* trusted =
401 reinterpret_cast<const PPB_ImageDataTrusted*>( 401 reinterpret_cast<const PPB_ImageDataTrusted*>(
402 dispatcher()->local_get_interface()(PPB_IMAGEDATA_TRUSTED_INTERFACE)); 402 dispatcher()->local_get_interface()(PPB_IMAGEDATA_TRUSTED_INTERFACE));
403 uint32_t byte_count = 0; 403 uint32_t byte_count = 0;
404 if (trusted) { 404 if (trusted) {
405 int32_t handle; 405 int32_t handle;
406 if (trusted->GetSharedMemory(resource, &handle, &byte_count) == PP_OK) { 406 if (trusted->GetSharedMemory(resource, &handle, &byte_count) == PP_OK) {
407 #if defined(OS_WIN) 407 #if defined(OS_WIN)
408 ImageHandle ih = ImageData::HandleFromInt(handle); 408 ImageHandle ih = ImageData::HandleFromInt(handle);
409 *result_image_handle = dispatcher()->ShareHandleWithRemote(ih, false); 409 *result_image_handle = dispatcher()->ShareHandleWithRemote(ih, false);
410 #else 410 #else
411 *result_image_handle = ImageData::HandleFromInt(handle); 411 *result_image_handle = ImageData::HandleFromInt(handle);
412 #endif 412 #endif
413 } 413 }
414 } 414 }
415 } 415 }
416 416
417 } // namespace proxy 417 } // namespace proxy
418 } // namespace ppapi 418 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698