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

Side by Side Diff: third_party/WebKit/Source/modules/netinfo/NetworkInformation.cpp

Issue 2704083002: Remove Page dependency from NetworkStateNotifier (Closed)
Patch Set: nullcheck for tests Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/page/Page.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/netinfo/NetworkInformation.h" 5 #include "modules/netinfo/NetworkInformation.h"
6 6
7 #include "core/dom/ExecutionContext.h" 7 #include "core/dom/ExecutionContext.h"
8 #include "core/dom/TaskRunnerHelper.h" 8 #include "core/dom/TaskRunnerHelper.h"
9 #include "core/events/Event.h" 9 #include "core/events/Event.h"
10 #include "core/page/NetworkStateNotifier.h" 10 #include "core/page/NetworkStateNotifier.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 123 }
124 124
125 void NetworkInformation::contextDestroyed(ExecutionContext*) { 125 void NetworkInformation::contextDestroyed(ExecutionContext*) {
126 m_contextStopped = true; 126 m_contextStopped = true;
127 stopObserving(); 127 stopObserving();
128 } 128 }
129 129
130 void NetworkInformation::startObserving() { 130 void NetworkInformation::startObserving() {
131 if (!m_observing && !m_contextStopped) { 131 if (!m_observing && !m_contextStopped) {
132 m_type = networkStateNotifier().connectionType(); 132 m_type = networkStateNotifier().connectionType();
133 networkStateNotifier().addObserver( 133 networkStateNotifier().addConnectionObserver(
134 this, TaskRunnerHelper::get(TaskType::Networking, getExecutionContext()) 134 this,
135 .get()); 135 TaskRunnerHelper::get(TaskType::Networking, getExecutionContext()));
136 m_observing = true; 136 m_observing = true;
137 } 137 }
138 } 138 }
139 139
140 void NetworkInformation::stopObserving() { 140 void NetworkInformation::stopObserving() {
141 if (m_observing) { 141 if (m_observing) {
142 networkStateNotifier().removeObserver( 142 networkStateNotifier().removeConnectionObserver(
143 this, TaskRunnerHelper::get(TaskType::Networking, getExecutionContext()) 143 this,
144 .get()); 144 TaskRunnerHelper::get(TaskType::Networking, getExecutionContext()));
145 m_observing = false; 145 m_observing = false;
146 } 146 }
147 } 147 }
148 148
149 NetworkInformation::NetworkInformation(ExecutionContext* context) 149 NetworkInformation::NetworkInformation(ExecutionContext* context)
150 : ContextLifecycleObserver(context), 150 : ContextLifecycleObserver(context),
151 m_type(networkStateNotifier().connectionType()), 151 m_type(networkStateNotifier().connectionType()),
152 m_downlinkMaxMbps(networkStateNotifier().maxBandwidth()), 152 m_downlinkMaxMbps(networkStateNotifier().maxBandwidth()),
153 m_observing(false), 153 m_observing(false),
154 m_contextStopped(false) {} 154 m_contextStopped(false) {}
155 155
156 DEFINE_TRACE(NetworkInformation) { 156 DEFINE_TRACE(NetworkInformation) {
157 EventTargetWithInlineData::trace(visitor); 157 EventTargetWithInlineData::trace(visitor);
158 ContextLifecycleObserver::trace(visitor); 158 ContextLifecycleObserver::trace(visitor);
159 } 159 }
160 160
161 } // namespace blink 161 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/Page.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698