Source/WebCore/ChangeLog

 12017-10-02 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
 2
 3 [GLib] NetworkStateNotifier implementation missing
 4 https://bugs.webkit.org/show_bug.cgi?id=177741
 5
 6 Reviewed by Carlos Garcia Campos.
 7
 8 No new tests. The DOM support is already being tested, but we would need a way
 9 of simulating a network outage to test GNetworkMonitor.
 10
 11 * PlatformGTK.cmake: add new file.
 12 * PlatformWPE.cmake: add new file.
 13 * platform/network/NetworkStateNotifier.cpp: no longer need the empty implementations, all platforms covered.
 14 * platform/network/NetworkStateNotifier.h:
 15 * platform/network/glib/NetworkStateNotifierGLib.cpp: Added.
 16 (WebCore::NetworkStateNotifier::updateStateWithoutNotifying): update the network state using GNetworkMonitor's availability.
 17 (WebCore::NetworkStateNotifier::networkChangedCallback): when network-changed is emitted, trigger a state update.
 18 (WebCore::NetworkStateNotifier::startObserving): watch GNetworkMonitor's network-changed signal.
 19
1202017-10-02 Ryosuke Niwa <rniwa@webkit.org>
221
322 Windows build fix attempt after r222697.

Source/WebCore/PlatformGTK.cmake

@@list(APPEND WebCore_SOURCES
107107 platform/gtk/ScrollAnimatorGtk.cpp
108108 platform/gtk/SelectionData.cpp
109109
 110 platform/network/glib/NetworkStateNotifierGLib.cpp
 111
110112 platform/network/soup/AuthenticationChallengeSoup.cpp
111113 platform/network/soup/CertificateInfo.cpp
112114 platform/network/soup/CookieJarSoup.cpp

Source/WebCore/PlatformWPE.cmake

@@list(APPEND WebCore_SOURCES
9797
9898 platform/graphics/wpe/PlatformDisplayWPE.cpp
9999
 100 platform/network/glib/NetworkStateNotifierGLib.cpp
 101
100102 platform/network/soup/AuthenticationChallengeSoup.cpp
101103 platform/network/soup/CertificateInfo.cpp
102104 platform/network/soup/CookieJarSoup.cpp

Source/WebCore/platform/network/NetworkStateNotifier.cpp

@@void NetworkStateNotifier::updateStateSoon()
7575 m_updateStateTimer.startOneShot(updateStateSoonInterval);
7676}
7777
78 #if !PLATFORM(IOS) && !PLATFORM(MAC) && !PLATFORM(WIN)
79 
80 // Empty stubs for platforms where monitoring of network state is not yet implemented.
81 
82 void NetworkStateNotifier::updateStateWithoutNotifying()
83 {
84 }
85 
86 void NetworkStateNotifier::startObserving()
87 {
88 }
89 
90 #endif
91 
9278} // namespace WebCore

Source/WebCore/platform/network/NetworkStateNotifier.h

@@private:
6767 static void CALLBACK addressChangeCallback(void*, BOOLEAN timedOut);
6868#endif
6969
 70#if PLATFORM(GTK) || PLATFORM(WPE)
 71 static void networkChangedCallback(NetworkStateNotifier*);
 72#endif
 73
7074 std::optional<bool> m_isOnLine;
7175 Vector<WTF::Function<void(bool)>> m_listeners;
7276 Timer m_updateStateTimer;

Source/WebCore/platform/network/glib/NetworkStateNotifierGLib.cpp

 1/*
 2 * Copyright (C) 2017 Collabora Ltd.
 3 *
 4 * This library is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU Lesser General Public
 6 * License as published by the Free Software Foundation; either
 7 * version 2 of the License, or (at your option) any later version.
 8 *
 9 * This library is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 * Lesser General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU Lesser General Public
 15 * License along with this library; if not, write to the Free Software
 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 17 */
 18
 19#include "config.h"
 20#include "NetworkStateNotifier.h"
 21
 22#include <gio/gio.h>
 23
 24namespace WebCore {
 25
 26void NetworkStateNotifier::updateStateWithoutNotifying()
 27{
 28 m_isOnLine = g_network_monitor_get_network_available(g_network_monitor_get_default());
 29}
 30
 31void NetworkStateNotifier::networkChangedCallback(NetworkStateNotifier* networkStateNotifier)
 32{
 33 networkStateNotifier->singleton().updateStateSoon();
 34}
 35
 36void NetworkStateNotifier::startObserving()
 37{
 38 g_signal_connect_swapped(g_network_monitor_get_default(), "network-changed", G_CALLBACK(networkChangedCallback), this);
 39}
 40
 41}