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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 public ppapi::proxy::HostDispatcher::SyncMessageStatusObserver { | 54 public ppapi::proxy::HostDispatcher::SyncMessageStatusObserver { |
55 public: | 55 public: |
56 static gin::WrapperInfo kWrapperInfo; | 56 static gin::WrapperInfo kWrapperInfo; |
57 | 57 |
58 // Creates a MessageChannel, returning a pointer to it and sets |result| to | 58 // Creates a MessageChannel, returning a pointer to it and sets |result| to |
59 // the v8 object which is backed by the message channel. The returned pointer | 59 // the v8 object which is backed by the message channel. The returned pointer |
60 // is only valid as long as the object in |result| is alive. | 60 // is only valid as long as the object in |result| is alive. |
61 static MessageChannel* Create(PepperPluginInstanceImpl* instance, | 61 static MessageChannel* Create(PepperPluginInstanceImpl* instance, |
62 v8::Persistent<v8::Object>* result); | 62 v8::Persistent<v8::Object>* result); |
63 | 63 |
64 virtual ~MessageChannel(); | 64 ~MessageChannel() override; |
65 | 65 |
66 // Called when the instance is deleted. The MessageChannel might outlive the | 66 // Called when the instance is deleted. The MessageChannel might outlive the |
67 // plugin instance because it is garbage collected. | 67 // plugin instance because it is garbage collected. |
68 void InstanceDeleted(); | 68 void InstanceDeleted(); |
69 | 69 |
70 // Post a message to the onmessage handler for this channel's instance | 70 // Post a message to the onmessage handler for this channel's instance |
71 // asynchronously. | 71 // asynchronously. |
72 void PostMessageToJavaScript(PP_Var message_data); | 72 void PostMessageToJavaScript(PP_Var message_data); |
73 | 73 |
74 // Messages are queued initially. After the PepperPluginInstanceImpl is ready | 74 // Messages are queued initially. After the PepperPluginInstanceImpl is ready |
(...skipping 11 matching lines...) Expand all Loading... |
86 | 86 |
87 void SetReadOnlyProperty(PP_Var key, PP_Var value); | 87 void SetReadOnlyProperty(PP_Var key, PP_Var value); |
88 | 88 |
89 private: | 89 private: |
90 // Struct for storing the result of a v8 object being converted to a PP_Var. | 90 // Struct for storing the result of a v8 object being converted to a PP_Var. |
91 struct VarConversionResult; | 91 struct VarConversionResult; |
92 | 92 |
93 explicit MessageChannel(PepperPluginInstanceImpl* instance); | 93 explicit MessageChannel(PepperPluginInstanceImpl* instance); |
94 | 94 |
95 // gin::NamedPropertyInterceptor | 95 // gin::NamedPropertyInterceptor |
96 virtual v8::Local<v8::Value> GetNamedProperty( | 96 v8::Local<v8::Value> GetNamedProperty(v8::Isolate* isolate, |
97 v8::Isolate* isolate, | 97 const std::string& property) override; |
98 const std::string& property) override; | 98 bool SetNamedProperty(v8::Isolate* isolate, |
99 virtual bool SetNamedProperty(v8::Isolate* isolate, | 99 const std::string& property, |
100 const std::string& property, | 100 v8::Local<v8::Value> value) override; |
101 v8::Local<v8::Value> value) override; | 101 std::vector<std::string> EnumerateNamedProperties( |
102 virtual std::vector<std::string> EnumerateNamedProperties( | |
103 v8::Isolate* isolate) override; | 102 v8::Isolate* isolate) override; |
104 | 103 |
105 // gin::Wrappable | 104 // gin::Wrappable |
106 virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder( | 105 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
107 v8::Isolate* isolate) override; | 106 v8::Isolate* isolate) override; |
108 | 107 |
109 // ppapi::proxy::HostDispatcher::SyncMessageStatusObserver | 108 // ppapi::proxy::HostDispatcher::SyncMessageStatusObserver |
110 virtual void BeginBlockOnSyncMessage() override; | 109 void BeginBlockOnSyncMessage() override; |
111 virtual void EndBlockOnSyncMessage() override; | 110 void EndBlockOnSyncMessage() override; |
112 | 111 |
113 // Post a message to the plugin's HandleMessage function for this channel's | 112 // Post a message to the plugin's HandleMessage function for this channel's |
114 // instance. | 113 // instance. |
115 void PostMessageToNative(gin::Arguments* args); | 114 void PostMessageToNative(gin::Arguments* args); |
116 // Post a message to the plugin's HandleBlocking Message function for this | 115 // Post a message to the plugin's HandleBlocking Message function for this |
117 // channel's instance synchronously, and return a result. | 116 // channel's instance synchronously, and return a result. |
118 void PostBlockingMessageToNative(gin::Arguments* args); | 117 void PostBlockingMessageToNative(gin::Arguments* args); |
119 | 118 |
120 // Post a message to the onmessage handler for this channel's instance | 119 // Post a message to the onmessage handler for this channel's instance |
121 // synchronously. This is used by PostMessageToJavaScript. | 120 // synchronously. This is used by PostMessageToJavaScript. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // This is used to ensure pending tasks will not fire after this object is | 189 // This is used to ensure pending tasks will not fire after this object is |
191 // destroyed. | 190 // destroyed. |
192 base::WeakPtrFactory<MessageChannel> weak_ptr_factory_; | 191 base::WeakPtrFactory<MessageChannel> weak_ptr_factory_; |
193 | 192 |
194 DISALLOW_COPY_AND_ASSIGN(MessageChannel); | 193 DISALLOW_COPY_AND_ASSIGN(MessageChannel); |
195 }; | 194 }; |
196 | 195 |
197 } // namespace content | 196 } // namespace content |
198 | 197 |
199 #endif // CONTENT_RENDERER_PEPPER_MESSAGE_CHANNEL_H_ | 198 #endif // CONTENT_RENDERER_PEPPER_MESSAGE_CHANNEL_H_ |
OLD | NEW |