OLD | NEW |
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 CONTENT_RENDERER_PEPPER_MESSAGE_CHANNEL_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_MESSAGE_CHANNEL_H_ |
6 #define CONTENT_RENDERER_PEPPER_MESSAGE_CHANNEL_H_ | 6 #define CONTENT_RENDERER_PEPPER_MESSAGE_CHANNEL_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <list> | 9 #include <list> |
10 | 10 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // also trusted plugins for which we will continue to support synchronous | 104 // also trusted plugins for which we will continue to support synchronous |
105 // scripting. | 105 // scripting. |
106 NPObject* passthrough_object_; | 106 NPObject* passthrough_object_; |
107 | 107 |
108 // The NPObject we use to expose postMessage to JavaScript. | 108 // The NPObject we use to expose postMessage to JavaScript. |
109 MessageChannelNPObject* np_object_; | 109 MessageChannelNPObject* np_object_; |
110 | 110 |
111 // Post a message to the onmessage handler for this channel's instance | 111 // Post a message to the onmessage handler for this channel's instance |
112 // synchronously. This is used by PostMessageToJavaScript. | 112 // synchronously. This is used by PostMessageToJavaScript. |
113 void PostMessageToJavaScriptImpl( | 113 void PostMessageToJavaScriptImpl( |
114 const WebKit::WebSerializedScriptValue& message_data); | 114 const blink::WebSerializedScriptValue& message_data); |
115 // Post a message to the PPP_Instance HandleMessage function for this | 115 // Post a message to the PPP_Instance HandleMessage function for this |
116 // channel's instance. This is used by PostMessageToNative. | 116 // channel's instance. This is used by PostMessageToNative. |
117 void PostMessageToNativeImpl(PP_Var message_data); | 117 void PostMessageToNativeImpl(PP_Var message_data); |
118 | 118 |
119 void DrainEarlyMessageQueue(); | 119 void DrainEarlyMessageQueue(); |
120 | 120 |
121 // TODO(teravest): Remove all the tricky DRAIN_CANCELLED logic once | 121 // TODO(teravest): Remove all the tricky DRAIN_CANCELLED logic once |
122 // PluginInstance::ResetAsProxied() is gone. | 122 // PluginInstance::ResetAsProxied() is gone. |
123 std::deque<WebKit::WebSerializedScriptValue> early_message_queue_; | 123 std::deque<blink::WebSerializedScriptValue> early_message_queue_; |
124 enum EarlyMessageQueueState { | 124 enum EarlyMessageQueueState { |
125 QUEUE_MESSAGES, // Queue JS messages. | 125 QUEUE_MESSAGES, // Queue JS messages. |
126 SEND_DIRECTLY, // Post JS messages directly. | 126 SEND_DIRECTLY, // Post JS messages directly. |
127 DRAIN_PENDING, // Drain queue, then transition to DIRECT. | 127 DRAIN_PENDING, // Drain queue, then transition to DIRECT. |
128 DRAIN_CANCELLED // Preempt drain, go back to QUEUE. | 128 DRAIN_CANCELLED // Preempt drain, go back to QUEUE. |
129 }; | 129 }; |
130 EarlyMessageQueueState early_message_queue_state_; | 130 EarlyMessageQueueState early_message_queue_state_; |
131 | 131 |
132 // This queue stores vars that have been converted from NPVariants. Because | 132 // This queue stores vars that have been converted from NPVariants. Because |
133 // conversion can happen asynchronously, the queue stores the var until all | 133 // conversion can happen asynchronously, the queue stores the var until all |
134 // previous vars have been converted before calling PostMessage to ensure that | 134 // previous vars have been converted before calling PostMessage to ensure that |
135 // the order in which messages are processed is preserved. | 135 // the order in which messages are processed is preserved. |
136 std::list<VarConversionResult> converted_var_queue_; | 136 std::list<VarConversionResult> converted_var_queue_; |
137 | 137 |
138 // This is used to ensure pending tasks will not fire after this object is | 138 // This is used to ensure pending tasks will not fire after this object is |
139 // destroyed. | 139 // destroyed. |
140 base::WeakPtrFactory<MessageChannel> weak_ptr_factory_; | 140 base::WeakPtrFactory<MessageChannel> weak_ptr_factory_; |
141 | 141 |
142 DISALLOW_COPY_AND_ASSIGN(MessageChannel); | 142 DISALLOW_COPY_AND_ASSIGN(MessageChannel); |
143 }; | 143 }; |
144 | 144 |
145 } // namespace content | 145 } // namespace content |
146 | 146 |
147 #endif // CONTENT_RENDERER_PEPPER_MESSAGE_CHANNEL_H_ | 147 #endif // CONTENT_RENDERER_PEPPER_MESSAGE_CHANNEL_H_ |
OLD | NEW |