Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(781)

Unified Diff: ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_testing_rpc_server.cc

Issue 8920005: Add TestingInstance::EvalScript method which posts a message that the test page can eval(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_testing_rpc_server.cc
===================================================================
--- ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_testing_rpc_server.cc (revision 114053)
+++ ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_testing_rpc_server.cc (working copy)
@@ -17,7 +17,9 @@
#include "srpcgen/ppb_rpc.h"
using ppapi_proxy::DebugPrintf;
+using ppapi_proxy::DeserializeTo;
using ppapi_proxy::PPBTestingInterface;
+using ppapi_proxy::SerializeTo;
void PpbTestingRpcServer::PPB_Testing_ReadImageData(
NaClSrpcRpc* rpc,
@@ -90,4 +92,50 @@
rpc->result = NACL_SRPC_RESULT_OK;
}
+void PpbTestingRpcServer::PPB_Testing_SimulateInputEvent(
+ NaClSrpcRpc* rpc,
+ NaClSrpcClosure* done,
+ PP_Instance instance,
+ PP_Resource input_event) {
+ NaClSrpcClosureRunner runner(done);
+ rpc->result = NACL_SRPC_RESULT_APP_ERROR;
+ PPBTestingInterface()->SimulateInputEvent(instance, input_event);
+
+ DebugPrintf("PPB_Testing::SimulateInputEvent: instance=%"NACL_PRIu32"\n",
+ instance);
+ rpc->result = NACL_SRPC_RESULT_OK;
+}
+
+void PpbTestingRpcServer::PPB_Testing_ExecuteScript(
+ NaClSrpcRpc* rpc,
+ NaClSrpcClosure* done,
+ PP_Instance instance,
+ nacl_abi_size_t script_size, char* script_bytes,
+ nacl_abi_size_t* result_size, char* result_bytes,
+ nacl_abi_size_t* exception_size, char* exception_bytes) {
+ NaClSrpcClosureRunner runner(done);
+ rpc->result = NACL_SRPC_RESULT_APP_ERROR;
+
+ PP_Var script;
+ if (!DeserializeTo(script_bytes, script_size, 1, &script))
+ return;
+
+ PP_Var exception = PP_MakeUndefined();
+ PP_Var result =
+ PPBTestingInterface()->ExecuteScript(instance, script, &exception);
+
+ // The proxy can't serialize anything more complex than a string.
+ if (result.type > PP_VARTYPE_STRING)
+ result = PP_MakeUndefined();
+ if (exception.type > PP_VARTYPE_STRING)
+ exception = PP_MakeUndefined();
+
+ if (!SerializeTo(&result, result_bytes, result_size))
+ return;
+ if (!SerializeTo(&exception, exception_bytes, exception_size))
+ return;
+
+ rpc->result = NACL_SRPC_RESULT_OK;
+}
+

Powered by Google App Engine
This is Rietveld 408576698