| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 NetworkInformation* connection = new NetworkInformation(context); | 48 NetworkInformation* connection = new NetworkInformation(context); |
| 49 connection->suspendIfNeeded(); | 49 connection->suspendIfNeeded(); |
| 50 return connection; | 50 return connection; |
| 51 } | 51 } |
| 52 | 52 |
| 53 NetworkInformation::~NetworkInformation() { | 53 NetworkInformation::~NetworkInformation() { |
| 54 ASSERT(!m_observing); | 54 ASSERT(!m_observing); |
| 55 } | 55 } |
| 56 | 56 |
| 57 String NetworkInformation::type() const { | 57 String NetworkInformation::type() const { |
| 58 // m_type is only updated when listening for events, so ask networkStateNotifi
er | 58 // m_type is only updated when listening for events, so ask |
| 59 // if not listening (crbug.com/379841). | 59 // networkStateNotifier if not listening (crbug.com/379841). |
| 60 if (!m_observing) | 60 if (!m_observing) |
| 61 return connectionTypeToString(networkStateNotifier().connectionType()); | 61 return connectionTypeToString(networkStateNotifier().connectionType()); |
| 62 | 62 |
| 63 // If observing, return m_type which changes when the event fires, per spec. | 63 // If observing, return m_type which changes when the event fires, per spec. |
| 64 return connectionTypeToString(m_type); | 64 return connectionTypeToString(m_type); |
| 65 } | 65 } |
| 66 | 66 |
| 67 double NetworkInformation::downlinkMax() const { | 67 double NetworkInformation::downlinkMax() const { |
| 68 if (!m_observing) | 68 if (!m_observing) |
| 69 return networkStateNotifier().maxBandwidth(); | 69 return networkStateNotifier().maxBandwidth(); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |