| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 WTF_MAKE_NONCOPYABLE(NetworkStateNotifier); WTF_MAKE_FAST_ALLOCATED(NetworkS
tateNotifier); | 42 WTF_MAKE_NONCOPYABLE(NetworkStateNotifier); WTF_MAKE_FAST_ALLOCATED(NetworkS
tateNotifier); |
| 43 public: | 43 public: |
| 44 class NetworkStateObserver { | 44 class NetworkStateObserver { |
| 45 public: | 45 public: |
| 46 // Will be called on the thread of the context passed in addObserver. | 46 // Will be called on the thread of the context passed in addObserver. |
| 47 virtual void connectionChange(WebConnectionType, double maxBandwidthMbps
) = 0; | 47 virtual void connectionChange(WebConnectionType, double maxBandwidthMbps
) = 0; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 NetworkStateNotifier() | 50 NetworkStateNotifier() |
| 51 : m_isOnLine(true) | 51 : m_isOnLine(true) |
| 52 , m_type(ConnectionTypeOther) | 52 , m_type(WebConnectionTypeOther) |
| 53 , m_maxBandwidthMbps(std::numeric_limits<double>::infinity()) | 53 , m_maxBandwidthMbps(std::numeric_limits<double>::infinity()) |
| 54 , m_testUpdatesOnly(false) | 54 , m_testUpdatesOnly(false) |
| 55 { | 55 { |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Can be called on any thread. | 58 // Can be called on any thread. |
| 59 bool onLine() const | 59 bool onLine() const |
| 60 { | 60 { |
| 61 MutexLocker locker(m_mutex); | 61 MutexLocker locker(m_mutex); |
| 62 return m_isOnLine; | 62 return m_isOnLine; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 double m_maxBandwidthMbps; | 126 double m_maxBandwidthMbps; |
| 127 ObserverListMap m_observers; | 127 ObserverListMap m_observers; |
| 128 bool m_testUpdatesOnly; | 128 bool m_testUpdatesOnly; |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 CORE_EXPORT NetworkStateNotifier& networkStateNotifier(); | 131 CORE_EXPORT NetworkStateNotifier& networkStateNotifier(); |
| 132 | 132 |
| 133 } // namespace blink | 133 } // namespace blink |
| 134 | 134 |
| 135 #endif // NetworkStateNotifier_h | 135 #endif // NetworkStateNotifier_h |
| OLD | NEW |