Add PluginControllerProxy class
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Sep 2010 16:07:18 +0000 (16:07 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Sep 2010 16:07:18 +0000 (16:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=46728

Reviewed by Adam Roben.

* PluginProcess/PluginControllerProxy.cpp: Added.
* PluginProcess/PluginControllerProxy.h: Added.
Add stubbed out PluginControllerProxy class.

* PluginProcess/WebProcessConnection.cpp:
(WebKit::WebProcessConnection::~WebProcessConnection):
Assert that we don't have any live plug-in controller proxies.

(WebKit::WebProcessConnection::addPluginControllerProxy):
Add the plug-in controller proxy to the map.

(WebKit::WebProcessConnection::removePluginControllerProxy):
Remove the plug-in controller proxy from the map. If the last plug-in controller
proxy went away, invalidate the connection.

* WebKit2.xcodeproj/project.pbxproj:
Add files.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@68522 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit2/ChangeLog
WebKit2/PluginProcess/PluginControllerProxy.cpp [new file with mode: 0644]
WebKit2/PluginProcess/PluginControllerProxy.h [new file with mode: 0644]
WebKit2/PluginProcess/WebProcessConnection.cpp
WebKit2/PluginProcess/WebProcessConnection.h
WebKit2/WebKit2.xcodeproj/project.pbxproj

index a7bddcd..8bb73f7 100644 (file)
@@ -1,3 +1,28 @@
+2010-09-28  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Adam Roben.
+
+        Add PluginControllerProxy class
+        https://bugs.webkit.org/show_bug.cgi?id=46728
+
+        * PluginProcess/PluginControllerProxy.cpp: Added.
+        * PluginProcess/PluginControllerProxy.h: Added.
+        Add stubbed out PluginControllerProxy class.
+        
+        * PluginProcess/WebProcessConnection.cpp:
+        (WebKit::WebProcessConnection::~WebProcessConnection):
+        Assert that we don't have any live plug-in controller proxies.
+
+        (WebKit::WebProcessConnection::addPluginControllerProxy):
+        Add the plug-in controller proxy to the map.
+                
+        (WebKit::WebProcessConnection::removePluginControllerProxy):
+        Remove the plug-in controller proxy from the map. If the last plug-in controller
+        proxy went away, invalidate the connection.
+        
+        * WebKit2.xcodeproj/project.pbxproj:
+        Add files.
+
 2010-09-28  Adam Roben  <aroben@apple.com>
 
         Don't call NPP_SetWindow until the plugin's HWND has been
diff --git a/WebKit2/PluginProcess/PluginControllerProxy.cpp b/WebKit2/PluginProcess/PluginControllerProxy.cpp
new file mode 100644 (file)
index 0000000..73fe4e6
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if ENABLE(PLUGIN_PROCESS)
+
+#include "PluginControllerProxy.h"
+
+#include "NotImplemented.h"
+#include <wtf/text/WTFString.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassOwnPtr<PluginControllerProxy> PluginControllerProxy::create(WebProcessConnection* connection, uint64_t pluginInstanceID)
+{
+    return adoptPtr(new PluginControllerProxy(connection, pluginInstanceID));
+}
+
+PluginControllerProxy::PluginControllerProxy(WebProcessConnection* connection, uint64_t pluginInstanceID)
+    : m_connection(connection)
+    , m_pluginInstanceID(pluginInstanceID)
+{
+}
+
+PluginControllerProxy::~PluginControllerProxy()
+{
+    ASSERT(!m_plugin);
+}
+
+void PluginControllerProxy::invalidate(const IntRect&)
+{
+    notImplemented();
+}
+
+String PluginControllerProxy::userAgent(const WebCore::KURL&)
+{
+    notImplemented();
+    return String();
+}
+
+void PluginControllerProxy::loadURL(uint64_t requestID, const String& method, const String& urlString, const String& target, const HTTPHeaderMap& headerFields, const Vector<uint8_t>& httpBody, bool allowPopups)
+{
+    notImplemented();
+}
+
+void PluginControllerProxy::cancelStreamLoad(uint64_t streamID)
+{
+    notImplemented();
+}
+
+void PluginControllerProxy::cancelManualStreamLoad()
+{
+    notImplemented();
+}
+
+NPObject* PluginControllerProxy::windowScriptNPObject()
+{
+    notImplemented();
+    return 0;
+}
+
+NPObject* PluginControllerProxy::pluginElementNPObject()
+{
+    notImplemented();
+    return 0;
+}
+
+bool PluginControllerProxy::evaluate(NPObject*, const String& scriptString, NPVariant* result, bool allowPopups)
+{
+    notImplemented();
+    return false;
+}
+
+void PluginControllerProxy::setStatusbarText(const WTF::String&)
+{
+    notImplemented();
+}
+
+bool PluginControllerProxy::isAcceleratedCompositingEnabled()
+{
+    notImplemented();
+    return false;
+}
+
+void PluginControllerProxy::pluginProcessCrashed()
+{
+    notImplemented();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(PLUGIN_PROCESS)
diff --git a/WebKit2/PluginProcess/PluginControllerProxy.h b/WebKit2/PluginProcess/PluginControllerProxy.h
new file mode 100644 (file)
index 0000000..a1a28b6
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PluginControllerProxy_h
+#define PluginControllerProxy_h
+
+#if ENABLE(PLUGIN_PROCESS)
+
+#include "Connection.h"
+#include "Plugin.h"
+#include "PluginController.h"
+#include <wtf/Noncopyable.h>
+
+namespace WebKit {
+
+class WebProcessConnection;
+
+class PluginControllerProxy : PluginController {
+    WTF_MAKE_NONCOPYABLE(PluginControllerProxy);
+
+public:
+    static PassOwnPtr<PluginControllerProxy> create(WebProcessConnection* connection, uint64_t pluginInstanceID);
+    ~PluginControllerProxy();
+
+    uint64_t pluginInstanceID() const { return m_pluginInstanceID; }
+
+private:
+    PluginControllerProxy(WebProcessConnection* connection, uint64_t pluginInstanceID);
+
+    // PluginController
+    virtual void invalidate(const WebCore::IntRect&);
+    virtual String userAgent(const WebCore::KURL&);
+    virtual void loadURL(uint64_t requestID, const String& method, const String& urlString, const String& target, const WebCore::HTTPHeaderMap& headerFields, const Vector<uint8_t>& httpBody, bool allowPopups);
+    virtual void cancelStreamLoad(uint64_t streamID);
+    virtual void cancelManualStreamLoad();
+    virtual NPObject* windowScriptNPObject();
+    virtual NPObject* pluginElementNPObject();
+    virtual bool evaluate(NPObject*, const String& scriptString, NPVariant* result, bool allowPopups);
+    virtual void setStatusbarText(const String&);
+    virtual bool isAcceleratedCompositingEnabled();
+    virtual void pluginProcessCrashed();
+
+    WebProcessConnection* m_connection;
+    uint64_t m_pluginInstanceID;
+
+    RefPtr<Plugin> m_plugin;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(PLUGIN_PROCESS)
+
+#endif // PluginControllerProxy_h
index b13f8b3..a5acfa4 100644 (file)
@@ -27,6 +27,8 @@
 
 #include "WebProcessConnection.h"
 
+#include "PluginControllerProxy.h"
+#include "PluginProcess.h"
 #include "RunLoop.h"
 
 namespace WebKit {
@@ -38,6 +40,7 @@ PassRefPtr<WebProcessConnection> WebProcessConnection::create(CoreIPC::Connectio
 
 WebProcessConnection::~WebProcessConnection()
 {
+    ASSERT(m_pluginControllers.isEmpty());
 }
     
 WebProcessConnection::WebProcessConnection(CoreIPC::Connection::Identifier connectionIdentifier)
@@ -46,6 +49,28 @@ WebProcessConnection::WebProcessConnection(CoreIPC::Connection::Identifier conne
     m_connection->open();
 }
 
+void WebProcessConnection::addPluginControllerProxy(PluginControllerProxy* pluginController)
+{
+    ASSERT(!m_pluginControllers.contains(pluginController->pluginInstanceID()));
+    m_pluginControllers.set(pluginController->pluginInstanceID(), pluginController);
+}
+
+void WebProcessConnection::removePluginControllerProxy(PluginControllerProxy* pluginController)
+{
+    ASSERT(m_pluginControllers.contains(pluginController->pluginInstanceID()));
+    m_pluginControllers.remove(pluginController->pluginInstanceID());
+
+    if (!m_pluginControllers.isEmpty())
+        return;
+
+    // The last plug-in went away, close this connection.
+    m_connection->invalidate();
+    m_connection = 0;
+
+    // This will cause us to be deleted.    
+    PluginProcess::shared().removeWebProcessConnection(this);
+}
+
 void WebProcessConnection::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
 {
     // FIXME: Implement.
index c7f4e79..08b6e91 100644 (file)
@@ -34,6 +34,8 @@
 
 namespace WebKit {
 
+class PluginControllerProxy;
+    
 // A connection from a plug-in process to a web process.
 
 class WebProcessConnection : public RefCounted<WebProcessConnection>, CoreIPC::Connection::Client {
@@ -43,6 +45,9 @@ public:
 
     CoreIPC::Connection* connection() const { return m_connection.get(); }
 
+    void addPluginControllerProxy(PluginControllerProxy*);
+    void removePluginControllerProxy(PluginControllerProxy*);
+
 private:
     WebProcessConnection(CoreIPC::Connection::Identifier);
 
@@ -57,6 +62,9 @@ private:
     void createPlugin(uint64_t pluginInstanceID, const Plugin::Parameters&, bool& result);
 
     RefPtr<CoreIPC::Connection> m_connection;
+
+    HashMap<uint64_t, PluginControllerProxy*> m_pluginControllers;
+
 };
 
 } // namespace WebKit
index fdd4a8a..cbe54b4 100644 (file)
                1A6FBA2B11E6862700DB1371 /* NetscapeBrowserFuncs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FBA2911E6862700DB1371 /* NetscapeBrowserFuncs.cpp */; };
                1A6FBD2811E69BC200DB1371 /* NetscapePlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6FBD2611E69BC200DB1371 /* NetscapePlugin.h */; };
                1A6FBD2911E69BC200DB1371 /* NetscapePlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FBD2711E69BC200DB1371 /* NetscapePlugin.cpp */; };
+               1A8EF4CB1252403700F7067F /* PluginControllerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8EF4C91252403700F7067F /* PluginControllerProxy.h */; };
+               1A8EF4CC1252403700F7067F /* PluginControllerProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8EF4CA1252403700F7067F /* PluginControllerProxy.cpp */; };
                1AA1CC5D100FA1A10078DEBC /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1CC5C100FA1A10078DEBC /* QuartzCore.framework */; };
                1AA1CD07100FA1BA0078DEBC /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1CD06100FA1BA0078DEBC /* Carbon.framework */; };
                1AA56F2911E92BC80061B882 /* PluginController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA56F2811E92BC80061B882 /* PluginController.h */; };
                1A6FBA2911E6862700DB1371 /* NetscapeBrowserFuncs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetscapeBrowserFuncs.cpp; sourceTree = "<group>"; };
                1A6FBD2611E69BC200DB1371 /* NetscapePlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetscapePlugin.h; sourceTree = "<group>"; };
                1A6FBD2711E69BC200DB1371 /* NetscapePlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetscapePlugin.cpp; sourceTree = "<group>"; };
+               1A8EF4C91252403700F7067F /* PluginControllerProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginControllerProxy.h; sourceTree = "<group>"; };
+               1A8EF4CA1252403700F7067F /* PluginControllerProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginControllerProxy.cpp; sourceTree = "<group>"; };
                1AA1C79A100E7FC50078DEBC /* WebCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
                1AA1C7DE100E846E0078DEBC /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JavaScriptCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
                1AA1CC5C100FA1A10078DEBC /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = /System/Library/Frameworks/QuartzCore.framework; sourceTree = "<absolute>"; };
                        isa = PBXGroup;
                        children = (
                                1A0EC7FD124BD402007EF4A5 /* mac */,
+                               1A8EF4CA1252403700F7067F /* PluginControllerProxy.cpp */,
+                               1A8EF4C91252403700F7067F /* PluginControllerProxy.h */,
                                1A043975124D034800FFBFB5 /* PluginProcess.cpp */,
                                1A043974124D034800FFBFB5 /* PluginProcess.h */,
                                1A0EC6B1124BBD36007EF4A5 /* PluginProcess.messages.in */,
                                BC40783D1250FADD0068F20A /* WKEvent.h in Headers */,
                                1A043DC1124FF87500FFBFB5 /* PluginProxy.h in Headers */,
                                1A043F6A12514D8B00FFBFB5 /* WebProcessConnectionMessages.h in Headers */,
+                               1A8EF4CB1252403700F7067F /* PluginControllerProxy.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                1A043D92124FF02B00FFBFB5 /* BackingStoreMac.mm in Sources */,
                                1A043DC2124FF87500FFBFB5 /* PluginProxy.cpp in Sources */,
                                1A043F6912514D8B00FFBFB5 /* WebProcessConnectionMessageReceiver.cpp in Sources */,
+                               1A8EF4CC1252403700F7067F /* PluginControllerProxy.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };