| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 if (RuntimeEnabledFeatures::netInfoDownlinkMaxEnabled()) | 87 if (RuntimeEnabledFeatures::netInfoDownlinkMaxEnabled()) |
| 88 dispatchEvent(Event::create(EventTypeNames::change)); | 88 dispatchEvent(Event::create(EventTypeNames::change)); |
| 89 } | 89 } |
| 90 | 90 |
| 91 const AtomicString& NetworkInformation::interfaceName() const { | 91 const AtomicString& NetworkInformation::interfaceName() const { |
| 92 return EventTargetNames::NetworkInformation; | 92 return EventTargetNames::NetworkInformation; |
| 93 } | 93 } |
| 94 | 94 |
| 95 ExecutionContext* NetworkInformation::getExecutionContext() const { | 95 ExecutionContext* NetworkInformation::getExecutionContext() const { |
| 96 return ActiveDOMObject::getExecutionContext(); | 96 return SuspendableObject::getExecutionContext(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void NetworkInformation::addedEventListener( | 99 void NetworkInformation::addedEventListener( |
| 100 const AtomicString& eventType, | 100 const AtomicString& eventType, |
| 101 RegisteredEventListener& registeredListener) { | 101 RegisteredEventListener& registeredListener) { |
| 102 EventTargetWithInlineData::addedEventListener(eventType, registeredListener); | 102 EventTargetWithInlineData::addedEventListener(eventType, registeredListener); |
| 103 startObserving(); | 103 startObserving(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void NetworkInformation::removedEventListener( | 106 void NetworkInformation::removedEventListener( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 void NetworkInformation::stopObserving() { | 141 void NetworkInformation::stopObserving() { |
| 142 if (m_observing) { | 142 if (m_observing) { |
| 143 networkStateNotifier().removeObserver(this, getExecutionContext()); | 143 networkStateNotifier().removeObserver(this, getExecutionContext()); |
| 144 m_observing = false; | 144 m_observing = false; |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 NetworkInformation::NetworkInformation(ExecutionContext* context) | 148 NetworkInformation::NetworkInformation(ExecutionContext* context) |
| 149 : ActiveScriptWrappable(this), | 149 : ActiveScriptWrappable(this), |
| 150 ActiveDOMObject(context), | 150 SuspendableObject(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 ActiveDOMObject::trace(visitor); | 158 SuspendableObject::trace(visitor); |
| 159 } | 159 } |
| 160 | 160 |
| 161 } // namespace blink | 161 } // namespace blink |
| OLD | NEW |