Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2187)

Unified Diff: content/renderer/pepper/message_channel.h

Issue 512983004: Revert of Replace NPObject usage in ppapi with gin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/pepper/host_var_tracker_unittest.cc ('k') | content/renderer/pepper/message_channel.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/pepper/message_channel.h
diff --git a/content/renderer/pepper/message_channel.h b/content/renderer/pepper/message_channel.h
index d0337aa40a5978f647de1ce3b38284a5cca689ea..4682399939d8cc369bf7dc5711e9259a675794b2 100644
--- a/content/renderer/pepper/message_channel.h
+++ b/content/renderer/pepper/message_channel.h
@@ -9,29 +9,20 @@
#include <list>
#include <map>
-#include "base/basictypes.h"
#include "base/memory/weak_ptr.h"
-#include "gin/handle.h"
-#include "gin/interceptor.h"
-#include "gin/wrappable.h"
#include "ppapi/shared_impl/resource.h"
#include "third_party/WebKit/public/web/WebSerializedScriptValue.h"
-#include "v8/include/v8.h"
+#include "third_party/npapi/bindings/npruntime.h"
struct PP_Var;
-namespace gin {
-class Arguments;
-} // namespace gin
-
namespace ppapi {
class ScopedPPVar;
-} // namespace ppapi
+}
namespace content {
class PepperPluginInstanceImpl;
-class PluginObject;
// MessageChannel implements bidirectional postMessage functionality, allowing
// calls from JavaScript to plugins and vice-versa. See
@@ -46,73 +37,64 @@
// - The message target won't be limited to instance, and should support
// either plugin-provided or JS objects.
// TODO(dmichael): Add support for separate MessagePorts.
-class MessageChannel : public gin::Wrappable<MessageChannel>,
- public gin::NamedPropertyInterceptor {
+class MessageChannel {
public:
- static gin::WrapperInfo kWrapperInfo;
+ // MessageChannelNPObject is a simple struct that adds a pointer back to a
+ // MessageChannel instance. This way, we can use an NPObject to allow
+ // JavaScript interactions without forcing MessageChannel to inherit from
+ // NPObject.
+ struct MessageChannelNPObject : public NPObject {
+ MessageChannelNPObject();
+ ~MessageChannelNPObject();
- // Creates a MessageChannel, returning a pointer to it and sets |result| to
- // the v8 object which is backed by the message channel. The returned pointer
- // is only valid as long as the object in |result| is alive.
- static MessageChannel* Create(PepperPluginInstanceImpl* instance,
- v8::Persistent<v8::Object>* result);
+ base::WeakPtr<MessageChannel> message_channel;
+ };
- virtual ~MessageChannel();
-
- // Post a message to the onmessage handler for this channel's instance
- // asynchronously.
- void PostMessageToJavaScript(PP_Var message_data);
+ explicit MessageChannel(PepperPluginInstanceImpl* instance);
+ ~MessageChannel();
// Messages are queued initially. After the PepperPluginInstanceImpl is ready
// to send and handle messages, users of MessageChannel should call
// Start().
void Start();
- // Set the V8Object to which we should forward any calls which aren't
- // related to postMessage. Note that this can be empty; it only gets set if
+ // Return the NPObject* to which we should forward any calls which aren't
+ // related to postMessage. Note that this can be NULL; it only gets set if
// there is a scriptable 'InstanceObject' associated with this channel's
// instance.
- void SetPassthroughObject(v8::Handle<v8::Object> passthrough);
+ NPObject* passthrough_object() { return passthrough_object_; }
+ void SetPassthroughObject(NPObject* passthrough);
+
+ NPObject* np_object() { return np_object_; }
PepperPluginInstanceImpl* instance() { return instance_; }
+ bool GetReadOnlyProperty(NPIdentifier key, NPVariant* value) const;
void SetReadOnlyProperty(PP_Var key, PP_Var value);
- private:
- // Struct for storing the result of a v8 object being converted to a PP_Var.
- struct VarConversionResult;
-
- explicit MessageChannel(PepperPluginInstanceImpl* instance);
-
- // gin::NamedPropertyInterceptor
- virtual v8::Local<v8::Value> GetNamedProperty(
- v8::Isolate* isolate,
- const std::string& property) OVERRIDE;
- virtual bool SetNamedProperty(v8::Isolate* isolate,
- const std::string& property,
- v8::Local<v8::Value> value) OVERRIDE;
- virtual std::vector<std::string> EnumerateNamedProperties(
- v8::Isolate* isolate) OVERRIDE;
-
- // gin::Wrappable
- virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
- v8::Isolate* isolate) OVERRIDE;
+ // Post a message to the onmessage handler for this channel's instance
+ // asynchronously.
+ void PostMessageToJavaScript(PP_Var message_data);
// Post a message to the plugin's HandleMessage function for this channel's
// instance.
- void PostMessageToNative(gin::Arguments* args);
+ void PostMessageToNative(const NPVariant* message_data);
+
// Post a message to the plugin's HandleBlocking Message function for this
// channel's instance synchronously, and return a result.
- void PostBlockingMessageToNative(gin::Arguments* args);
+ void PostBlockingMessageToNative(const NPVariant* message_data,
+ NPVariant* np_result);
+
+ private:
+ // Struct for storing the result of a NPVariant being converted to a PP_Var.
+ struct VarConversionResult;
// Post a message to the onmessage handler for this channel's instance
// synchronously. This is used by PostMessageToJavaScript.
void PostMessageToJavaScriptImpl(
const blink::WebSerializedScriptValue& message_data);
- PluginObject* GetPluginObject(v8::Isolate* isolate);
-
- void EnqueuePluginMessage(v8::Handle<v8::Value> v8_value);
+ void EnqueuePluginMessage(const NPVariant* variant);
void FromV8ValueComplete(VarConversionResult* result_holder,
const ppapi::ScopedPPVar& result_var,
@@ -128,7 +110,10 @@
// postMessage. This is necessary to support backwards-compatibility, and
// also trusted plugins for which we will continue to support synchronous
// scripting.
- v8::Persistent<v8::Object> passthrough_object_;
+ NPObject* passthrough_object_;
+
+ // The NPObject we use to expose postMessage to JavaScript.
+ MessageChannelNPObject* np_object_;
std::deque<blink::WebSerializedScriptValue> early_message_queue_;
enum EarlyMessageQueueState {
@@ -147,7 +132,7 @@
// probably also work, but is less clearly specified).
std::list<VarConversionResult> plugin_message_queue_;
- std::map<std::string, ppapi::ScopedPPVar> internal_named_properties_;
+ std::map<NPIdentifier, ppapi::ScopedPPVar> internal_properties_;
// This is used to ensure pending tasks will not fire after this object is
// destroyed.
« no previous file with comments | « content/renderer/pepper/host_var_tracker_unittest.cc ('k') | content/renderer/pepper/message_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698