| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef NetworkStateNotifier_h | 26 #ifndef NetworkStateNotifier_h |
| 27 #define NetworkStateNotifier_h | 27 #define NetworkStateNotifier_h |
| 28 | 28 |
| 29 #include <wtf/FastAllocBase.h> | 29 #include <wtf/FastAllocBase.h> |
| 30 #include <wtf/Noncopyable.h> | 30 #include <wtf/Noncopyable.h> |
| 31 | 31 |
| 32 #if PLATFORM(MAC) | |
| 33 | |
| 34 #include <wtf/RetainPtr.h> | |
| 35 #include "Timer.h" | |
| 36 | |
| 37 typedef const struct __CFArray * CFArrayRef; | |
| 38 typedef const struct __SCDynamicStore * SCDynamicStoreRef; | |
| 39 | |
| 40 #elif PLATFORM(WIN) | |
| 41 | |
| 42 #include <windows.h> | |
| 43 | |
| 44 #elif PLATFORM(QT) | |
| 45 | |
| 46 #include <QtCore/qglobal.h> | |
| 47 | |
| 48 #endif | |
| 49 | |
| 50 namespace WebCore { | 32 namespace WebCore { |
| 51 | 33 |
| 52 #if (PLATFORM(QT) && !defined(QT_NO_BEARERMANAGEMENT)) | |
| 53 class NetworkStateNotifierPrivate; | |
| 54 #endif | |
| 55 | |
| 56 class NetworkStateNotifier { | 34 class NetworkStateNotifier { |
| 57 WTF_MAKE_NONCOPYABLE(NetworkStateNotifier); WTF_MAKE_FAST_ALLOCATED; | 35 WTF_MAKE_NONCOPYABLE(NetworkStateNotifier); WTF_MAKE_FAST_ALLOCATED; |
| 58 public: | 36 public: |
| 59 NetworkStateNotifier(); | 37 NetworkStateNotifier(); |
| 60 void setNetworkStateChangedFunction(void (*)()); | 38 void setNetworkStateChangedFunction(void (*)()); |
| 61 | 39 |
| 62 bool onLine() const { return m_isOnLine; } | 40 bool onLine() const { return m_isOnLine; } |
| 63 | |
| 64 #if (PLATFORM(QT) && !defined(QT_NO_BEARERMANAGEMENT)) | |
| 65 void setNetworkAccessAllowed(bool); | |
| 66 #elif PLATFORM(CHROMIUM) | |
| 67 void setOnLine(bool); | 41 void setOnLine(bool); |
| 68 #endif | |
| 69 | |
| 70 #if PLATFORM(BLACKBERRY) | |
| 71 void networkStateChange(bool online); | |
| 72 #endif | |
| 73 | 42 |
| 74 private: | 43 private: |
| 75 bool m_isOnLine; | 44 bool m_isOnLine; |
| 76 void (*m_networkStateChangedFunction)(); | 45 void (*m_networkStateChangedFunction)(); |
| 77 | 46 |
| 78 void updateState(); | 47 void updateState(); |
| 79 | |
| 80 #if PLATFORM(MAC) | |
| 81 void networkStateChangeTimerFired(Timer<NetworkStateNotifier>*); | |
| 82 | |
| 83 static void dynamicStoreCallback(SCDynamicStoreRef, CFArrayRef changedKeys,
void *info); | |
| 84 | |
| 85 RetainPtr<SCDynamicStoreRef> m_store; | |
| 86 Timer<NetworkStateNotifier> m_networkStateChangeTimer; | |
| 87 | |
| 88 #elif PLATFORM(WIN) | |
| 89 static void CALLBACK addrChangeCallback(void*, BOOLEAN timedOut); | |
| 90 static void callAddressChanged(void*); | |
| 91 void addressChanged(); | |
| 92 | |
| 93 void registerForAddressChange(); | |
| 94 HANDLE m_waitHandle; | |
| 95 OVERLAPPED m_overlapped; | |
| 96 | |
| 97 #elif (PLATFORM(QT) && !defined(QT_NO_BEARERMANAGEMENT)) | |
| 98 friend class NetworkStateNotifierPrivate; | |
| 99 NetworkStateNotifierPrivate* p; | |
| 100 #endif | |
| 101 }; | 48 }; |
| 102 | 49 |
| 103 #if !PLATFORM(MAC) && !PLATFORM(WIN) && !(PLATFORM(QT) && !defined(QT_NO_BEARERM
ANAGEMENT)) && !PLATFORM(BLACKBERRY) | |
| 104 | |
| 105 inline NetworkStateNotifier::NetworkStateNotifier() | 50 inline NetworkStateNotifier::NetworkStateNotifier() |
| 106 : m_isOnLine(true) | 51 : m_isOnLine(true) |
| 107 , m_networkStateChangedFunction(0) | 52 , m_networkStateChangedFunction(0) |
| 108 { | 53 { |
| 109 } | 54 } |
| 110 | 55 |
| 111 inline void NetworkStateNotifier::updateState() { } | 56 inline void NetworkStateNotifier::updateState() { } |
| 112 | 57 |
| 113 #endif | |
| 114 | |
| 115 NetworkStateNotifier& networkStateNotifier(); | 58 NetworkStateNotifier& networkStateNotifier(); |
| 116 | 59 |
| 117 }; | 60 }; |
| 118 | 61 |
| 119 #endif // NetworkStateNotifier_h | 62 #endif // NetworkStateNotifier_h |
| OLD | NEW |