Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(803)

Unified Diff: Source/core/page/NetworkStateNotifier.h

Issue 1308943005: [NetInfo] Add Blink support for connection.change, connection.downlinkMax, and wimax (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/frame/UseCounter.h ('k') | Source/core/page/NetworkStateNotifier.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/NetworkStateNotifier.h
diff --git a/Source/core/page/NetworkStateNotifier.h b/Source/core/page/NetworkStateNotifier.h
index 66290b7c00fa531e61c2a83a98538ae59f0bdc2f..da794adcaf5a7f1787f5040acd7781fd91e7ffb2 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 maxBandwidthMbps) = 0;
};
NetworkStateNotifier()
: m_isOnLine(true)
, m_type(ConnectionTypeOther)
+ , m_maxBandwidthMbps(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_maxBandwidthMbps;
+ }
+
+ void setWebConnection(WebConnectionType, double maxBandwidthMbps);
// 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 maxBandwidthMbps);
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 maxBandwidthMbps);
+ void setMaxBandwidthImpl(double maxBandwidthMbps);
using ObserverListMap = HashMap<ExecutionContext*, OwnPtr<ObserverList>>;
- void notifyObserversOnContext(WebConnectionType, ExecutionContext*);
+ void notifyObserversOfConnectionChangeOnContext(WebConnectionType, double maxBandwidthMbps, ExecutionContext*);
ObserverList* lockAndFindObserverList(ExecutionContext*);
@@ -112,6 +123,7 @@ private:
mutable Mutex m_mutex;
bool m_isOnLine;
WebConnectionType m_type;
+ double m_maxBandwidthMbps;
ObserverListMap m_observers;
bool m_testUpdatesOnly;
};
« no previous file with comments | « Source/core/frame/UseCounter.h ('k') | Source/core/page/NetworkStateNotifier.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698