Title: [152885] trunk/Source/WebCore
Revision
152885
Author
[email protected]
Date
2013-07-18 22:07:16 -0700 (Thu, 18 Jul 2013)

Log Message

WorkerGlobalScope should support onoffline/ononline event handlers
https://bugs.webkit.org/show_bug.cgi?id=118832

Reviewed by Alexey Proskuryakov.

HTML5 spec says that WorkerGlobalScope should support
onoffline/ononline event handlers as stated in
http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html#event-offline

Modified NetworkStateNotifier to support multiple callbacks and added a
callback to dispatch offline and online events to WorkerGlobalScope
when network state is changed.

No new test because the current test infrastructure does not provide a
mock network state notifier.

* page/Page.cpp:
(WebCore::networkStateChanged):
Change the function to take an additional argument, isOnLine so that we
can remove a call to NetworkStateNotifier::onLine().
(WebCore::Page::Page):
Use NetworkStateNotifier::addNetworkStateChangeListener which
allows us to add multiple callbacks.

* platform/network/NetworkStateNotifier.cpp:
(WebCore::NetworkStateNotifier::addNetworkStateChangeListener):
Replace NetworkStateNotifier::setNetworkStateChangedFunction with
NetworkStateNotifier::addNetworkStateChangeListener.
(WebCore::NetworkStateNotifier::notifyNetworkStateChange):
A helper method to notify all registered network state change
callbacks.
* platform/network/NetworkStateNotifier.h:
(WebCore::NetworkStateNotifier::NetworkStateNotifier):
* platform/network/blackberry/NetworkStateNotifierBlackBerry.cpp:
(WebCore::NetworkStateNotifier::NetworkStateNotifier):
(WebCore::NetworkStateNotifier::networkStateChange):
* platform/network/efl/NetworkStateNotifierEfl.cpp:
(WebCore::NetworkStateNotifier::networkInterfaceChanged):
(WebCore::NetworkStateNotifier::NetworkStateNotifier):
* platform/network/mac/NetworkStateNotifierMac.cpp:
(WebCore::NetworkStateNotifier::networkStateChangeTimerFired):
(WebCore::NetworkStateNotifier::NetworkStateNotifier):
* platform/network/qt/NetworkStateNotifierQt.cpp:
(WebCore::NetworkStateNotifier::updateState):
(WebCore::NetworkStateNotifier::NetworkStateNotifier):
* platform/network/win/NetworkStateNotifierWin.cpp:
(WebCore::NetworkStateNotifier::addressChanged):
(WebCore::NetworkStateNotifier::NetworkStateNotifier):
Replace m_networkStateChangedFunction() with notifyNetworkStateChange().

* workers/Worker.cpp:
(WebCore::networkStateChanged):
Notify network state change by iterating all Workers.
(WebCore::Worker::Worker):
Initialize allWorkers and add networkStateChanged to
NetworkStateNotifier in first invocation. Add this Worker to
allWorkers.
(WebCore::Worker::~Worker):
Remove this Worker from allWorkers.
(WebCore::Worker::notifyNetworkStateChange):
* workers/Worker.h:
* workers/WorkerGlobalScope.h:
Add onoffline and ononline event handlers.
* workers/WorkerGlobalScope.idl:
Add onoffline and ononline event handlers
* workers/WorkerGlobalScopeProxy.h:

* workers/WorkerMessagingProxy.cpp:
(WebCore::NotifyNetworkStateChangeTask::create):
(WebCore::NotifyNetworkStateChangeTask::NotifyNetworkStateChangeTask):
(WebCore::NotifyNetworkStateChangeTask::performTask):
A subclass of ScriptExecutionContext::Task to dispatch offline and
online events to WorkerGlobalScope.
(WebCore::WorkerMessagingProxy::notifyNetworkStateChange):
Notify network state change using ScriptExecutionContext::postTask to
dispatch events across threads.
* workers/WorkerMessagingProxy.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (152884 => 152885)


