| 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> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "content/renderer/pepper/v8_var_converter.h" | 14 #include "content/renderer/pepper/v8_var_converter.h" |
| 15 #include "gin/handle.h" | 15 #include "gin/handle.h" |
| 16 #include "gin/interceptor.h" | 16 #include "gin/interceptor.h" |
| 17 #include "gin/wrappable.h" | 17 #include "gin/wrappable.h" |
| 18 #include "ppapi/proxy/host_dispatcher.h" | 18 #include "ppapi/proxy/host_dispatcher.h" |
| 19 #include "ppapi/shared_impl/resource.h" | 19 #include "ppapi/shared_impl/resource.h" |
| 20 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" | 20 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" |
| 21 #include "v8/include/v8-util.h" |
| 21 #include "v8/include/v8.h" | 22 #include "v8/include/v8.h" |
| 22 | 23 |
| 23 struct PP_Var; | 24 struct PP_Var; |
| 24 | 25 |
| 25 namespace gin { | 26 namespace gin { |
| 26 class Arguments; | 27 class Arguments; |
| 27 } // namespace gin | 28 } // namespace gin |
| 28 | 29 |
| 29 namespace ppapi { | 30 namespace ppapi { |
| 30 class ScopedPPVar; | 31 class ScopedPPVar; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 void DrainCompletedPluginMessages(); | 136 void DrainCompletedPluginMessages(); |
| 136 // Drain the queue of messages that are going to JavaScript. | 137 // Drain the queue of messages that are going to JavaScript. |
| 137 void DrainJSMessageQueue(); | 138 void DrainJSMessageQueue(); |
| 138 // PostTask to call DrainJSMessageQueue() soon. Use this when you want to | 139 // PostTask to call DrainJSMessageQueue() soon. Use this when you want to |
| 139 // send the messages, but can't immediately (e.g., because the instance is | 140 // send the messages, but can't immediately (e.g., because the instance is |
| 140 // not ready or JavaScript is on the stack). | 141 // not ready or JavaScript is on the stack). |
| 141 void DrainJSMessageQueueSoon(); | 142 void DrainJSMessageQueueSoon(); |
| 142 | 143 |
| 143 void UnregisterSyncMessageStatusObserver(); | 144 void UnregisterSyncMessageStatusObserver(); |
| 144 | 145 |
| 146 v8::Local<v8::FunctionTemplate> GetFunctionTemplate( |
| 147 v8::Isolate* isolate, |
| 148 const std::string& name, |
| 149 void (MessageChannel::*memberFuncPtr)(gin::Arguments* args)); |
| 150 |
| 145 PepperPluginInstanceImpl* instance_; | 151 PepperPluginInstanceImpl* instance_; |
| 146 | 152 |
| 147 // We pass all non-postMessage calls through to the passthrough_object_. | 153 // We pass all non-postMessage calls through to the passthrough_object_. |
| 148 // This way, a plugin can use PPB_Class or PPP_Class_Deprecated and also | 154 // This way, a plugin can use PPB_Class or PPP_Class_Deprecated and also |
| 149 // postMessage. This is necessary to support backwards-compatibility, and | 155 // postMessage. This is necessary to support backwards-compatibility, and |
| 150 // also trusted plugins for which we will continue to support synchronous | 156 // also trusted plugins for which we will continue to support synchronous |
| 151 // scripting. | 157 // scripting. |
| 152 v8::Persistent<v8::Object> passthrough_object_; | 158 v8::Persistent<v8::Object> passthrough_object_; |
| 153 | 159 |
| 154 enum MessageQueueState { | 160 enum MessageQueueState { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 179 MessageQueueState plugin_message_queue_state_; | 185 MessageQueueState plugin_message_queue_state_; |
| 180 | 186 |
| 181 std::map<std::string, ppapi::ScopedPPVar> internal_named_properties_; | 187 std::map<std::string, ppapi::ScopedPPVar> internal_named_properties_; |
| 182 | 188 |
| 183 V8VarConverter var_converter_; | 189 V8VarConverter var_converter_; |
| 184 | 190 |
| 185 // A callback to invoke at shutdown to ensure we unregister ourselves as | 191 // A callback to invoke at shutdown to ensure we unregister ourselves as |
| 186 // Observers for sync messages. | 192 // Observers for sync messages. |
| 187 base::Closure unregister_observer_callback_; | 193 base::Closure unregister_observer_callback_; |
| 188 | 194 |
| 195 v8::StdPersistentValueMap<std::string, v8::FunctionTemplate> template_cache_; |
| 196 |
| 189 // 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 |
| 190 // destroyed. | 198 // destroyed. |
| 191 base::WeakPtrFactory<MessageChannel> weak_ptr_factory_; | 199 base::WeakPtrFactory<MessageChannel> weak_ptr_factory_; |
| 192 | 200 |
| 193 DISALLOW_COPY_AND_ASSIGN(MessageChannel); | 201 DISALLOW_COPY_AND_ASSIGN(MessageChannel); |
| 194 }; | 202 }; |
| 195 | 203 |
| 196 } // namespace content | 204 } // namespace content |
| 197 | 205 |
| 198 #endif // CONTENT_RENDERER_PEPPER_MESSAGE_CHANNEL_H_ | 206 #endif // CONTENT_RENDERER_PEPPER_MESSAGE_CHANNEL_H_ |
| OLD | NEW |