| OLD | NEW |
| 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/events/Event.h" | 8 #include "core/events/Event.h" |
| 9 #include "core/page/NetworkStateNotifier.h" | 9 #include "core/page/NetworkStateNotifier.h" |
| 10 #include "modules/EventTargetModules.h" | 10 #include "modules/EventTargetModules.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 stopObserving(); | 118 stopObserving(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 bool NetworkInformation::hasPendingActivity() const { | 121 bool NetworkInformation::hasPendingActivity() const { |
| 122 ASSERT(m_contextStopped || m_observing == hasEventListeners()); | 122 ASSERT(m_contextStopped || m_observing == hasEventListeners()); |
| 123 | 123 |
| 124 // Prevent collection of this object when there are active listeners. | 124 // Prevent collection of this object when there are active listeners. |
| 125 return m_observing; | 125 return m_observing; |
| 126 } | 126 } |
| 127 | 127 |
| 128 void NetworkInformation::stop() { | 128 void NetworkInformation::contextDestroyed() { |
| 129 m_contextStopped = true; | 129 m_contextStopped = true; |
| 130 stopObserving(); | 130 stopObserving(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void NetworkInformation::startObserving() { | 133 void NetworkInformation::startObserving() { |
| 134 if (!m_observing && !m_contextStopped) { | 134 if (!m_observing && !m_contextStopped) { |
| 135 m_type = networkStateNotifier().connectionType(); | 135 m_type = networkStateNotifier().connectionType(); |
| 136 networkStateNotifier().addObserver(this, getExecutionContext()); | 136 networkStateNotifier().addObserver(this, getExecutionContext()); |
| 137 m_observing = true; | 137 m_observing = true; |
| 138 } | 138 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 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 ActiveDOMObject::trace(visitor); | 158 ActiveDOMObject::trace(visitor); |
| 159 } | 159 } |
| 160 | 160 |
| 161 } // namespace blink | 161 } // namespace blink |
| OLD | NEW |