--- trunk/Source/WebCore/ChangeLog	2013-07-19 03:58:54 UTC (rev 152884)
+++ trunk/Source/WebCore/ChangeLog	2013-07-19 05:07:16 UTC (rev 152885)
@@ -1,3 +1,83 @@
+2013-07-18  Kwang Yul Seo  <[email protected]>
+
+        WorkerGlobalScope should support onoffline/ononline event handlers
+        https://bugs.webkit.org/show_bug.cgi?id=118832
+
+        Reviewed by Alexey Proskuryakov.
+
+        HTML5 spec says that WorkerGlobalScope should support
+        onoffline/ononline event handlers as stated in
+        http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html#event-offline
+
+        Modified NetworkStateNotifier to support multiple callbacks and added a
+        callback to dispatch offline and online events to WorkerGlobalScope
+        when network state is changed.
+
+        No new test because the current test infrastructure does not provide a
+        mock network state notifier.
+
+        * page/Page.cpp:
+        (WebCore::networkStateChanged):
+        Change the function to take an additional argument, isOnLine so that we
+        can remove a call to NetworkStateNotifier::onLine().
+        (WebCore::Page::Page):
+        Use NetworkStateNotifier::addNetworkStateChangeListener which
+        allows us to add multiple callbacks.
+
+        * platform/network/NetworkStateNotifier.cpp:
+        (WebCore::NetworkStateNotifier::addNetworkStateChangeListener):
+        Replace NetworkStateNotifier::setNetworkStateChangedFunction with
+        NetworkStateNotifier::addNetworkStateChangeListener.
+        (WebCore::NetworkStateNotifier::notifyNetworkStateChange):
+        A helper method to notify all registered network state change
+        callbacks.
+        * platform/network/NetworkStateNotifier.h:
+        (WebCore::NetworkStateNotifier::NetworkStateNotifier):
+        * platform/network/blackberry/NetworkStateNotifierBlackBerry.cpp:
+        (WebCore::NetworkStateNotifier::NetworkStateNotifier):
+        (WebCore::NetworkStateNotifier::networkStateChange):
+        * platform/network/efl/NetworkStateNotifierEfl.cpp:
+        (WebCore::NetworkStateNotifier::networkInterfaceChanged):
+        (WebCore::NetworkStateNotifier::NetworkStateNotifier):
+        * platform/network/mac/NetworkStateNotifierMac.cpp:
+        (WebCore::NetworkStateNotifier::networkStateChangeTimerFired):
+        (WebCore::NetworkStateNotifier::NetworkStateNotifier):
+        * platform/network/qt/NetworkStateNotifierQt.cpp:
+        (WebCore::NetworkStateNotifier::updateState):
+        (WebCore::NetworkStateNotifier::NetworkStateNotifier):
+        * platform/network/win/NetworkStateNotifierWin.cpp:
+        (WebCore::NetworkStateNotifier::addressChanged):
+        (WebCore::NetworkStateNotifier::NetworkStateNotifier):
+        Replace m_networkStateChangedFunction() with notifyNetworkStateChange().
+
+        * workers/Worker.cpp:
+        (WebCore::networkStateChanged):
+        Notify network state change by iterating all Workers.
+        (WebCore::Worker::Worker):
+        Initialize allWorkers and add networkStateChanged to
+        NetworkStateNotifier in first invocation. Add this Worker to
+        allWorkers.
+        (WebCore::Worker::~Worker):
+        Remove this Worker from allWorkers.
+        (WebCore::Worker::notifyNetworkStateChange):
+        * workers/Worker.h:
+        * workers/WorkerGlobalScope.h:
+        Add onoffline and ononline event handlers.
+        * workers/WorkerGlobalScope.idl:
+        Add onoffline and ononline event handlers
+        * workers/WorkerGlobalScopeProxy.h:
+
+        * workers/WorkerMessagingProxy.cpp:
+        (WebCore::NotifyNetworkStateChangeTask::create):
+        (WebCore::NotifyNetworkStateChangeTask::NotifyNetworkStateChangeTask):
+        (WebCore::NotifyNetworkStateChangeTask::performTask):
+        A subclass of ScriptExecutionContext::Task to dispatch offline and
+        online events to WorkerGlobalScope.
+        (WebCore::WorkerMessagingProxy::notifyNetworkStateChange):
+        Notify network state change using ScriptExecutionContext::postTask to
+        dispatch events across threads.
+        * workers/WorkerMessagingProxy.h:
+
 2013-07-18  Ryosuke Niwa  <[email protected]>
 
         Build fix after r152876.

Modified: trunk/Source/WebCore/page/Page.cpp (152884 => 152885)


--- trunk/Source/WebCore/page/Page.cpp	2013-07-19 03:58:54 UTC (rev 152884)
+++ trunk/Source/WebCore/page/Page.cpp	2013-07-19 05:07:16 UTC (rev 152885)
@@ -96,7 +96,7 @@
 
 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, pageCounter, ("Page"));
 
-static void networkStateChanged()
+static void networkStateChanged(bool isOnLine)
 {
     Vector<RefPtr<Frame> > frames;
     
@@ -108,7 +108,7 @@
         InspectorInstrumentation::networkStateChanged(*it);
     }
 
-    AtomicString eventName = networkStateNotifier().onLine() ? eventNames().onlineEvent : eventNames().offlineEvent;
+    AtomicString eventName = isOnLine ? eventNames().onlineEvent : eventNames().offlineEvent;
     for (unsigned i = 0; i < frames.size(); i++)
         frames[i]->document()->dispatchWindowEvent(Event::create(eventName, false, false));
 }
@@ -193,7 +193,7 @@
     if (!allPages) {
         allPages = new HashSet<Page*>;
         
-        networkStateNotifier().setNetworkStateChangedFunction(networkStateChanged);
+        networkStateNotifier().addNetworkStateChangeListener(networkStateChanged);
     }
 
     ASSERT(!allPages->contains(this));

Modified: trunk/Source/WebCore/platform/network/NetworkStateNotifier.cpp (152884 => 152885)


--- trunk/Source/WebCore/platform/network/NetworkStateNotifier.cpp	2013-07-19 03:58:54 UTC (rev 152884)
+++ trunk/Source/WebCore/platform/network/NetworkStateNotifier.cpp	2013-07-19 05:07:16 UTC (rev 152885)
@@ -39,11 +39,17 @@
     return *networkStateNotifier;
 }
 
-void NetworkStateNotifier::setNetworkStateChangedFunction(void(*function)())
+void NetworkStateNotifier::addNetworkStateChangeListener(NetworkStateChangeListener listener)
 {
-    ASSERT(!m_networkStateChangedFunction);
+    ASSERT(!listener);
+    m_listeners.append(listener);
+}
 
-    m_networkStateChangedFunction = function;
+void NetworkStateNotifier::notifyNetworkStateChange()
+{
+    Vector<NetworkStateChangeListener>::iterator end = m_listeners.end();
+    for (Vector<NetworkStateChangeListener>::iterator it = m_listeners.begin(); it != end; ++it)
+        (*it)(m_isOnLine);
 }
 
 }

Modified: trunk/Source/WebCore/platform/network/NetworkStateNotifier.h (152884 => 152885)


--- trunk/Source/WebCore/platform/network/NetworkStateNotifier.h	2013-07-19 03:58:54 UTC (rev 152884)
+++ trunk/Source/WebCore/platform/network/NetworkStateNotifier.h	2013-07-19 05:07:16 UTC (rev 152885)
@@ -28,6 +28,7 @@
 
 #include <wtf/FastAllocBase.h>
 #include <wtf/Noncopyable.h>
+#include <wtf/Vector.h>
 
 #if PLATFORM(MAC)
 
@@ -65,7 +66,8 @@
 #if PLATFORM(EFL)
     ~NetworkStateNotifier();
 #endif
-    void setNetworkStateChangedFunction(void (*)());
+    typedef void (*NetworkStateChangeListener)(bool m_isOnLine);
+    void addNetworkStateChangeListener(NetworkStateChangeListener);
 
     bool onLine() const { return m_isOnLine; }
 
@@ -79,8 +81,9 @@
 
 private:
     bool m_isOnLine;
-    void (*m_networkStateChangedFunction)();
+    Vector<NetworkStateChangeListener> m_listeners;
 
+    void notifyNetworkStateChange();
     void updateState();
 
 #if PLATFORM(MAC)
@@ -117,7 +120,6 @@
 
 inline NetworkStateNotifier::NetworkStateNotifier()
     : m_isOnLine(true)
-    , m_networkStateChangedFunction(0)
 {
 }
 

Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkStateNotifierBlackBerry.cpp (152884 => 152885)


--- trunk/Source/WebCore/platform/network/blackberry/NetworkStateNotifierBlackBerry.cpp	2013-07-19 03:58:54 UTC (rev 152884)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkStateNotifierBlackBerry.cpp	2013-07-19 05:07:16 UTC (rev 152885)
@@ -33,7 +33,6 @@
 
 NetworkStateNotifier::NetworkStateNotifier()
     : m_isOnLine(BlackBerry::Platform::Settings::instance()->isNetworkAvailable())
