Index: content/renderer/pepper/message_channel.h |
diff --git a/content/renderer/pepper/message_channel.h b/content/renderer/pepper/message_channel.h |
index 3caef263db382f38427a5356c4dfb17d31e8c466..8a6e01c4a35c4befd849412abc4d1fea525eef42 100644 |
--- a/content/renderer/pepper/message_channel.h |
+++ b/content/renderer/pepper/message_channel.h |
@@ -14,6 +14,7 @@ |
#include "gin/handle.h" |
#include "gin/interceptor.h" |
#include "gin/wrappable.h" |
+#include "ppapi/proxy/host_dispatcher.h" |
#include "ppapi/shared_impl/resource.h" |
#include "third_party/WebKit/public/web/WebSerializedScriptValue.h" |
#include "v8/include/v8.h" |
@@ -46,8 +47,10 @@ class PluginObject; |
// - The message target won't be limited to instance, and should support |
// either plugin-provided or JS objects. |
// TODO(dmichael): Add support for separate MessagePorts. |
-class MessageChannel : public gin::Wrappable<MessageChannel>, |
- public gin::NamedPropertyInterceptor { |
+class MessageChannel : |
+ public gin::Wrappable<MessageChannel>, |
+ public gin::NamedPropertyInterceptor, |
+ public ppapi::proxy::HostDispatcher::SyncMessageStatusObserver { |
public: |
static gin::WrapperInfo kWrapperInfo; |
@@ -102,6 +105,10 @@ class MessageChannel : public gin::Wrappable<MessageChannel>, |
virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
v8::Isolate* isolate) OVERRIDE; |
+ // ppapi::proxy::HostDispatcher::SyncMessageStatusObserver |
+ virtual void BeginBlockOnSyncMessage() OVERRIDE; |
+ virtual void EndBlockOnSyncMessage() OVERRIDE; |
+ |
// Post a message to the plugin's HandleMessage function for this channel's |
// instance. |
void PostMessageToNative(gin::Arguments* args); |
@@ -123,7 +130,8 @@ class MessageChannel : public gin::Wrappable<MessageChannel>, |
bool success); |
void DrainCompletedPluginMessages(); |
- void DrainEarlyMessageQueue(); |
+ void DrainJSMessageQueue(); |
+ void DrainJSMessageQueueSoon(); |
raymes
2014/09/23 02:57:09
nit: a comment here might be good.
dmichael (off chromium)
2014/09/23 17:38:42
Done.
|
PepperPluginInstanceImpl* instance_; |
@@ -134,12 +142,20 @@ class MessageChannel : public gin::Wrappable<MessageChannel>, |
// scripting. |
v8::Persistent<v8::Object> passthrough_object_; |
- std::deque<blink::WebSerializedScriptValue> early_message_queue_; |
- enum EarlyMessageQueueState { |
- QUEUE_MESSAGES, // Queue JS messages. |
- SEND_DIRECTLY, // Post JS messages directly. |
+ enum MessageQueueState { |
+ WAITING_TO_START, // Waiting for Start() to be called. Queue messages. |
+ QUEUE_MESSAGES, // Queue messages temporarily. |
+ SEND_DIRECTLY, // Post messages directly. |
}; |
- EarlyMessageQueueState early_message_queue_state_; |
+ |
+ std::deque<blink::WebSerializedScriptValue> js_message_queue_; |
raymes
2014/09/23 02:57:09
nit: Maybe just add a comment // This queue stores
dmichael (off chromium)
2014/09/23 17:38:42
Done.
|
+ MessageQueueState js_message_queue_state_; |
+ // When the renderer is sending a blocking message to the plugin, we will |
+ // queue Plugin->JS messages temporarily to avoid re-entering JavaScript. This |
+ // counts how many blocking renderer->plugin messages are on the stack so that |
+ // we only begin sending messages to JavaScript again when the depth reaches |
+ // zero. |
+ int blocking_message_depth_; |
// This queue stores vars that are being sent to the plugin. Because |
// conversion can happen asynchronously for object types, the queue stores |
@@ -150,6 +166,7 @@ class MessageChannel : public gin::Wrappable<MessageChannel>, |
// calls to push_back or pop_front; hence why we're using list. (deque would |
// probably also work, but is less clearly specified). |
std::list<VarConversionResult> plugin_message_queue_; |
+ MessageQueueState plugin_message_queue_state_; |
std::map<std::string, ppapi::ScopedPPVar> internal_named_properties_; |