| 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 "native_client/src/shared/ppapi_proxy/plugin_ppb_testing.h" | 5 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_testing.h" |
| 6 | 6 |
| 7 #include "native_client/src/include/nacl_scoped_ptr.h" | 7 #include "native_client/src/include/nacl_scoped_ptr.h" |
| 8 #include "native_client/src/include/portability.h" | 8 #include "native_client/src/include/portability.h" |
| 9 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" | 9 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" |
| 10 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" | 10 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 90 } |
| 91 | 91 |
| 92 PP_Bool IsOutOfProcess() { | 92 PP_Bool IsOutOfProcess() { |
| 93 // The NaCl plugin is run in-process, and all calls are synchronous, so even | 93 // The NaCl plugin is run in-process, and all calls are synchronous, so even |
| 94 // though a NaCl module runs in a separate process, it behaves as if it were | 94 // though a NaCl module runs in a separate process, it behaves as if it were |
| 95 // in-process. Furthermore, calls off of the main thread are not supported | 95 // in-process. Furthermore, calls off of the main thread are not supported |
| 96 // (same as trusted in-process). | 96 // (same as trusted in-process). |
| 97 return PP_FALSE; | 97 return PP_FALSE; |
| 98 } | 98 } |
| 99 | 99 |
| 100 void SimulateInputEvent(PP_Instance instance, PP_Resource input_event) { |
| 101 DebugPrintf("PPB_Testing::SimulateInputEvent: instance=%"NACL_PRId32", " |
| 102 "input_event=%"NACL_PRId32"\n", |
| 103 instance, input_event); |
| 104 |
| 105 NaClSrpcError srpc_result = |
| 106 PpbTestingRpcClient::PPB_Testing_SimulateInputEvent(GetMainSrpcChannel(), |
| 107 instance, |
| 108 input_event); |
| 109 DebugPrintf("PPB_Testing::SimulateInputEvent: %s\n", |
| 110 NaClSrpcErrorString(srpc_result)); |
| 111 } |
| 112 |
| 113 PP_Var ExecuteScript(PP_Instance instance, PP_Var script, PP_Var* exception) { |
| 114 DebugPrintf("PPB_Testing::ExecuteScript: instance=%"NACL_PRId32", " |
| 115 "script=%"NACL_PRId32", exception=%"NACL_PRId32"\n", |
| 116 script, exception); |
| 117 |
| 118 nacl_abi_size_t script_size = kMaxVarSize; |
| 119 nacl::scoped_array<char> script_bytes(Serialize(&script, 1, &script_size)); |
| 120 nacl_abi_size_t exception_size = kMaxVarSize; |
| 121 nacl::scoped_array<char> exception_bytes(new char[kMaxVarSize]); |
| 122 nacl_abi_size_t result_size = kMaxVarSize; |
| 123 nacl::scoped_array<char> result_bytes(new char[kMaxVarSize]); |
| 124 |
| 125 NaClSrpcError srpc_result = |
| 126 PpbTestingRpcClient::PPB_Testing_ExecuteScript( |
| 127 GetMainSrpcChannel(), |
| 128 instance, |
| 129 script_size, script_bytes.get(), |
| 130 &exception_size, exception_bytes.get(), |
| 131 &result_size, result_bytes.get()); |
| 132 |
| 133 DebugPrintf("PPB_Testing::ExecuteScript: %s\n", |
| 134 NaClSrpcErrorString(srpc_result)); |
| 135 |
| 136 PP_Var result = PP_MakeUndefined(); |
| 137 if (srpc_result == NACL_SRPC_RESULT_OK) { |
| 138 (void) DeserializeTo(result_bytes.get(), result_size, 1, &result); |
| 139 (void) DeserializeTo(exception_bytes.get(), exception_size, 1, exception); |
| 140 } |
| 141 |
| 142 return result; |
| 143 } |
| 144 |
| 100 } // namespace | 145 } // namespace |
| 101 | 146 |
| 102 const PPB_Testing_Dev* PluginTesting::GetInterface() { | 147 const PPB_Testing_Dev* PluginTesting::GetInterface() { |
| 103 static const PPB_Testing_Dev testing_interface = { | 148 static const PPB_Testing_Dev testing_interface = { |
| 104 ReadImageData, | 149 ReadImageData, |
| 105 RunMessageLoop, | 150 RunMessageLoop, |
| 106 QuitMessageLoop, | 151 QuitMessageLoop, |
| 107 GetLiveObjectsForInstance, | 152 GetLiveObjectsForInstance, |
| 108 IsOutOfProcess | 153 IsOutOfProcess, |
| 154 SimulateInputEvent, |
| 155 ExecuteScript |
| 109 }; | 156 }; |
| 110 return &testing_interface; | 157 return &testing_interface; |
| 111 } | 158 } |
| 112 | 159 |
| 113 } // namespace ppapi_proxy | 160 } // namespace ppapi_proxy |
| OLD | NEW |