-    , m_networkStateChangedFunction(0)
 {
 }
 
@@ -44,8 +43,7 @@
 
     m_isOnLine = online;
 
-    if (m_networkStateChangedFunction)
-        m_networkStateChangedFunction();
+    notifyNetworkStateChange();
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/network/efl/NetworkStateNotifierEfl.cpp (152884 => 152885)


--- trunk/Source/WebCore/platform/network/efl/NetworkStateNotifierEfl.cpp	2013-07-19 03:58:54 UTC (rev 152884)
+++ trunk/Source/WebCore/platform/network/efl/NetworkStateNotifierEfl.cpp	2013-07-19 05:07:16 UTC (rev 152885)
@@ -97,8 +97,8 @@
     bool wasOnline = m_isOnLine;
     updateState();
 
-    if (wasOnline != m_isOnLine && m_networkStateChangedFunction)
-        m_networkStateChangedFunction();
+    if (wasOnline != m_isOnLine)
+        notifyNetworkStateChange();
 }
 
 Eina_Bool NetworkStateNotifier::readSocketCallback(void* userData, Ecore_Fd_Handler* handler)
@@ -156,7 +156,6 @@
 
 NetworkStateNotifier::NetworkStateNotifier()
     : m_isOnLine(false)
-    , m_networkStateChangedFunction(0)
     , m_netlinkSocket(-1)
     , m_fdHandler(0)
 {

Modified: trunk/Source/WebCore/platform/network/mac/NetworkStateNotifierMac.cpp (152884 => 152885)


--- trunk/Source/WebCore/platform/network/mac/NetworkStateNotifierMac.cpp	2013-07-19 03:58:54 UTC (rev 152884)
+++ trunk/Source/WebCore/platform/network/mac/NetworkStateNotifierMac.cpp	2013-07-19 05:07:16 UTC (rev 152885)
@@ -90,13 +90,11 @@
     if (m_isOnLine == oldOnLine)
         return;
 
-    if (m_networkStateChangedFunction)
-        m_networkStateChangedFunction();
+    notifyNetworkStateChange();
 }
 
 NetworkStateNotifier::NetworkStateNotifier()
     : m_isOnLine(false)
-    , m_networkStateChangedFunction(0)
     , m_networkStateChangeTimer(this, &NetworkStateNotifier::networkStateChangeTimerFired)
 {
     SCDynamicStoreContext context = { 0, this, 0, 0, 0 };

Modified: trunk/Source/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp (152884 => 152885)


--- trunk/Source/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp	2013-07-19 03:58:54 UTC (rev 152884)
+++ trunk/Source/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp	2013-07-19 05:07:16 UTC (rev 152885)
@@ -79,13 +79,11 @@
         return;
 
     m_isOnLine = p->effectivelyOnline();
-    if (m_networkStateChangedFunction)
-        m_networkStateChangedFunction();
+    notifyNetworkStateChange();
 }
 
 NetworkStateNotifier::NetworkStateNotifier()
     : m_isOnLine(true)
-    , m_networkStateChangedFunction(0)
 {
     p = new NetworkStateNotifierPrivate(this);
     m_isOnLine = p->effectivelyOnline();

Modified: trunk/Source/WebCore/platform/network/win/NetworkStateNotifierWin.cpp (152884 => 152885)


--- trunk/Source/WebCore/platform/network/win/NetworkStateNotifierWin.cpp	2013-07-19 03:58:54 UTC (rev 152884)
+++ trunk/Source/WebCore/platform/network/win/NetworkStateNotifierWin.cpp	2013-07-19 05:07:16 UTC (rev 152885)
@@ -77,8 +77,7 @@
     if (m_isOnLine == oldOnLine)
         return;
 
-    if (m_networkStateChangedFunction)
-        m_networkStateChangedFunction();
+    notifyNetworkStateChange();
 }
 
 void NetworkStateNotifier::callAddressChanged(void* context)
@@ -103,7 +102,6 @@
 
 NetworkStateNotifier::NetworkStateNotifier()
     : m_isOnLine(false)
