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