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

Side by Side Diff: webkit/plugins/ppapi/message_channel.h

Issue 11490014: PPAPI: Make Messaging not PostTask and copy when out-of-process. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed NaCl plugins Created 8 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 unified diff | Download patch
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 #ifndef WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_ 5 #ifndef WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_
6 #define WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_ 6 #define WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_
7 7
8 #include <deque>
9
8 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
9 #include "ppapi/shared_impl/resource.h" 11 #include "ppapi/shared_impl/resource.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize dScriptValue.h"
10 #include "third_party/npapi/bindings/npruntime.h" 13 #include "third_party/npapi/bindings/npruntime.h"
11 14
12 struct PP_Var; 15 struct PP_Var;
13 namespace WebKit {
14 class WebSerializedScriptValue;
15 }
16 16
17 namespace webkit { 17 namespace webkit {
18 namespace ppapi { 18 namespace ppapi {
19 19
20 class PluginInstance; 20 class PluginInstance;
21 21
22 // MessageChannel implements bidirectional postMessage functionality, allowing 22 // MessageChannel implements bidirectional postMessage functionality, allowing
23 // calls from JavaScript to plugins and vice-versa. See 23 // calls from JavaScript to plugins and vice-versa. See
24 // PPB_Messaging::PostMessage and PPP_Messaging::HandleMessage for more 24 // PPB_Messaging::PostMessage and PPP_Messaging::HandleMessage for more
25 // information. 25 // information.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return passthrough_object_; 63 return passthrough_object_;
64 } 64 }
65 void SetPassthroughObject(NPObject* passthrough); 65 void SetPassthroughObject(NPObject* passthrough);
66 66
67 NPObject* np_object() { return np_object_; } 67 NPObject* np_object() { return np_object_; }
68 68
69 PluginInstance* instance() { 69 PluginInstance* instance() {
70 return instance_; 70 return instance_;
71 } 71 }
72 72
73 // Messages sent to JavaScript are queued by default. After the DOM is
74 // set up for the plugin, users of MessageChannel should call
75 // EndQueueingJavaScriptMessages to start dispatching messages to JavaScript.
76 void QueueJavaScriptMessages();
77 void EndQueueingJavaScriptMessages();
dmichael (off chromium) 2012/12/11 18:55:55 StopQueueingJavaScriptMessages? Slightly more impe
teravest 2012/12/11 21:32:12 Done.
78
73 private: 79 private:
74 PluginInstance* instance_; 80 PluginInstance* instance_;
75 81
76 // We pass all non-postMessage calls through to the passthrough_object_. 82 // We pass all non-postMessage calls through to the passthrough_object_.
77 // This way, a plugin can use PPB_Class or PPP_Class_Deprecated and also 83 // This way, a plugin can use PPB_Class or PPP_Class_Deprecated and also
78 // postMessage. This is necessary to support backwards-compatibility, and 84 // postMessage. This is necessary to support backwards-compatibility, and
79 // also trusted plugins for which we will continue to support synchronous 85 // also trusted plugins for which we will continue to support synchronous
80 // scripting. 86 // scripting.
81 NPObject* passthrough_object_; 87 NPObject* passthrough_object_;
82 88
83 // The NPObject we use to expose postMessage to JavaScript. 89 // The NPObject we use to expose postMessage to JavaScript.
84 MessageChannelNPObject* np_object_; 90 MessageChannelNPObject* np_object_;
85 91
86 // Post a message to the onmessage handler for this channel's instance 92 // Post a message to the onmessage handler for this channel's instance
87 // synchronously. This is used by PostMessageToJavaScript. 93 // synchronously. This is used by PostMessageToJavaScript.
88 void PostMessageToJavaScriptImpl( 94 void PostMessageToJavaScriptImpl(
89 const WebKit::WebSerializedScriptValue& message_data); 95 const WebKit::WebSerializedScriptValue& message_data);
90 // Post a message to the PPP_Instance HandleMessage function for this 96 // Post a message to the PPP_Instance HandleMessage function for this
91 // channel's instance. This is used by PostMessageToNative. 97 // channel's instance. This is used by PostMessageToNative.
92 void PostMessageToNativeImpl(PP_Var message_data); 98 void PostMessageToNativeImpl(PP_Var message_data);
93 99
100 void DrainEarlyMessageQueue();
101
94 // This is used to ensure pending tasks will not fire after this object is 102 // This is used to ensure pending tasks will not fire after this object is
95 // destroyed. 103 // destroyed.
96 base::WeakPtrFactory<MessageChannel> weak_ptr_factory_; 104 base::WeakPtrFactory<MessageChannel> weak_ptr_factory_;
97 105
106 bool queue_js_messages_;
107 std::deque<WebKit::WebSerializedScriptValue> early_message_queue_;
108
98 DISALLOW_COPY_AND_ASSIGN(MessageChannel); 109 DISALLOW_COPY_AND_ASSIGN(MessageChannel);
99 }; 110 };
100 111
101 } // namespace ppapi 112 } // namespace ppapi
102 } // namespace webkit 113 } // namespace webkit
103 114
104 #endif // WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_ 115 #endif // WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_
OLDNEW
« no previous file with comments | « no previous file | webkit/plugins/ppapi/message_channel.cc » ('j') | webkit/plugins/ppapi/message_channel.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698