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/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/proxy/interface_id.h" | 9 #include "ppapi/proxy/interface_id.h" |
10 #include "ppapi/proxy/plugin_dispatcher.h" | 10 #include "ppapi/proxy/plugin_dispatcher.h" |
(...skipping 27 matching lines...) Expand all Loading... |
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) |
48 : InterfaceProxy(dispatcher) { | 48 : dispatcher_(dispatcher) { |
49 } | 49 } |
50 | 50 |
51 ResourceCreationProxy::~ResourceCreationProxy() { | 51 ResourceCreationProxy::~ResourceCreationProxy() { |
52 } | 52 } |
53 | 53 |
54 // static | |
55 InterfaceProxy* ResourceCreationProxy::Create(Dispatcher* dispatcher) { | |
56 return new ResourceCreationProxy(dispatcher); | |
57 } | |
58 | |
59 ResourceCreationAPI* ResourceCreationProxy::AsResourceCreationAPI() { | 54 ResourceCreationAPI* ResourceCreationProxy::AsResourceCreationAPI() { |
60 return this; | 55 return this; |
61 } | 56 } |
62 | 57 |
63 PP_Resource ResourceCreationProxy::CreateAudio( | 58 PP_Resource ResourceCreationProxy::CreateAudio( |
64 PP_Instance instance, | 59 PP_Instance instance, |
65 PP_Resource config_id, | 60 PP_Resource config_id, |
66 PPB_Audio_Callback audio_callback, | 61 PPB_Audio_Callback audio_callback, |
67 void* user_data) { | 62 void* user_data) { |
68 return PPB_Audio_Proxy::CreateProxyResource(instance, config_id, | 63 return PPB_Audio_Proxy::CreateProxyResource(instance, config_id, |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 data.event_modifiers = modifiers; | 330 data.event_modifiers = modifiers; |
336 data.wheel_delta = *wheel_delta; | 331 data.wheel_delta = *wheel_delta; |
337 data.wheel_ticks = *wheel_ticks; | 332 data.wheel_ticks = *wheel_ticks; |
338 data.wheel_scroll_by_page = PP_ToBool(scroll_by_page); | 333 data.wheel_scroll_by_page = PP_ToBool(scroll_by_page); |
339 | 334 |
340 return (new InputEventImpl(InputEventImpl::InitAsProxy(), | 335 return (new InputEventImpl(InputEventImpl::InitAsProxy(), |
341 instance, data))->GetReference(); | 336 instance, data))->GetReference(); |
342 } | 337 } |
343 | 338 |
344 bool ResourceCreationProxy::Send(IPC::Message* msg) { | 339 bool ResourceCreationProxy::Send(IPC::Message* msg) { |
345 return dispatcher()->Send(msg); | 340 return dispatcher_->Send(msg); |
346 } | 341 } |
347 | 342 |
348 bool ResourceCreationProxy::OnMessageReceived(const IPC::Message& msg) { | 343 bool ResourceCreationProxy::OnMessageReceived(const IPC::Message& msg) { |
349 bool handled = true; | 344 bool handled = true; |
350 IPC_BEGIN_MESSAGE_MAP(ResourceCreationProxy, msg) | 345 IPC_BEGIN_MESSAGE_MAP(ResourceCreationProxy, msg) |
351 IPC_MESSAGE_HANDLER(PpapiHostMsg_ResourceCreation_Graphics2D, | 346 IPC_MESSAGE_HANDLER(PpapiHostMsg_ResourceCreation_Graphics2D, |
352 OnMsgCreateGraphics2D) | 347 OnMsgCreateGraphics2D) |
353 IPC_MESSAGE_HANDLER(PpapiHostMsg_ResourceCreation_ImageData, | 348 IPC_MESSAGE_HANDLER(PpapiHostMsg_ResourceCreation_ImageData, |
354 OnMsgCreateImageData) | 349 OnMsgCreateImageData) |
355 IPC_MESSAGE_UNHANDLED(handled = false) | 350 IPC_MESSAGE_UNHANDLED(handled = false) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 enter_resource(resource, false); | 388 enter_resource(resource, false); |
394 PP_ImageDataDesc desc; | 389 PP_ImageDataDesc desc; |
395 if (enter_resource.object()->Describe(&desc) == PP_TRUE) { | 390 if (enter_resource.object()->Describe(&desc) == PP_TRUE) { |
396 image_data_desc->resize(sizeof(PP_ImageDataDesc)); | 391 image_data_desc->resize(sizeof(PP_ImageDataDesc)); |
397 memcpy(&(*image_data_desc)[0], &desc, sizeof(PP_ImageDataDesc)); | 392 memcpy(&(*image_data_desc)[0], &desc, sizeof(PP_ImageDataDesc)); |
398 } | 393 } |
399 | 394 |
400 // Get the shared memory handle. | 395 // Get the shared memory handle. |
401 const PPB_ImageDataTrusted* trusted = | 396 const PPB_ImageDataTrusted* trusted = |
402 reinterpret_cast<const PPB_ImageDataTrusted*>( | 397 reinterpret_cast<const PPB_ImageDataTrusted*>( |
403 dispatcher()->local_get_interface()(PPB_IMAGEDATA_TRUSTED_INTERFACE)); | 398 dispatcher_->GetLocalInterface(PPB_IMAGEDATA_TRUSTED_INTERFACE)); |
404 uint32_t byte_count = 0; | 399 uint32_t byte_count = 0; |
405 if (trusted) { | 400 if (trusted) { |
406 int32_t handle; | 401 int32_t handle; |
407 if (trusted->GetSharedMemory(resource, &handle, &byte_count) == PP_OK) { | 402 if (trusted->GetSharedMemory(resource, &handle, &byte_count) == PP_OK) { |
408 #if defined(OS_WIN) | 403 #if defined(OS_WIN) |
409 ImageHandle ih = ImageData::HandleFromInt(handle); | 404 ImageHandle ih = ImageData::HandleFromInt(handle); |
410 *result_image_handle = dispatcher()->ShareHandleWithRemote(ih, false); | 405 *result_image_handle = dispatcher_->ShareHandleWithRemote(ih, false); |
411 #else | 406 #else |
412 *result_image_handle = ImageData::HandleFromInt(handle); | 407 *result_image_handle = ImageData::HandleFromInt(handle); |
413 #endif | 408 #endif |
414 } | 409 } |
415 } | 410 } |
416 } | 411 } |
417 | 412 |
418 } // namespace proxy | 413 } // namespace proxy |
419 } // namespace ppapi | 414 } // namespace ppapi |
OLD | NEW |