Chromium Code Reviews| Index: webkit/plugins/ppapi/message_channel.h |
| diff --git a/webkit/plugins/ppapi/message_channel.h b/webkit/plugins/ppapi/message_channel.h |
| index 12f4c0b7c3c8935021339ef43f63e3fa60007cb0..b0ee40f10255da035b18bcc5b524270a6884ee4b 100644 |
| --- a/webkit/plugins/ppapi/message_channel.h |
| +++ b/webkit/plugins/ppapi/message_channel.h |
| @@ -5,14 +5,14 @@ |
| #ifndef WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_ |
| #define WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_ |
| +#include <deque> |
| + |
| #include "base/memory/weak_ptr.h" |
| #include "ppapi/shared_impl/resource.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerializedScriptValue.h" |
| #include "third_party/npapi/bindings/npruntime.h" |
| struct PP_Var; |
| -namespace WebKit { |
| -class WebSerializedScriptValue; |
| -} |
| namespace webkit { |
| namespace ppapi { |
| @@ -70,6 +70,12 @@ class MessageChannel { |
| return instance_; |
| } |
| + // Messages sent to JavaScript are queued by default. After the DOM is |
| + // set up for the plugin, users of MessageChannel should call |
| + // StopQueueingJavaScriptMessages to start dispatching messages to JavaScript. |
| + void QueueJavaScriptMessages(); |
| + void StopQueueingJavaScriptMessages(); |
| + |
| private: |
| PluginInstance* instance_; |
| @@ -91,10 +97,21 @@ class MessageChannel { |
| // channel's instance. This is used by PostMessageToNative. |
| void PostMessageToNativeImpl(PP_Var message_data); |
| + void DrainEarlyMessageQueue(); |
| + |
| // This is used to ensure pending tasks will not fire after this object is |
| // destroyed. |
| base::WeakPtrFactory<MessageChannel> weak_ptr_factory_; |
| + std::deque<WebKit::WebSerializedScriptValue> early_message_queue_; |
| + enum EarlyMessageQueueState { |
| + QUEUE, // Queue JS messages. |
|
dmichael (off chromium)
2012/12/11 22:35:30
I think it might be easier to understand with slig
teravest
2012/12/11 22:43:39
Done.
|
| + DIRECT, // Post JS messages directly. |
| + DRAIN, // Drain queue, then transition to DIRECT. |
| + DRAIN_CANCEL // Preempt drain, go back to QUEUE. |
| + }; |
| + EarlyMessageQueueState early_message_queue_state_; |
|
dmichael (off chromium)
2012/12/11 22:35:30
Can you add a TODO or file a bug to remove this st
teravest
2012/12/11 22:43:39
Done.
|
| + |
| DISALLOW_COPY_AND_ASSIGN(MessageChannel); |
| }; |