Chromium Code Reviews| Index: Source/core/page/NetworkStateNotifier.h |
| diff --git a/Source/core/page/NetworkStateNotifier.h b/Source/core/page/NetworkStateNotifier.h |
| index 66290b7c00fa531e61c2a83a98538ae59f0bdc2f..715d9fcbc2032ba0d2904d7a13ac6277bfbd219e 100644 |
| --- a/Source/core/page/NetworkStateNotifier.h |
| +++ b/Source/core/page/NetworkStateNotifier.h |
| @@ -44,16 +44,18 @@ public: |
| class NetworkStateObserver { |
| public: |
| // Will be called on the thread of the context passed in addObserver. |
| - virtual void connectionTypeChange(WebConnectionType) = 0; |
| + virtual void connectionChange(WebConnectionType, double) = 0; |
|
adamk
2015/08/28 00:55:31
The second argument here needs a name.
jkarlin
2015/09/02 17:37:06
Done.
|
| }; |
| NetworkStateNotifier() |
| : m_isOnLine(true) |
| , m_type(ConnectionTypeOther) |
| + , m_maxBandwidth(std::numeric_limits<double>::infinity()) |
| , m_testUpdatesOnly(false) |
| { |
| } |
| + // Can be called on any thread. |
| bool onLine() const |
| { |
| MutexLocker locker(m_mutex); |
| @@ -62,13 +64,21 @@ public: |
| void setOnLine(bool); |
| + // Can be called on any thread. |
| WebConnectionType connectionType() const |
| { |
| MutexLocker locker(m_mutex); |
| return m_type; |
| } |
| - void setWebConnectionType(WebConnectionType); |
| + // Can be called on any thread. |
| + double maxBandwidth() const |
| + { |
| + MutexLocker locker(m_mutex); |
| + return m_maxBandwidth; |
| + } |
| + |
| + void setWebConnection(WebConnectionType, double); |
|
adamk
2015/08/28 00:55:31
Same here.
jkarlin
2015/09/02 17:37:07
Done.
|
| // Must be called on the context's thread. An added observer must be removed |
| // before its ExecutionContext is deleted. It's possible for an observer to |
| @@ -83,7 +93,7 @@ public: |
| // can update the connection type. This is used for layout tests (see crbug.com/377736). |
| void setTestUpdatesOnly(bool); |
| // Tests should call this as it will change the type regardless of the value of m_testUpdatesOnly. |
| - void setWebConnectionTypeForTest(WebConnectionType); |
| + void setWebConnectionForTest(WebConnectionType, double); |
|
adamk
2015/08/28 00:55:31
Same here.
jkarlin
2015/09/02 17:37:06
Done.
|
| private: |
| struct ObserverList { |
| @@ -96,11 +106,12 @@ private: |
| Vector<size_t> zeroedObservers; // Indices in observers that are 0. |
| }; |
| - void setWebConnectionTypeImpl(WebConnectionType); |
| + void setWebConnectionImpl(WebConnectionType, double); |
|
adamk
2015/08/28 00:55:31
And here
jkarlin
2015/09/02 17:37:06
Done.
|
| + void setMaxBandwidthImpl(double); |
| using ObserverListMap = HashMap<ExecutionContext*, OwnPtr<ObserverList>>; |
| - void notifyObserversOnContext(WebConnectionType, ExecutionContext*); |
| + void notifyObserversOfConnectionChangeOnContext(WebConnectionType, double, ExecutionContext*); |
|
adamk
2015/08/28 00:55:31
And here
jkarlin
2015/09/02 17:37:07
Done.
|
| ObserverList* lockAndFindObserverList(ExecutionContext*); |
| @@ -112,6 +123,7 @@ private: |
| mutable Mutex m_mutex; |
| bool m_isOnLine; |
| WebConnectionType m_type; |
| + double m_maxBandwidth; |
| ObserverListMap m_observers; |
| bool m_testUpdatesOnly; |
| }; |