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

Unified Diff: content/renderer/pepper/pepper_plugin_instance_impl.cc

Issue 290553004: PPAPI: Refactor MessageChannel to prep for sync postMessae (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move NaClHelper in to nacl namespace Created 6 years, 7 months 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: content/renderer/pepper/pepper_plugin_instance_impl.cc
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc
index 7d4670fe3e9b35359e21d7bb2fdcbed727eb74c4..b9bc30dcdd56e34a41d25aa2de4795523edf7c4c 100644
--- a/content/renderer/pepper/pepper_plugin_instance_impl.cc
+++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc
@@ -80,6 +80,7 @@
#include "ppapi/shared_impl/ppp_instance_combined.h"
#include "ppapi/shared_impl/resource.h"
#include "ppapi/shared_impl/scoped_pp_resource.h"
+#include "ppapi/shared_impl/scoped_pp_var.h"
#include "ppapi/shared_impl/time_conversion.h"
#include "ppapi/shared_impl/url_request_info_data.h"
#include "ppapi/shared_impl/var.h"
@@ -146,6 +147,7 @@ using ppapi::PPB_View_Shared;
using ppapi::PPP_Instance_Combined;
using ppapi::Resource;
using ppapi::ScopedPPResource;
+using ppapi::ScopedPPVar;
using ppapi::StringVar;
using ppapi::TrackedCallback;
using ppapi::thunk::EnterResourceNoLock;
@@ -822,8 +824,14 @@ bool PepperPluginInstanceImpl::Initialize(
scoped_ptr<const char * []> argv_array(StringVectorToArgArray(argv_));
bool success = PP_ToBool(instance_interface_->DidCreate(
pp_instance(), argn_.size(), argn_array.get(), argv_array.get()));
- if (success)
- message_channel_->StopQueueingJavaScriptMessages();
+ // If this is a plugin that hosts external plugins, we should delay messages
+ // so that the child plugin that's created later will receive all the
+ // messages. (E.g., NaCl trusted plugin starting a child NaCl app.)
+ //
+ // A host for external plugins will call ResetAsProxied later, at which point
+ // we can Start() the message_channel_.
+ if (success && (!module_->renderer_ppapi_host()->IsExternalPluginHost()))
+ message_channel_->Start();
return success;
}
@@ -1112,11 +1120,11 @@ bool PepperPluginInstanceImpl::HandleInputEvent(
return rv;
}
-void PepperPluginInstanceImpl::HandleMessage(PP_Var message) {
+void PepperPluginInstanceImpl::HandleMessage(ScopedPPVar message) {
TRACE_EVENT0("ppapi", "PepperPluginInstanceImpl::HandleMessage");
ppapi::proxy::HostDispatcher* dispatcher =
ppapi::proxy::HostDispatcher::GetForInstance(pp_instance());
- if (!dispatcher || (message.type == PP_VARTYPE_OBJECT)) {
+ if (!dispatcher || (message.get().type == PP_VARTYPE_OBJECT)) {
// The dispatcher should always be valid, and the browser should never send
// an 'object' var over PPP_Messaging.
NOTREACHED();
@@ -1125,7 +1133,7 @@ void PepperPluginInstanceImpl::HandleMessage(PP_Var message) {
dispatcher->Send(new PpapiMsg_PPPMessaging_HandleMessage(
ppapi::API_ID_PPP_MESSAGING,
pp_instance(),
- ppapi::proxy::SerializedVarSendInputShmem(dispatcher, message,
+ ppapi::proxy::SerializedVarSendInputShmem(dispatcher, message.get(),
pp_instance())));
}
@@ -2736,9 +2744,6 @@ PP_ExternalPluginResult PepperPluginInstanceImpl::ResetAsProxied(
original_module_ = module_;
module_ = module;
- // Don't send any messages to the plugin until DidCreate() has finished.
- message_channel_->QueueJavaScriptMessages();
-
// For NaCl instances, remember the NaCl plugin instance interface, so we
// can shut it down by calling its DidDestroy in our Delete() method.
original_instance_interface_.reset(instance_interface_.release());
@@ -2774,7 +2779,7 @@ PP_ExternalPluginResult PepperPluginInstanceImpl::ResetAsProxied(
if (!instance_interface_->DidCreate(
pp_instance(), argn_.size(), argn_array.get(), argv_array.get()))
return PP_EXTERNAL_PLUGIN_ERROR_INSTANCE;
- message_channel_->StopQueueingJavaScriptMessages();
+ message_channel_->Start();
// Clear sent_initial_did_change_view_ and cancel any pending DidChangeView
// event. This way, SendDidChangeView will send the "current" view
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_impl.h ('k') | content/renderer/pepper/renderer_ppapi_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698