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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 WebKit::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 // This is used to ensure pending tasks will not fire after this object is | |
122 // destroyed. | |
123 base::WeakPtrFactory<MessageChannel> weak_ptr_factory_; | |
124 | |
125 // TODO(teravest): Remove all the tricky DRAIN_CANCELLED logic once | 121 // TODO(teravest): Remove all the tricky DRAIN_CANCELLED logic once |
126 // PluginInstance::ResetAsProxied() is gone. | 122 // PluginInstance::ResetAsProxied() is gone. |
127 std::deque<WebKit::WebSerializedScriptValue> early_message_queue_; | 123 std::deque<WebKit::WebSerializedScriptValue> early_message_queue_; |
128 enum EarlyMessageQueueState { | 124 enum EarlyMessageQueueState { |
129 QUEUE_MESSAGES, // Queue JS messages. | 125 QUEUE_MESSAGES, // Queue JS messages. |
130 SEND_DIRECTLY, // Post JS messages directly. | 126 SEND_DIRECTLY, // Post JS messages directly. |
131 DRAIN_PENDING, // Drain queue, then transition to DIRECT. | 127 DRAIN_PENDING, // Drain queue, then transition to DIRECT. |
132 DRAIN_CANCELLED // Preempt drain, go back to QUEUE. | 128 DRAIN_CANCELLED // Preempt drain, go back to QUEUE. |
133 }; | 129 }; |
134 EarlyMessageQueueState early_message_queue_state_; | 130 EarlyMessageQueueState early_message_queue_state_; |
135 | 131 |
136 // This queue stores vars that have been converted from NPVariants. Because | 132 // This queue stores vars that have been converted from NPVariants. Because |
137 // conversion can happen asynchronously, the queue stores the var until all | 133 // conversion can happen asynchronously, the queue stores the var until all |
138 // previous vars have been converted before calling PostMessage to ensure that | 134 // previous vars have been converted before calling PostMessage to ensure that |
139 // the order in which messages are processed is preserved. | 135 // the order in which messages are processed is preserved. |
140 std::list<VarConversionResult> converted_var_queue_; | 136 std::list<VarConversionResult> converted_var_queue_; |
141 | 137 |
| 138 // This is used to ensure pending tasks will not fire after this object is |
| 139 // destroyed. |
| 140 base::WeakPtrFactory<MessageChannel> weak_ptr_factory_; |
| 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 |