- Revision
- 149620
- Author
- [email protected]
- Date
- 2013-05-06 11:44:25 -0700 (Mon, 06 May 2013)
Log Message
[WK2] Make the WebNetworkInfoManagerProxy a supplement to the WebContext
https://bugs.webkit.org/show_bug.cgi?id=115654
Reviewed by Andreas Kling.
Rather than holding a RefPtr to the WebNetworkInfoManagerProxy object in WebContext, change the WebNetworkInfoManagerProxy
to implement the WebContextSupplement interface and handle the object as such in WebContext, simplifying its
construction and cleanup, removing the specific RefPtr member variable and its correlating getter method.
* UIProcess/API/C/WKContext.cpp:
(WKContextGetNetworkInfoManager): Retrieve the WebNetworkInfoManagerProxy object from the suppplements of the WebContext.
* UIProcess/WebContext.cpp:
(WebKit::WebContext::WebContext): Add the WebNetworkInfoManagerProxy object as a supplement instead of assigning it to
the now-removed member variable.
(WebKit::WebContext::~WebContext): No need for the specific cleanup, the equivalent is achieved when iterating through the
supplements vector.
(WebKit::WebContext::disconnectProcess): Ditto.
* UIProcess/WebContext.h:
(WebContext): Remove the WebNetworkInfoManagerProxy RefPtr member variable and its getter method.
* UIProcess/WebNetworkInfoManagerProxy.cpp:
(WebKit::WebNetworkInfoManagerProxy::supplementName): Specift the supplement's name.
(WebKit::WebNetworkInfoManagerProxy::WebNetworkInfoManagerProxy): Initialize as a WebContextSupplement.
(WebKit::WebNetworkInfoManagerProxy::providerDidChangeNetworkInformation): Adjust to use the context() method instead of
accessing the private m_context directly.
(WebKit::WebNetworkInfoManagerProxy::contextDestroyed): Stop updating when invoked.
(WebKit::WebNetworkInfoManagerProxy::processDidClose): Ditto.
(WebKit::WebNetworkInfoManagerProxy::refWebContextSupplement): Call APIObject::ref.
(WebKit::WebNetworkInfoManagerProxy::derefWebContextSupplement): Call APIObject::deref.
* UIProcess/WebNetworkInfoManagerProxy.h:
(WebNetworkInfoManagerProxy): Inherit from WebContextSupplement, declare the newly-inherited methods.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (149619 => 149620)
--- trunk/Source/WebKit2/ChangeLog 2013-05-06 18:40:29 UTC (rev 149619)
+++ trunk/Source/WebKit2/ChangeLog 2013-05-06 18:44:25 UTC (rev 149620)
@@ -1,3 +1,36 @@
+2013-05-06 Zan Dobersek <[email protected]>
+
+ [WK2] Make the WebNetworkInfoManagerProxy a supplement to the WebContext
+ https://bugs.webkit.org/show_bug.cgi?id=115654
+
+ Reviewed by Andreas Kling.
+
+ Rather than holding a RefPtr to the WebNetworkInfoManagerProxy object in WebContext, change the WebNetworkInfoManagerProxy
+ to implement the WebContextSupplement interface and handle the object as such in WebContext, simplifying its
+ construction and cleanup, removing the specific RefPtr member variable and its correlating getter method.
+
+ * UIProcess/API/C/WKContext.cpp:
+ (WKContextGetNetworkInfoManager): Retrieve the WebNetworkInfoManagerProxy object from the suppplements of the WebContext.
+ * UIProcess/WebContext.cpp:
+ (WebKit::WebContext::WebContext): Add the WebNetworkInfoManagerProxy object as a supplement instead of assigning it to
+ the now-removed member variable.
+ (WebKit::WebContext::~WebContext): No need for the specific cleanup, the equivalent is achieved when iterating through the
+ supplements vector.
+ (WebKit::WebContext::disconnectProcess): Ditto.
+ * UIProcess/WebContext.h:
+ (WebContext): Remove the WebNetworkInfoManagerProxy RefPtr member variable and its getter method.
+ * UIProcess/WebNetworkInfoManagerProxy.cpp:
+ (WebKit::WebNetworkInfoManagerProxy::supplementName): Specift the supplement's name.
+ (WebKit::WebNetworkInfoManagerProxy::WebNetworkInfoManagerProxy): Initialize as a WebContextSupplement.
+ (WebKit::WebNetworkInfoManagerProxy::providerDidChangeNetworkInformation): Adjust to use the context() method instead of
+ accessing the private m_context directly.
+ (WebKit::WebNetworkInfoManagerProxy::contextDestroyed): Stop updating when invoked.
+ (WebKit::WebNetworkInfoManagerProxy::processDidClose): Ditto.
+ (WebKit::WebNetworkInfoManagerProxy::refWebContextSupplement): Call APIObject::ref.
+ (WebKit::WebNetworkInfoManagerProxy::derefWebContextSupplement): Call APIObject::deref.
+ * UIProcess/WebNetworkInfoManagerProxy.h:
+ (WebNetworkInfoManagerProxy): Inherit from WebContextSupplement, declare the newly-inherited methods.
+
2013-05-06 Alexey Proskuryakov <[email protected]>
<rdar://problem/13479806> [Mac] Pass plug-in bundle ID to LaunchServices
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp (149619 => 149620)
--- trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp 2013-05-06 18:40:29 UTC (rev 149619)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp 2013-05-06 18:44:25 UTC (rev 149620)
@@ -49,6 +49,9 @@
#if ENABLE(BATTERY_STATUS)
#include "WebBatteryManagerProxy.h"
#endif
+#if ENABLE(NETWORK_INFO)
+#include "WebNetworkInfoManagerProxy.h"
+#endif
using namespace WebKit;
@@ -232,7 +235,7 @@
WKNetworkInfoManagerRef WKContextGetNetworkInfoManager(WKContextRef contextRef)
{
#if ENABLE(NETWORK_INFO)
- return toAPI(toImpl(contextRef)->networkInfoManagerProxy());
+ return toAPI(toImpl(contextRef)->supplement<WebNetworkInfoManagerProxy>());
#else
return 0;
#endif
Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (149619 => 149620)
--- trunk/Source/WebKit2/UIProcess/WebContext.cpp 2013-05-06 18:40:29 UTC (rev 149619)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp 2013-05-06 18:44:25 UTC (rev 149620)
@@ -156,9 +156,6 @@
// NOTE: These sub-objects must be initialized after m_messageReceiverMap..
m_iconDatabase = WebIconDatabase::create(this);
-#if ENABLE(NETWORK_INFO)
- m_networkInfoManagerProxy = WebNetworkInfoManagerProxy::create(this);
-#endif
#if ENABLE(NETSCAPE_PLUGIN_API)
m_pluginSiteDataManager = WebPluginSiteDataManager::create(this);
#endif // ENABLE(NETSCAPE_PLUGIN_API)
@@ -179,6 +176,9 @@
#if ENABLE(BATTERY_STATUS)
addSupplement<WebBatteryManagerProxy>();
#endif
+#if ENABLE(NETWORK_INFO)
+ addSupplement<WebNetworkInfoManagerProxy>();
+#endif
contexts().append(this);
@@ -225,11 +225,6 @@
m_iconDatabase->invalidate();
m_iconDatabase->clearContext();
-#if ENABLE(NETWORK_INFO)
- m_networkInfoManagerProxy->invalidate();
- m_networkInfoManagerProxy->clearContext();
-#endif
-
#if ENABLE(NETSCAPE_PLUGIN_API)
m_pluginSiteDataManager->invalidate();
m_pluginSiteDataManager->clearContext();
@@ -671,10 +666,6 @@
for (; it != end; ++it)
it->value->processDidClose(process);
-#if ENABLE(NETWORK_INFO)
- m_networkInfoManagerProxy->invalidate();
-#endif
-
// When out of process plug-ins are enabled, we don't want to invalidate the plug-in site data
// manager just because the web process crashes since it's not involved.
#if ENABLE(NETSCAPE_PLUGIN_API) && !ENABLE(PLUGIN_PROCESS)
Modified: trunk/Source/WebKit2/UIProcess/WebContext.h (149619 => 149620)
--- trunk/Source/WebKit2/UIProcess/WebContext.h 2013-05-06 18:40:29 UTC (rev 149619)
+++ trunk/Source/WebKit2/UIProcess/WebContext.h 2013-05-06 18:44:25 UTC (rev 149620)
@@ -211,9 +211,6 @@
WebContextClient& client() { return m_client; }
WebIconDatabase* iconDatabase() const { return m_iconDatabase.get(); }
-#if ENABLE(NETWORK_INFO)
- WebNetworkInfoManagerProxy* networkInfoManagerProxy() const { return m_networkInfoManagerProxy.get(); }
-#endif
#if ENABLE(NETSCAPE_PLUGIN_API)
WebPluginSiteDataManager* pluginSiteDataManager() const { return m_pluginSiteDataManager.get(); }
#endif
@@ -429,9 +426,6 @@
double m_memorySamplerInterval;
RefPtr<WebIconDatabase> m_iconDatabase;
-#if ENABLE(NETWORK_INFO)
- RefPtr<WebNetworkInfoManagerProxy> m_networkInfoManagerProxy;
-#endif
#if ENABLE(NETSCAPE_PLUGIN_API)
RefPtr<WebPluginSiteDataManager> m_pluginSiteDataManager;
#endif
Modified: trunk/Source/WebKit2/UIProcess/WebNetworkInfoManagerProxy.cpp (149619 => 149620)
--- trunk/Source/WebKit2/UIProcess/WebNetworkInfoManagerProxy.cpp 2013-05-06 18:40:29 UTC (rev 149619)
+++ trunk/Source/WebKit2/UIProcess/WebNetworkInfoManagerProxy.cpp 2013-05-06 18:44:25 UTC (rev 149620)
@@ -35,27 +35,27 @@
namespace WebKit {
+const char* WebNetworkInfoManagerProxy::supplementName()
+{
+ return "WebNetworkInfoManagerProxy";
+}
+
PassRefPtr<WebNetworkInfoManagerProxy> WebNetworkInfoManagerProxy::create(WebContext* context)
{
return adoptRef(new WebNetworkInfoManagerProxy(context));
}
WebNetworkInfoManagerProxy::WebNetworkInfoManagerProxy(WebContext* context)
- : m_isUpdating(false)
- , m_context(context)
+ : WebContextSupplement(context)
+ , m_isUpdating(false)
{
- m_context->addMessageReceiver(Messages::WebNetworkInfoManagerProxy::messageReceiverName(), this);
+ WebContextSupplement::context()->addMessageReceiver(Messages::WebNetworkInfoManagerProxy::messageReceiverName(), this);
}
WebNetworkInfoManagerProxy::~WebNetworkInfoManagerProxy()
{
}
-void WebNetworkInfoManagerProxy::invalidate()
-{
- stopUpdating();
-}
-
void WebNetworkInfoManagerProxy::initializeProvider(const WKNetworkInfoProvider* provider)
{
m_provider.initialize(provider);
@@ -63,12 +63,34 @@
void WebNetworkInfoManagerProxy::providerDidChangeNetworkInformation(const AtomicString& eventType, WebNetworkInfo* networkInformation)
{
- if (!m_context)
+ if (!context())
return;
- m_context->sendToAllProcesses(Messages::WebNetworkInfoManager::DidChangeNetworkInformation(eventType, networkInformation->data()));
+ context()->sendToAllProcesses(Messages::WebNetworkInfoManager::DidChangeNetworkInformation(eventType, networkInformation->data()));
}
+// WebContextSupplement
+
+void WebNetworkInfoManagerProxy::contextDestroyed()
+{
+ stopUpdating();
+}
+
+void WebNetworkInfoManagerProxy::processDidClose(WebProcessProxy*)
+{
+ stopUpdating();
+}
+
+void WebNetworkInfoManagerProxy::refWebContextSupplement()
+{
+ APIObject::ref();
+}
+
+void WebNetworkInfoManagerProxy::derefWebContextSupplement()
+{
+ APIObject::deref();
+}
+
void WebNetworkInfoManagerProxy::startUpdating()
{
if (m_isUpdating)
Modified: trunk/Source/WebKit2/UIProcess/WebNetworkInfoManagerProxy.h (149619 => 149620)
--- trunk/Source/WebKit2/UIProcess/WebNetworkInfoManagerProxy.h 2013-05-06 18:40:29 UTC (rev 149619)
+++ trunk/Source/WebKit2/UIProcess/WebNetworkInfoManagerProxy.h 2013-05-06 18:44:25 UTC (rev 149620)
@@ -30,6 +30,7 @@
#include "APIObject.h"
#include "MessageReceiver.h"
+#include "WebContextSupplement.h"
#include "WebNetworkInfoProvider.h"
#include <wtf/Forward.h>
@@ -38,21 +39,29 @@
class WebContext;
class WebNetworkInfo;
-class WebNetworkInfoManagerProxy : public TypedAPIObject<APIObject::TypeNetworkInfoManager>, private CoreIPC::MessageReceiver {
+class WebNetworkInfoManagerProxy : public TypedAPIObject<APIObject::TypeNetworkInfoManager>, public WebContextSupplement, private CoreIPC::MessageReceiver {
public:
+ static const char* supplementName();
+
static PassRefPtr<WebNetworkInfoManagerProxy> create(WebContext*);
virtual ~WebNetworkInfoManagerProxy();
- void invalidate();
- void clearContext() { m_context = 0; }
-
void initializeProvider(const WKNetworkInfoProvider*);
void providerDidChangeNetworkInformation(const WTF::AtomicString& eventType, WebNetworkInfo*);
+ using APIObject::ref;
+ using APIObject::deref;
+
private:
explicit WebNetworkInfoManagerProxy(WebContext*);
+ // WebContextSupplement
+ virtual void contextDestroyed() OVERRIDE;
+ virtual void processDidClose(WebProcessProxy*) OVERRIDE;
+ virtual void refWebContextSupplement() OVERRIDE;
+ virtual void derefWebContextSupplement() OVERRIDE;
+
// CoreIPC::MessageReceiver
virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE;
virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&) OVERRIDE;