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

Unified Diff: content/renderer/browser_plugin/browser_plugin_bindings.h

Issue 10830072: Browser Plugin: New Implementation (Renderer Side) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added lots more comments to messages and public members of BrowserPlugin Created 8 years, 5 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
Index: content/renderer/browser_plugin/browser_plugin_bindings.h
diff --git a/content/renderer/browser_plugin/browser_plugin_bindings.h b/content/renderer/browser_plugin/browser_plugin_bindings.h
new file mode 100644
index 0000000000000000000000000000000000000000..ede6e124a651756bc54bc1ef5242f90f310f2340
--- /dev/null
+++ b/content/renderer/browser_plugin/browser_plugin_bindings.h
@@ -0,0 +1,55 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_
+#define WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_
+
+#include "base/memory/weak_ptr.h"
+#include "ppapi/shared_impl/resource.h"
+#include "third_party/npapi/bindings/npruntime.h"
+
+namespace WebKit {
+class WebSerializedScriptValue;
+}
+
+namespace content {
+namespace browser_plugin {
+
+class BrowserPlugin;
+
+class BrowserPluginBindings {
+ public:
+ // BrowserPluginNPObject is a simple struct that adds a pointer back to a
+ // BrowserPluginBindings instance. This way, we can use an NPObject to allow
+ // JavaScript interactions without forcing BrowserPluginBindings to inherit
+ // from NPObject.
+ struct BrowserPluginNPObject : public NPObject {
+ BrowserPluginNPObject();
+ ~BrowserPluginNPObject();
+
+ base::WeakPtr<BrowserPluginBindings> message_channel;
+ };
+
+ explicit BrowserPluginBindings(BrowserPlugin* instance);
+ ~BrowserPluginBindings();
+
+ NPObject* np_object() const { return np_object_; }
+
+ BrowserPlugin* instance() const { return instance_; }
+ private:
+ BrowserPlugin* instance_;
+ // The NPObject we use to expose postMessage to JavaScript.
+ BrowserPluginNPObject* np_object_;
+
+ // This is used to ensure pending tasks will not fire after this object is
+ // destroyed.
+ base::WeakPtrFactory<BrowserPluginBindings> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindings);
+};
+
+} // namespace browser_plugin
+} // namespace content
+
+#endif // WEBKIT_PLUGINS_PPAPI_MESSAGE_CHANNEL_H_

Powered by Google App Engine
This is Rietveld 408576698