| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "ppapi/c/private/ppb_testing_private.h" | 8 #include "ppapi/c/private/ppb_testing_private.h" |
| 9 #include "ppapi/proxy/enter_proxy.h" | 9 #include "ppapi/proxy/enter_proxy.h" |
| 10 #include "ppapi/proxy/plugin_dispatcher.h" | 10 #include "ppapi/proxy/plugin_dispatcher.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 uint32_t result = 0; | 73 uint32_t result = 0; |
| 74 dispatcher->Send(new PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance( | 74 dispatcher->Send(new PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance( |
| 75 API_ID_PPB_TESTING, instance_id, &result)); | 75 API_ID_PPB_TESTING, instance_id, &result)); |
| 76 return result; | 76 return result; |
| 77 } | 77 } |
| 78 | 78 |
| 79 PP_Bool IsOutOfProcess() { | 79 PP_Bool IsOutOfProcess() { |
| 80 return PP_TRUE; | 80 return PP_TRUE; |
| 81 } | 81 } |
| 82 | 82 |
| 83 PP_Bool IsPeripheral(PP_Instance instance_id) { |
| 84 ProxyAutoLock lock; |
| 85 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); |
| 86 if (!dispatcher) |
| 87 return PP_FALSE; |
| 88 |
| 89 PP_Bool result = PP_FALSE; |
| 90 dispatcher->Send(new PpapiHostMsg_PPBTesting_IsPeripheral( |
| 91 API_ID_PPB_TESTING, instance_id, &result)); |
| 92 return result; |
| 93 } |
| 94 |
| 83 void SimulateInputEvent(PP_Instance instance_id, PP_Resource input_event) { | 95 void SimulateInputEvent(PP_Instance instance_id, PP_Resource input_event) { |
| 84 ProxyAutoLock lock; | 96 ProxyAutoLock lock; |
| 85 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); | 97 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); |
| 86 if (!dispatcher) | 98 if (!dispatcher) |
| 87 return; | 99 return; |
| 88 EnterResourceNoLock<PPB_InputEvent_API> enter(input_event, false); | 100 EnterResourceNoLock<PPB_InputEvent_API> enter(input_event, false); |
| 89 if (enter.failed()) | 101 if (enter.failed()) |
| 90 return; | 102 return; |
| 91 | 103 |
| 92 const InputEventData& input_event_data = enter.object()->GetInputEventData(); | 104 const InputEventData& input_event_data = enter.object()->GetInputEventData(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 new PpapiHostMsg_PPBTesting_SetMinimumArrayBufferSizeForShmem( | 138 new PpapiHostMsg_PPBTesting_SetMinimumArrayBufferSizeForShmem( |
| 127 API_ID_PPB_TESTING, threshold)); | 139 API_ID_PPB_TESTING, threshold)); |
| 128 } | 140 } |
| 129 | 141 |
| 130 void RunV8GC(PP_Instance instance) { | 142 void RunV8GC(PP_Instance instance) { |
| 131 // TODO(raymes): Implement this if we need it. | 143 // TODO(raymes): Implement this if we need it. |
| 132 NOTIMPLEMENTED(); | 144 NOTIMPLEMENTED(); |
| 133 } | 145 } |
| 134 | 146 |
| 135 const PPB_Testing_Private testing_interface = { | 147 const PPB_Testing_Private testing_interface = { |
| 136 &ReadImageData, | 148 &ReadImageData, |
| 137 &RunMessageLoop, | 149 &RunMessageLoop, |
| 138 &QuitMessageLoop, | 150 &QuitMessageLoop, |
| 139 &GetLiveObjectsForInstance, | 151 &GetLiveObjectsForInstance, |
| 140 &IsOutOfProcess, | 152 &IsOutOfProcess, |
| 141 &SimulateInputEvent, | 153 &IsPeripheral, |
| 142 &GetDocumentURL, | 154 &SimulateInputEvent, |
| 143 &GetLiveVars, | 155 &GetDocumentURL, |
| 144 &SetMinimumArrayBufferSizeForShmem, | 156 &GetLiveVars, |
| 145 &RunV8GC | 157 &SetMinimumArrayBufferSizeForShmem, |
| 146 }; | 158 &RunV8GC}; |
| 147 | 159 |
| 148 } // namespace | 160 } // namespace |
| 149 | 161 |
| 150 PPB_Testing_Proxy::PPB_Testing_Proxy(Dispatcher* dispatcher) | 162 PPB_Testing_Proxy::PPB_Testing_Proxy(Dispatcher* dispatcher) |
| 151 : InterfaceProxy(dispatcher), | 163 : InterfaceProxy(dispatcher), |
| 152 ppb_testing_impl_(NULL) { | 164 ppb_testing_impl_(NULL) { |
| 153 if (!dispatcher->IsPlugin()) { | 165 if (!dispatcher->IsPlugin()) { |
| 154 ppb_testing_impl_ = static_cast<const PPB_Testing_Private*>( | 166 ppb_testing_impl_ = static_cast<const PPB_Testing_Private*>( |
| 155 dispatcher->local_get_interface()(PPB_TESTING_PRIVATE_INTERFACE)); | 167 dispatcher->local_get_interface()(PPB_TESTING_PRIVATE_INTERFACE)); |
| 156 } | 168 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 167 bool PPB_Testing_Proxy::OnMessageReceived(const IPC::Message& msg) { | 179 bool PPB_Testing_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 168 if (!dispatcher()->permissions().HasPermission(PERMISSION_TESTING)) | 180 if (!dispatcher()->permissions().HasPermission(PERMISSION_TESTING)) |
| 169 return false; | 181 return false; |
| 170 | 182 |
| 171 bool handled = true; | 183 bool handled = true; |
| 172 IPC_BEGIN_MESSAGE_MAP(PPB_Testing_Proxy, msg) | 184 IPC_BEGIN_MESSAGE_MAP(PPB_Testing_Proxy, msg) |
| 173 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_ReadImageData, | 185 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_ReadImageData, |
| 174 OnMsgReadImageData) | 186 OnMsgReadImageData) |
| 175 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance, | 187 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance, |
| 176 OnMsgGetLiveObjectsForInstance) | 188 OnMsgGetLiveObjectsForInstance) |
| 189 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_IsPeripheral, OnMsgIsPeripheral) |
| 177 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_SimulateInputEvent, | 190 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_SimulateInputEvent, |
| 178 OnMsgSimulateInputEvent) | 191 OnMsgSimulateInputEvent) |
| 179 IPC_MESSAGE_HANDLER( | 192 IPC_MESSAGE_HANDLER( |
| 180 PpapiHostMsg_PPBTesting_SetMinimumArrayBufferSizeForShmem, | 193 PpapiHostMsg_PPBTesting_SetMinimumArrayBufferSizeForShmem, |
| 181 OnMsgSetMinimumArrayBufferSizeForShmem) | 194 OnMsgSetMinimumArrayBufferSizeForShmem) |
| 182 IPC_MESSAGE_UNHANDLED(handled = false) | 195 IPC_MESSAGE_UNHANDLED(handled = false) |
| 183 IPC_END_MESSAGE_MAP() | 196 IPC_END_MESSAGE_MAP() |
| 184 return handled; | 197 return handled; |
| 185 } | 198 } |
| 186 | 199 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 199 | 212 |
| 200 void PPB_Testing_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) { | 213 void PPB_Testing_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) { |
| 201 ppb_testing_impl_->QuitMessageLoop(instance); | 214 ppb_testing_impl_->QuitMessageLoop(instance); |
| 202 } | 215 } |
| 203 | 216 |
| 204 void PPB_Testing_Proxy::OnMsgGetLiveObjectsForInstance(PP_Instance instance, | 217 void PPB_Testing_Proxy::OnMsgGetLiveObjectsForInstance(PP_Instance instance, |
| 205 uint32_t* result) { | 218 uint32_t* result) { |
| 206 *result = ppb_testing_impl_->GetLiveObjectsForInstance(instance); | 219 *result = ppb_testing_impl_->GetLiveObjectsForInstance(instance); |
| 207 } | 220 } |
| 208 | 221 |
| 222 void PPB_Testing_Proxy::OnMsgIsPeripheral(PP_Instance instance, |
| 223 PP_Bool* result) { |
| 224 *result = ppb_testing_impl_->IsPeripheral(instance); |
| 225 } |
| 226 |
| 209 void PPB_Testing_Proxy::OnMsgSimulateInputEvent( | 227 void PPB_Testing_Proxy::OnMsgSimulateInputEvent( |
| 210 PP_Instance instance, | 228 PP_Instance instance, |
| 211 const InputEventData& input_event) { | 229 const InputEventData& input_event) { |
| 212 scoped_refptr<PPB_InputEvent_Shared> input_event_impl( | 230 scoped_refptr<PPB_InputEvent_Shared> input_event_impl( |
| 213 new PPB_InputEvent_Shared(OBJECT_IS_PROXY, instance, input_event)); | 231 new PPB_InputEvent_Shared(OBJECT_IS_PROXY, instance, input_event)); |
| 214 ppb_testing_impl_->SimulateInputEvent(instance, | 232 ppb_testing_impl_->SimulateInputEvent(instance, |
| 215 input_event_impl->pp_resource()); | 233 input_event_impl->pp_resource()); |
| 216 } | 234 } |
| 217 | 235 |
| 218 void PPB_Testing_Proxy::OnMsgSetMinimumArrayBufferSizeForShmem( | 236 void PPB_Testing_Proxy::OnMsgSetMinimumArrayBufferSizeForShmem( |
| 219 uint32_t threshold) { | 237 uint32_t threshold) { |
| 220 RawVarDataGraph::SetMinimumArrayBufferSizeForShmemForTest(threshold); | 238 RawVarDataGraph::SetMinimumArrayBufferSizeForShmemForTest(threshold); |
| 221 } | 239 } |
| 222 | 240 |
| 223 } // namespace proxy | 241 } // namespace proxy |
| 224 } // namespace ppapi | 242 } // namespace ppapi |
| OLD | NEW |