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

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: Update test expectations Created 5 years, 4 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
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;
};

Powered by Google App Engine
This is Rietveld 408576698