Chromium Code Reviews| 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 WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_ |
| 7 | 7 |
| 8 #include <deque> | |
| 9 | |
| 8 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 9 #include "ppapi/shared_impl/resource.h" | 11 #include "ppapi/shared_impl/resource.h" |
| 10 #include "third_party/npapi/bindings/npruntime.h" | 12 #include "third_party/npapi/bindings/npruntime.h" |
| 11 | 13 |
| 12 struct PP_Var; | 14 struct PP_Var; |
| 13 namespace WebKit { | 15 namespace WebKit { |
| 14 class WebSerializedScriptValue; | 16 class WebSerializedScriptValue; |
| 15 } | 17 } |
| 16 | 18 |
| 17 namespace webkit { | 19 namespace webkit { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 return passthrough_object_; | 65 return passthrough_object_; |
| 64 } | 66 } |
| 65 void SetPassthroughObject(NPObject* passthrough); | 67 void SetPassthroughObject(NPObject* passthrough); |
| 66 | 68 |
| 67 NPObject* np_object() { return np_object_; } | 69 NPObject* np_object() { return np_object_; } |
| 68 | 70 |
| 69 PluginInstance* instance() { | 71 PluginInstance* instance() { |
| 70 return instance_; | 72 return instance_; |
| 71 } | 73 } |
| 72 | 74 |
| 75 void DidCreateFinished(); | |
|
dmichael (off chromium)
2012/12/10 22:02:52
suggestion: Might be easier to read as "FinishedDi
teravest
2012/12/10 22:30:59
Done.
| |
| 76 | |
| 73 private: | 77 private: |
| 74 PluginInstance* instance_; | 78 PluginInstance* instance_; |
| 75 | 79 |
| 76 // We pass all non-postMessage calls through to the passthrough_object_. | 80 // We pass all non-postMessage calls through to the passthrough_object_. |
| 77 // This way, a plugin can use PPB_Class or PPP_Class_Deprecated and also | 81 // This way, a plugin can use PPB_Class or PPP_Class_Deprecated and also |
| 78 // postMessage. This is necessary to support backwards-compatibility, and | 82 // postMessage. This is necessary to support backwards-compatibility, and |
| 79 // also trusted plugins for which we will continue to support synchronous | 83 // also trusted plugins for which we will continue to support synchronous |
| 80 // scripting. | 84 // scripting. |
| 81 NPObject* passthrough_object_; | 85 NPObject* passthrough_object_; |
| 82 | 86 |
| 83 // The NPObject we use to expose postMessage to JavaScript. | 87 // The NPObject we use to expose postMessage to JavaScript. |
| 84 MessageChannelNPObject* np_object_; | 88 MessageChannelNPObject* np_object_; |
| 85 | 89 |
| 86 // Post a message to the onmessage handler for this channel's instance | 90 // Post a message to the onmessage handler for this channel's instance |
| 87 // synchronously. This is used by PostMessageToJavaScript. | 91 // synchronously. This is used by PostMessageToJavaScript. |
| 88 void PostMessageToJavaScriptImpl( | 92 void PostMessageToJavaScriptImpl( |
| 89 const WebKit::WebSerializedScriptValue& message_data); | 93 const WebKit::WebSerializedScriptValue& message_data); |
| 90 // Post a message to the PPP_Instance HandleMessage function for this | 94 // Post a message to the PPP_Instance HandleMessage function for this |
| 91 // channel's instance. This is used by PostMessageToNative. | 95 // channel's instance. This is used by PostMessageToNative. |
| 92 void PostMessageToNativeImpl(PP_Var message_data); | 96 void PostMessageToNativeImpl(PP_Var message_data); |
| 93 | 97 |
| 98 void DrainEarlyMessageQueue(); | |
| 99 | |
| 94 // This is used to ensure pending tasks will not fire after this object is | 100 // This is used to ensure pending tasks will not fire after this object is |
| 95 // destroyed. | 101 // destroyed. |
| 96 base::WeakPtrFactory<MessageChannel> weak_ptr_factory_; | 102 base::WeakPtrFactory<MessageChannel> weak_ptr_factory_; |
| 97 | 103 |
| 104 bool did_create_finished_; | |
| 105 std::deque<WebKit::WebSerializedScriptValue> early_message_queue_; | |
| 106 | |
| 98 DISALLOW_COPY_AND_ASSIGN(MessageChannel); | 107 DISALLOW_COPY_AND_ASSIGN(MessageChannel); |
| 99 }; | 108 }; |
| 100 | 109 |
| 101 } // namespace ppapi | 110 } // namespace ppapi |
| 102 } // namespace webkit | 111 } // namespace webkit |
| 103 | 112 |
| 104 #endif // WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_ | 113 #endif // WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_ |
| OLD | NEW |