| 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/ppb_testing_proxy.h" | 5 #include "ppapi/proxy/ppb_testing_proxy.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "ppapi/c/dev/ppb_testing_dev.h" | 8 #include "ppapi/c/dev/ppb_testing_dev.h" |
| 9 #include "ppapi/proxy/plugin_dispatcher.h" | 9 #include "ppapi/proxy/plugin_dispatcher.h" |
| 10 #include "ppapi/proxy/plugin_resource.h" | 10 #include "ppapi/proxy/plugin_resource.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 if (!dispatcher) | 34 if (!dispatcher) |
| 35 return PP_FALSE; | 35 return PP_FALSE; |
| 36 | 36 |
| 37 PP_Bool result = PP_FALSE; | 37 PP_Bool result = PP_FALSE; |
| 38 dispatcher->Send(new PpapiHostMsg_PPBTesting_ReadImageData( | 38 dispatcher->Send(new PpapiHostMsg_PPBTesting_ReadImageData( |
| 39 INTERFACE_ID_PPB_TESTING, graphics_2d_object->host_resource(), | 39 INTERFACE_ID_PPB_TESTING, graphics_2d_object->host_resource(), |
| 40 image_object->host_resource(), *top_left, &result)); | 40 image_object->host_resource(), *top_left, &result)); |
| 41 return result; | 41 return result; |
| 42 } | 42 } |
| 43 | 43 |
| 44 void RunMessageLoop() { | 44 void RunMessageLoop(PP_Instance instance) { |
| 45 bool old_state = MessageLoop::current()->NestableTasksAllowed(); | 45 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 46 MessageLoop::current()->SetNestableTasksAllowed(true); | 46 if (!dispatcher) |
| 47 MessageLoop::current()->Run(); | 47 return; |
| 48 MessageLoop::current()->SetNestableTasksAllowed(old_state); | 48 IPC::SyncMessage* msg = new PpapiHostMsg_PPBTesting_RunMessageLoop( |
| 49 INTERFACE_ID_PPB_TESTING, instance); |
| 50 msg->EnableMessagePumping(); |
| 51 dispatcher->Send(msg); |
| 49 } | 52 } |
| 50 | 53 |
| 51 void QuitMessageLoop() { | 54 void QuitMessageLoop(PP_Instance instance) { |
| 52 MessageLoop::current()->QuitNow(); | 55 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 56 if (!dispatcher) |
| 57 return; |
| 58 dispatcher->Send(new PpapiHostMsg_PPBTesting_QuitMessageLoop( |
| 59 INTERFACE_ID_PPB_TESTING, instance)); |
| 53 } | 60 } |
| 54 | 61 |
| 55 uint32_t GetLiveObjectsForInstance(PP_Instance instance_id) { | 62 uint32_t GetLiveObjectsForInstance(PP_Instance instance_id) { |
| 56 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); | 63 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); |
| 57 if (!dispatcher) | 64 if (!dispatcher) |
| 58 return static_cast<uint32_t>(-1); | 65 return static_cast<uint32_t>(-1); |
| 59 | 66 |
| 60 uint32_t result = 0; | 67 uint32_t result = 0; |
| 61 dispatcher->Send(new PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance( | 68 dispatcher->Send(new PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance( |
| 62 INTERFACE_ID_PPB_TESTING, instance_id, &result)); | 69 INTERFACE_ID_PPB_TESTING, instance_id, &result)); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 122 |
| 116 void PPB_Testing_Proxy::OnMsgReadImageData( | 123 void PPB_Testing_Proxy::OnMsgReadImageData( |
| 117 const HostResource& device_context_2d, | 124 const HostResource& device_context_2d, |
| 118 const HostResource& image, | 125 const HostResource& image, |
| 119 const PP_Point& top_left, | 126 const PP_Point& top_left, |
| 120 PP_Bool* result) { | 127 PP_Bool* result) { |
| 121 *result = ppb_testing_target()->ReadImageData( | 128 *result = ppb_testing_target()->ReadImageData( |
| 122 device_context_2d.host_resource(), image.host_resource(), &top_left); | 129 device_context_2d.host_resource(), image.host_resource(), &top_left); |
| 123 } | 130 } |
| 124 | 131 |
| 125 void PPB_Testing_Proxy::OnMsgRunMessageLoop(bool* dummy) { | 132 void PPB_Testing_Proxy::OnMsgRunMessageLoop(PP_Instance instance) { |
| 126 ppb_testing_target()->RunMessageLoop(); | 133 ppb_testing_target()->RunMessageLoop(instance); |
| 127 *dummy = false; | |
| 128 } | 134 } |
| 129 | 135 |
| 130 void PPB_Testing_Proxy::OnMsgQuitMessageLoop() { | 136 void PPB_Testing_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) { |
| 131 ppb_testing_target()->QuitMessageLoop(); | 137 ppb_testing_target()->QuitMessageLoop(instance); |
| 132 } | 138 } |
| 133 | 139 |
| 134 void PPB_Testing_Proxy::OnMsgGetLiveObjectsForInstance(PP_Instance instance, | 140 void PPB_Testing_Proxy::OnMsgGetLiveObjectsForInstance(PP_Instance instance, |
| 135 uint32_t* result) { | 141 uint32_t* result) { |
| 136 *result = ppb_testing_target()->GetLiveObjectsForInstance(instance); | 142 *result = ppb_testing_target()->GetLiveObjectsForInstance(instance); |
| 137 } | 143 } |
| 138 | 144 |
| 139 } // namespace proxy | 145 } // namespace proxy |
| 140 } // namespace pp | 146 } // namespace pp |
| OLD | NEW |