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

Unified Diff: ppapi/proxy/ppb_testing_proxy.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/proxy/ppb_testing_proxy.cc
===================================================================
--- ppapi/proxy/ppb_testing_proxy.cc (revision 114053)
+++ ppapi/proxy/ppb_testing_proxy.cc (working copy)
@@ -9,6 +9,7 @@
#include "ppapi/proxy/enter_proxy.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/serialized_var.h"
#include "ppapi/shared_impl/ppapi_globals.h"
#include "ppapi/shared_impl/resource.h"
#include "ppapi/shared_impl/resource_tracker.h"
@@ -87,13 +88,31 @@
API_ID_PPB_TESTING, instance_id, input_event_data));
}
+PP_Var ExecuteScript(PP_Instance instance,
+ PP_Var script,
+ PP_Var* exception) {
+ PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
+ if (!dispatcher)
+ return PP_MakeUndefined();
+ ReceiveSerializedException se(dispatcher, exception);
+ if (se.IsThrown())
+ return PP_MakeUndefined();
+
+ ReceiveSerializedVarReturnValue result;
+ dispatcher->Send(new PpapiHostMsg_PPBTesting_ExecuteScript(
+ API_ID_PPB_TESTING, instance,
+ SerializedVarSendInput(dispatcher, script), &se, &result));
+ return result.Return(dispatcher);
+}
+
const PPB_Testing_Dev testing_interface = {
&ReadImageData,
&RunMessageLoop,
&QuitMessageLoop,
&GetLiveObjectsForInstance,
&IsOutOfProcess,
- &SimulateInputEvent
+ &SimulateInputEvent,
+ &ExecuteScript
};
InterfaceProxy* CreateTestingProxy(Dispatcher* dispatcher) {
@@ -127,6 +146,12 @@
}
bool PPB_Testing_Proxy::OnMessageReceived(const IPC::Message& msg) {
+ // Prevent the dispatcher from going away during a call to ExecuteScript.
+ // This must happen OUTSIDE of ExecuteScript since the SerializedVars use
+ // the dispatcher upon return of the function (converting the
+ // SerializedVarReturnValue/OutParam to a SerializedVar in the destructor).
+ ScopedModuleReference death_grip(dispatcher());
+
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PPB_Testing_Proxy, msg)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_ReadImageData,
@@ -135,6 +160,8 @@
OnMsgGetLiveObjectsForInstance)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_SimulateInputEvent,
OnMsgSimulateInputEvent)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_ExecuteScript,
+ OnMsgExecuteScript)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -173,5 +200,21 @@
input_event_impl->pp_resource());
}
+void PPB_Testing_Proxy::OnMsgExecuteScript(
+ PP_Instance instance,
+ SerializedVarReceiveInput script,
+ SerializedVarOutParam out_exception,
+ SerializedVarReturnValue result) {
+ if (dispatcher()->IsPlugin())
+ NOTREACHED();
+ else
+ static_cast<HostDispatcher*>(dispatcher())->set_allow_plugin_reentrancy();
+
+ result.Return(dispatcher(), ppb_testing_impl_->ExecuteScript(
+ instance,
+ script.Get(dispatcher()),
+ out_exception.OutParam(dispatcher())));
+}
+
} // namespace proxy
} // namespace ppapi

Powered by Google App Engine
This is Rietveld 408576698