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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/renderer/pepper/pepper_plugin_instance_impl.h" 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 #include "ppapi/proxy/url_loader_resource.h" 73 #include "ppapi/proxy/url_loader_resource.h"
74 #include "ppapi/shared_impl/ppapi_permissions.h" 74 #include "ppapi/shared_impl/ppapi_permissions.h"
75 #include "ppapi/shared_impl/ppapi_preferences.h" 75 #include "ppapi/shared_impl/ppapi_preferences.h"
76 #include "ppapi/shared_impl/ppb_gamepad_shared.h" 76 #include "ppapi/shared_impl/ppb_gamepad_shared.h"
77 #include "ppapi/shared_impl/ppb_input_event_shared.h" 77 #include "ppapi/shared_impl/ppb_input_event_shared.h"
78 #include "ppapi/shared_impl/ppb_url_util_shared.h" 78 #include "ppapi/shared_impl/ppb_url_util_shared.h"
79 #include "ppapi/shared_impl/ppb_view_shared.h" 79 #include "ppapi/shared_impl/ppb_view_shared.h"
80 #include "ppapi/shared_impl/ppp_instance_combined.h" 80 #include "ppapi/shared_impl/ppp_instance_combined.h"
81 #include "ppapi/shared_impl/resource.h" 81 #include "ppapi/shared_impl/resource.h"
82 #include "ppapi/shared_impl/scoped_pp_resource.h" 82 #include "ppapi/shared_impl/scoped_pp_resource.h"
83 #include "ppapi/shared_impl/scoped_pp_var.h"
83 #include "ppapi/shared_impl/time_conversion.h" 84 #include "ppapi/shared_impl/time_conversion.h"
84 #include "ppapi/shared_impl/url_request_info_data.h" 85 #include "ppapi/shared_impl/url_request_info_data.h"
85 #include "ppapi/shared_impl/var.h" 86 #include "ppapi/shared_impl/var.h"
86 #include "ppapi/thunk/enter.h" 87 #include "ppapi/thunk/enter.h"
87 #include "ppapi/thunk/ppb_buffer_api.h" 88 #include "ppapi/thunk/ppb_buffer_api.h"
88 #include "printing/metafile.h" 89 #include "printing/metafile.h"
89 #include "printing/metafile_skia_wrapper.h" 90 #include "printing/metafile_skia_wrapper.h"
90 #include "printing/units.h" 91 #include "printing/units.h"
91 #include "skia/ext/platform_canvas.h" 92 #include "skia/ext/platform_canvas.h"
92 #include "skia/ext/platform_device.h" 93 #include "skia/ext/platform_device.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 #endif 140 #endif
140 141
141 using base::StringPrintf; 142 using base::StringPrintf;
142 using ppapi::InputEventData; 143 using ppapi::InputEventData;
143 using ppapi::PpapiGlobals; 144 using ppapi::PpapiGlobals;
144 using ppapi::PPB_InputEvent_Shared; 145 using ppapi::PPB_InputEvent_Shared;
145 using ppapi::PPB_View_Shared; 146 using ppapi::PPB_View_Shared;
146 using ppapi::PPP_Instance_Combined; 147 using ppapi::PPP_Instance_Combined;
147 using ppapi::Resource; 148 using ppapi::Resource;
148 using ppapi::ScopedPPResource; 149 using ppapi::ScopedPPResource;
150 using ppapi::ScopedPPVar;
149 using ppapi::StringVar; 151 using ppapi::StringVar;
150 using ppapi::TrackedCallback; 152 using ppapi::TrackedCallback;
151 using ppapi::thunk::EnterResourceNoLock; 153 using ppapi::thunk::EnterResourceNoLock;
152 using ppapi::thunk::PPB_Buffer_API; 154 using ppapi::thunk::PPB_Buffer_API;
153 using ppapi::thunk::PPB_Gamepad_API; 155 using ppapi::thunk::PPB_Gamepad_API;
154 using ppapi::thunk::PPB_Graphics2D_API; 156 using ppapi::thunk::PPB_Graphics2D_API;
155 using ppapi::thunk::PPB_Graphics3D_API; 157 using ppapi::thunk::PPB_Graphics3D_API;
156 using ppapi::thunk::PPB_ImageData_API; 158 using ppapi::thunk::PPB_ImageData_API;
157 using ppapi::Var; 159 using ppapi::Var;
158 using ppapi::ArrayBufferVar; 160 using ppapi::ArrayBufferVar;
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 ppapi::Preferences(render_frame_->render_view()->webkit_preferences()), 817 ppapi::Preferences(render_frame_->render_view()->webkit_preferences()),
816 arg_names, 818 arg_names,
817 arg_values); 819 arg_values);
818 820
819 argn_ = arg_names; 821 argn_ = arg_names;
820 argv_ = arg_values; 822 argv_ = arg_values;
821 scoped_ptr<const char * []> argn_array(StringVectorToArgArray(argn_)); 823 scoped_ptr<const char * []> argn_array(StringVectorToArgArray(argn_));
822 scoped_ptr<const char * []> argv_array(StringVectorToArgArray(argv_)); 824 scoped_ptr<const char * []> argv_array(StringVectorToArgArray(argv_));
823 bool success = PP_ToBool(instance_interface_->DidCreate( 825 bool success = PP_ToBool(instance_interface_->DidCreate(
824 pp_instance(), argn_.size(), argn_array.get(), argv_array.get())); 826 pp_instance(), argn_.size(), argn_array.get(), argv_array.get()));
825 if (success) 827 // If this is a plugin that hosts external plugins, we should delay messages
826 message_channel_->StopQueueingJavaScriptMessages(); 828 // so that the child plugin that's created later will receive all the
829 // messages. (E.g., NaCl trusted plugin starting a child NaCl app.)
830 //
831 // A host for external plugins will call ResetAsProxied later, at which point
832 // we can Start() the message_channel_.
833 if (success && (!module_->renderer_ppapi_host()->IsExternalPluginHost()))
834 message_channel_->Start();
827 return success; 835 return success;
828 } 836 }
829 837
830 bool PepperPluginInstanceImpl::HandleDocumentLoad( 838 bool PepperPluginInstanceImpl::HandleDocumentLoad(
831 const blink::WebURLResponse& response) { 839 const blink::WebURLResponse& response) {
832 DCHECK(!document_loader_); 840 DCHECK(!document_loader_);
833 if (external_document_load_) { 841 if (external_document_load_) {
834 // The external proxy isn't available, so save the response and record 842 // The external proxy isn't available, so save the response and record
835 // document load notifications for later replay. 843 // document load notifications for later replay.
836 external_document_response_ = response; 844 external_document_response_ = response;
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 pp_instance(), event_resource->pp_resource())); 1113 pp_instance(), event_resource->pp_resource()));
1106 } 1114 }
1107 } 1115 }
1108 } 1116 }
1109 1117
1110 if (cursor_) 1118 if (cursor_)
1111 *cursor_info = *cursor_; 1119 *cursor_info = *cursor_;
1112 return rv; 1120 return rv;
1113 } 1121 }
1114 1122
1115 void PepperPluginInstanceImpl::HandleMessage(PP_Var message) { 1123 void PepperPluginInstanceImpl::HandleMessage(ScopedPPVar message) {
1116 TRACE_EVENT0("ppapi", "PepperPluginInstanceImpl::HandleMessage"); 1124 TRACE_EVENT0("ppapi", "PepperPluginInstanceImpl::HandleMessage");
1117 ppapi::proxy::HostDispatcher* dispatcher = 1125 ppapi::proxy::HostDispatcher* dispatcher =
1118 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); 1126 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance());
1119 if (!dispatcher || (message.type == PP_VARTYPE_OBJECT)) { 1127 if (!dispatcher || (message.get().type == PP_VARTYPE_OBJECT)) {
1120 // The dispatcher should always be valid, and the browser should never send 1128 // The dispatcher should always be valid, and the browser should never send
1121 // an 'object' var over PPP_Messaging. 1129 // an 'object' var over PPP_Messaging.
1122 NOTREACHED(); 1130 NOTREACHED();
1123 return; 1131 return;
1124 } 1132 }
1125 dispatcher->Send(new PpapiMsg_PPPMessaging_HandleMessage( 1133 dispatcher->Send(new PpapiMsg_PPPMessaging_HandleMessage(
1126 ppapi::API_ID_PPP_MESSAGING, 1134 ppapi::API_ID_PPP_MESSAGING,
1127 pp_instance(), 1135 pp_instance(),
1128 ppapi::proxy::SerializedVarSendInputShmem(dispatcher, message, 1136 ppapi::proxy::SerializedVarSendInputShmem(dispatcher, message.get(),
1129 pp_instance()))); 1137 pp_instance())));
1130 } 1138 }
1131 1139
1132 PP_Var PepperPluginInstanceImpl::GetInstanceObject() { 1140 PP_Var PepperPluginInstanceImpl::GetInstanceObject() {
1133 // Keep a reference on the stack. See NOTE above. 1141 // Keep a reference on the stack. See NOTE above.
1134 scoped_refptr<PepperPluginInstanceImpl> ref(this); 1142 scoped_refptr<PepperPluginInstanceImpl> ref(this);
1135 1143
1136 // If the plugin supports the private instance interface, try to retrieve its 1144 // If the plugin supports the private instance interface, try to retrieve its
1137 // instance object. 1145 // instance object.
1138 if (LoadPrivateInterface()) 1146 if (LoadPrivateInterface())
(...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after
2729 components); 2737 components);
2730 } 2738 }
2731 2739
2732 PP_ExternalPluginResult PepperPluginInstanceImpl::ResetAsProxied( 2740 PP_ExternalPluginResult PepperPluginInstanceImpl::ResetAsProxied(
2733 scoped_refptr<PluginModule> module) { 2741 scoped_refptr<PluginModule> module) {
2734 // Save the original module and switch over to the new one now that this 2742 // Save the original module and switch over to the new one now that this
2735 // plugin is using the IPC-based proxy. 2743 // plugin is using the IPC-based proxy.
2736 original_module_ = module_; 2744 original_module_ = module_;
2737 module_ = module; 2745 module_ = module;
2738 2746
2739 // Don't send any messages to the plugin until DidCreate() has finished.
2740 message_channel_->QueueJavaScriptMessages();
2741
2742 // For NaCl instances, remember the NaCl plugin instance interface, so we 2747 // For NaCl instances, remember the NaCl plugin instance interface, so we
2743 // can shut it down by calling its DidDestroy in our Delete() method. 2748 // can shut it down by calling its DidDestroy in our Delete() method.
2744 original_instance_interface_.reset(instance_interface_.release()); 2749 original_instance_interface_.reset(instance_interface_.release());
2745 2750
2746 base::Callback<const void*(const char*)> get_plugin_interface_func = 2751 base::Callback<const void*(const char*)> get_plugin_interface_func =
2747 base::Bind(&PluginModule::GetPluginInterface, module_.get()); 2752 base::Bind(&PluginModule::GetPluginInterface, module_.get());
2748 PPP_Instance_Combined* ppp_instance_combined = 2753 PPP_Instance_Combined* ppp_instance_combined =
2749 PPP_Instance_Combined::Create(get_plugin_interface_func); 2754 PPP_Instance_Combined::Create(get_plugin_interface_func);
2750 if (!ppp_instance_combined) { 2755 if (!ppp_instance_combined) {
2751 // The proxy must support at least one usable PPP_Instance interface. 2756 // The proxy must support at least one usable PPP_Instance interface.
(...skipping 15 matching lines...) Expand all
2767 plugin_selection_interface_ = NULL; 2772 plugin_selection_interface_ = NULL;
2768 plugin_textinput_interface_ = NULL; 2773 plugin_textinput_interface_ = NULL;
2769 plugin_zoom_interface_ = NULL; 2774 plugin_zoom_interface_ = NULL;
2770 2775
2771 // Re-send the DidCreate event via the proxy. 2776 // Re-send the DidCreate event via the proxy.
2772 scoped_ptr<const char * []> argn_array(StringVectorToArgArray(argn_)); 2777 scoped_ptr<const char * []> argn_array(StringVectorToArgArray(argn_));
2773 scoped_ptr<const char * []> argv_array(StringVectorToArgArray(argv_)); 2778 scoped_ptr<const char * []> argv_array(StringVectorToArgArray(argv_));
2774 if (!instance_interface_->DidCreate( 2779 if (!instance_interface_->DidCreate(
2775 pp_instance(), argn_.size(), argn_array.get(), argv_array.get())) 2780 pp_instance(), argn_.size(), argn_array.get(), argv_array.get()))
2776 return PP_EXTERNAL_PLUGIN_ERROR_INSTANCE; 2781 return PP_EXTERNAL_PLUGIN_ERROR_INSTANCE;
2777 message_channel_->StopQueueingJavaScriptMessages(); 2782 message_channel_->Start();
2778 2783
2779 // Clear sent_initial_did_change_view_ and cancel any pending DidChangeView 2784 // Clear sent_initial_did_change_view_ and cancel any pending DidChangeView
2780 // event. This way, SendDidChangeView will send the "current" view 2785 // event. This way, SendDidChangeView will send the "current" view
2781 // immediately (before other events like HandleDocumentLoad). 2786 // immediately (before other events like HandleDocumentLoad).
2782 sent_initial_did_change_view_ = false; 2787 sent_initial_did_change_view_ = false;
2783 view_change_weak_ptr_factory_.InvalidateWeakPtrs(); 2788 view_change_weak_ptr_factory_.InvalidateWeakPtrs();
2784 SendDidChangeView(); 2789 SendDidChangeView();
2785 2790
2786 DCHECK(external_document_load_); 2791 DCHECK(external_document_load_);
2787 external_document_load_ = false; 2792 external_document_load_ = false;
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
3138 // Running out-of-process. Initiate an IPC call to notify the plugin 3143 // Running out-of-process. Initiate an IPC call to notify the plugin
3139 // process. 3144 // process.
3140 ppapi::proxy::HostDispatcher* dispatcher = 3145 ppapi::proxy::HostDispatcher* dispatcher =
3141 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); 3146 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance());
3142 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( 3147 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad(
3143 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); 3148 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data));
3144 } 3149 }
3145 } 3150 }
3146 3151
3147 } // namespace content 3152 } // namespace content
OLDNEW
« 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