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

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

Issue 302543006: Adds ability to prevent browser connection updates in layout tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Nits Created 6 years, 7 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 | « no previous file | 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 2759274ae6b809d126db871f13dd0fca22d4dbaf..e60b93b64ff7636ee1e9cef386ce53ca59750f31 100644
--- a/Source/core/page/NetworkStateNotifier.h
+++ b/Source/core/page/NetworkStateNotifier.h
@@ -49,6 +49,7 @@ public:
NetworkStateNotifier()
: m_isOnLine(true)
, m_type(blink::ConnectionTypeOther)
+ , m_testUpdatesOnly(false)
{
}
@@ -73,6 +74,14 @@ public:
void addObserver(NetworkStateObserver*, ExecutionContext*);
void removeObserver(NetworkStateObserver*, ExecutionContext*);
+ // The following functions are for testing purposes.
+
+ // When true, setWebConnectionType calls are ignored and only setWebConnectionTypeForTest
+ // 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(blink::WebConnectionType);
+
private:
struct ObserverList {
ObserverList()
@@ -84,6 +93,8 @@ private:
Vector<size_t> zeroedObservers; // Indices in observers that are 0.
};
+ void setWebConnectionTypeImpl(blink::WebConnectionType);
+
typedef HashMap<ExecutionContext*, OwnPtr<ObserverList> > ObserverListMap;
void notifyObserversOnContext(ExecutionContext*, blink::WebConnectionType);
@@ -99,6 +110,7 @@ private:
bool m_isOnLine;
blink::WebConnectionType m_type;
ObserverListMap m_observers;
+ bool m_testUpdatesOnly;
};
NetworkStateNotifier& networkStateNotifier();
« no previous file with comments | « no previous file | Source/core/page/NetworkStateNotifier.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698