-    , m_networkStateChangedFunction(0)
 {
     updateState();
 

Modified: trunk/Source/WebCore/workers/Worker.cpp (152884 => 152885)


--- trunk/Source/WebCore/workers/Worker.cpp	2013-07-19 03:58:54 UTC (rev 152884)
+++ trunk/Source/WebCore/workers/Worker.cpp	2013-07-19 05:07:16 UTC (rev 152885)
@@ -43,18 +43,36 @@
 #include "FrameLoader.h"
 #include "InspectorInstrumentation.h"
 #include "MessageEvent.h"
+#include "NetworkStateNotifier.h"
 #include "TextEncoding.h"
 #include "WorkerGlobalScopeProxy.h"
 #include "WorkerScriptLoader.h"
 #include "WorkerThread.h"
+#include <wtf/HashSet.h>
 #include <wtf/MainThread.h>
 
 namespace WebCore {
 
+static HashSet<Worker*>* allWorkers;
+
+void networkStateChanged(bool isOnLine)
+{
+    HashSet<Worker*>::iterator end = allWorkers->end();
+    for (HashSet<Worker*>::iterator it = allWorkers->begin(); it != end; ++it)
+        (*it)->notifyNetworkStateChange(isOnLine);
+}
+
 inline Worker::Worker(ScriptExecutionContext* context)
     : AbstractWorker(context)
     , m_contextProxy(WorkerGlobalScopeProxy::create(this))
 {
+    if (!allWorkers) {
+        allWorkers = new HashSet<Worker*>;
+        networkStateNotifier().addNetworkStateChangeListener(networkStateChanged);
+    }
+
+    HashSet<Worker*>::AddResult addResult = allWorkers->add(this);
+    ASSERT_UNUSED(addResult, addResult.isNewEntry);
 }
 
 PassRefPtr<Worker> Worker::create(ScriptExecutionContext* context, const String& url, ExceptionCode& ec)
@@ -86,6 +104,7 @@
 {
     ASSERT(isMainThread());
     ASSERT(scriptExecutionContext()); // The context is protected by worker context proxy, so it cannot be destroyed while a Worker exists.
+    allWorkers->remove(this);
     m_contextProxy->workerObjectDestroyed();
 }
 
@@ -132,6 +151,11 @@
     return m_contextProxy->hasPendingActivity() || ActiveDOMObject::hasPendingActivity();
 }
 
+void Worker::notifyNetworkStateChange(bool isOnLine)
+{
+    m_contextProxy->notifyNetworkStateChange(isOnLine);
+}
+
 void Worker::didReceiveResponse(unsigned long identifier, const ResourceResponse&)
 {
     InspectorInstrumentation::didReceiveScriptResponse(scriptExecutionContext(), identifier);

Modified: trunk/Source/WebCore/workers/Worker.h (152884 => 152885)


--- trunk/Source/WebCore/workers/Worker.h	2013-07-19 03:58:54 UTC (rev 152884)
+++ trunk/Source/WebCore/workers/Worker.h	2013-07-19 05:07:16 UTC (rev 152885)
@@ -71,6 +71,8 @@
     private:
         explicit Worker(ScriptExecutionContext*);
 
+        void notifyNetworkStateChange(bool isOnline);
+
         // WorkerScriptLoaderClient callbacks
         virtual void didReceiveResponse(unsigned long identifier, const ResourceResponse&) OVERRIDE;
         virtual void notifyFinished() OVERRIDE;
@@ -78,6 +80,8 @@
         virtual void refEventTarget() OVERRIDE { ref(); }
         virtual void derefEventTarget() OVERRIDE { deref(); }
 
+        friend void networkStateChanged(bool isOnLine);
+
         RefPtr<WorkerScriptLoader> m_scriptLoader;
         WorkerGlobalScopeProxy* m_contextProxy; // The proxy outlives the worker to perform thread shutdown.
     };

Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.h (152884 => 152885)


--- trunk/Source/WebCore/workers/WorkerGlobalScope.h	2013-07-19 03:58:54 UTC (rev 152884)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.h	2013-07-19 05:07:16 UTC (rev 152885)
@@ -91,6 +91,8 @@
         void close();
 
         DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
+        DEFINE_ATTRIBUTE_EVENT_LISTENER(offline);
+        DEFINE_ATTRIBUTE_EVENT_LISTENER(online);
 
         // WorkerUtils
         virtual void importScripts(const Vector<String>& urls, ExceptionCode&);

Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.idl (152884 => 152885)


--- trunk/Source/WebCore/workers/WorkerGlobalScope.idl	2013-07-19 03:58:54 UTC (rev 152884)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.idl	2013-07-19 05:07:16 UTC (rev 152885)
@@ -41,6 +41,8 @@
              [Replaceable] readonly attribute WorkerLocation location;
     void close();
              attribute EventListener onerror;
+             attribute EventListener onoffline;
+             attribute EventListener ononline;
 
     // WorkerUtils
     [Custom] void importScripts(/*[Variadic] DOMString urls */);

Modified: trunk/Source/WebCore/workers/WorkerGlobalScopeProxy.h (152884 => 152885)


--- trunk/Source/WebCore/workers/WorkerGlobalScopeProxy.h	2013-07-19 03:58:54 UTC (rev 152884)
+++ trunk/Source/WebCore/workers/WorkerGlobalScopeProxy.h	2013-07-19 05:07:16 UTC (rev 152885)
@@ -60,6 +60,8 @@
 
         virtual void workerObjectDestroyed() = 0;
 
+        virtual void notifyNetworkStateChange(bool isOnline) = 0;
+
 #if ENABLE(INSPECTOR)
         class PageInspector {
         public:

Modified: trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp (152884 => 152885)


--- trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp	2013-07-19 03:58:54 UTC (rev 152884)
+++ trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp	2013-07-19 05:07:16 UTC (rev 152885)
@@ -38,6 +38,8 @@
 #include "DOMWindow.h"
 #include "Document.h"
 #include "ErrorEvent.h"
+#include "Event.h"
+#include "EventNames.h"
 #include "ExceptionCode.h"
 #include "InspectorInstrumentation.h"
 #include "MessageEvent.h"
@@ -242,7 +244,30 @@
     String m_message;
 };
 
+class NotifyNetworkStateChangeTask : public ScriptExecutionContext::Task {
+public:
+    static PassOwnPtr<NotifyNetworkStateChangeTask> create(bool isOnLine)
+    {
+        return adoptPtr(new NotifyNetworkStateChangeTask(isOnLine));
+    }
 
+private:
+    NotifyNetworkStateChangeTask(bool isOnLine)
+        : m_isOnLine(isOnLine)
+    {
+    }
+
+    virtual void performTask(ScriptExecutionContext *context)
+    {
+        AtomicString eventName = m_isOnLine ? eventNames().onlineEvent : eventNames().offlineEvent;
+        WorkerGlobalScope* workerGlobalScope = static_cast<WorkerGlobalScope*>(context);
+        workerGlobalScope->dispatchEvent(Event::create(eventName, false, false));
+    }
+
+    bool m_isOnLine;
+};
+
+
 WorkerGlobalScopeProxy* WorkerGlobalScopeProxy::create(Worker* worker)
 {
     return new WorkerMessagingProxy(worker);
@@ -361,6 +386,17 @@
     m_scriptExecutionContext->postTask(createCallbackTask(&workerObjectDestroyedInternal, AllowCrossThreadAccess(this)));
 }
 
+void WorkerMessagingProxy::notifyNetworkStateChange(bool isOnline)
+{
+    if (m_askedToTerminate)
+        return;
+
+    if (!m_workerThread)
+        return;
+
+    m_workerThread->runLoop().postTask(NotifyNetworkStateChangeTask::create(isOnline));
+}
+
 void WorkerMessagingProxy::workerObjectDestroyedInternal(ScriptExecutionContext*, WorkerMessagingProxy* proxy)
 {
     proxy->m_mayBeDestroyed = true;

Modified: trunk/Source/WebCore/workers/WorkerMessagingProxy.h (152884 => 152885)


--- trunk/Source/WebCore/workers/WorkerMessagingProxy.h	2013-07-19 03:58:54 UTC (rev 152884)
+++ trunk/Source/WebCore/workers/WorkerMessagingProxy.h	2013-07-19 05:07:16 UTC (rev 152885)
@@ -58,6 +58,7 @@
         virtual void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue>, PassOwnPtr<MessagePortChannelArray>) OVERRIDE;
         virtual bool hasPendingActivity() const OVERRIDE;
         virtual void workerObjectDestroyed() OVERRIDE;
+        virtual void notifyNetworkStateChange(bool isOnline) OVERRIDE;
 #if ENABLE(INSPECTOR)
         virtual void connectToInspector(WorkerGlobalScopeProxy::PageInspector*) OVERRIDE;
         virtual void disconnectFromInspector() OVERRIDE;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to