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 #include <map> | 10 #include <map> |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 // Messages are queued initially. After the PepperPluginInstanceImpl is ready | 75 // Messages are queued initially. After the PepperPluginInstanceImpl is ready |
76 // to send and handle messages, users of MessageChannel should call | 76 // to send and handle messages, users of MessageChannel should call |
77 // Start(). | 77 // Start(). |
78 void Start(); | 78 void Start(); |
79 | 79 |
80 // Set the V8Object to which we should forward any calls which aren't | 80 // Set the V8Object to which we should forward any calls which aren't |
81 // related to postMessage. Note that this can be empty; it only gets set if | 81 // related to postMessage. Note that this can be empty; it only gets set if |
82 // there is a scriptable 'InstanceObject' associated with this channel's | 82 // there is a scriptable 'InstanceObject' associated with this channel's |
83 // instance. | 83 // instance. |
84 void SetPassthroughObject(v8::Handle<v8::Object> passthrough); | 84 void SetPassthroughObject(v8::Local<v8::Object> passthrough); |
85 | 85 |
86 PepperPluginInstanceImpl* instance() { return instance_; } | 86 PepperPluginInstanceImpl* instance() { return instance_; } |
87 | 87 |
88 void SetReadOnlyProperty(PP_Var key, PP_Var value); | 88 void SetReadOnlyProperty(PP_Var key, PP_Var value); |
89 | 89 |
90 private: | 90 private: |
91 // Struct for storing the result of a v8 object being converted to a PP_Var. | 91 // Struct for storing the result of a v8 object being converted to a PP_Var. |
92 struct VarConversionResult; | 92 struct VarConversionResult; |
93 | 93 |
94 explicit MessageChannel(PepperPluginInstanceImpl* instance); | 94 explicit MessageChannel(PepperPluginInstanceImpl* instance); |
(...skipping 22 matching lines...) Expand all Loading... |
117 // channel's instance synchronously, and return a result. | 117 // channel's instance synchronously, and return a result. |
118 void PostBlockingMessageToNative(gin::Arguments* args); | 118 void PostBlockingMessageToNative(gin::Arguments* args); |
119 | 119 |
120 // Post a message to the onmessage handler for this channel's instance | 120 // Post a message to the onmessage handler for this channel's instance |
121 // synchronously. This is used by PostMessageToJavaScript. | 121 // synchronously. This is used by PostMessageToJavaScript. |
122 void PostMessageToJavaScriptImpl( | 122 void PostMessageToJavaScriptImpl( |
123 const blink::WebSerializedScriptValue& message_data); | 123 const blink::WebSerializedScriptValue& message_data); |
124 | 124 |
125 PluginObject* GetPluginObject(v8::Isolate* isolate); | 125 PluginObject* GetPluginObject(v8::Isolate* isolate); |
126 | 126 |
127 void EnqueuePluginMessage(v8::Handle<v8::Value> v8_value); | 127 void EnqueuePluginMessage(v8::Local<v8::Value> v8_value); |
128 | 128 |
129 void FromV8ValueComplete(VarConversionResult* result_holder, | 129 void FromV8ValueComplete(VarConversionResult* result_holder, |
130 const ppapi::ScopedPPVar& result_var, | 130 const ppapi::ScopedPPVar& result_var, |
131 bool success); | 131 bool success); |
132 | 132 |
133 // Drain the queue of messages that are going to the plugin. All "completed" | 133 // Drain the queue of messages that are going to the plugin. All "completed" |
134 // messages at the head of the queue will be sent; any messages awaiting | 134 // messages at the head of the queue will be sent; any messages awaiting |
135 // conversion as well as messages after that in the queue will not be sent. | 135 // conversion as well as messages after that in the queue will not be sent. |
136 void DrainCompletedPluginMessages(); | 136 void DrainCompletedPluginMessages(); |
137 // Drain the queue of messages that are going to JavaScript. | 137 // Drain the queue of messages that are going to JavaScript. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // This is used to ensure pending tasks will not fire after this object is | 197 // This is used to ensure pending tasks will not fire after this object is |
198 // destroyed. | 198 // destroyed. |
199 base::WeakPtrFactory<MessageChannel> weak_ptr_factory_; | 199 base::WeakPtrFactory<MessageChannel> weak_ptr_factory_; |
200 | 200 |
201 DISALLOW_COPY_AND_ASSIGN(MessageChannel); | 201 DISALLOW_COPY_AND_ASSIGN(MessageChannel); |
202 }; | 202 }; |
203 | 203 |
204 } // namespace content | 204 } // namespace content |
205 | 205 |
206 #endif // CONTENT_RENDERER_PEPPER_MESSAGE_CHANNEL_H_ | 206 #endif // CONTENT_RENDERER_PEPPER_MESSAGE_CHANNEL_H_ |
OLD | NEW |