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 "config.h" | 5 #include "config.h" |
6 #include "modules/netinfo/NetworkInformation.h" | 6 #include "modules/netinfo/NetworkInformation.h" |
7 | 7 |
8 #include "core/dom/ExecutionContext.h" | 8 #include "core/dom/ExecutionContext.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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 { | 55 { |
56 // m_type is only updated when listening for events, so ask networkStateNoti
fier | 56 // m_type is only updated when listening for events, so ask networkStateNoti
fier |
57 // if not listening (crbug.com/379841). | 57 // if not listening (crbug.com/379841). |
58 if (!m_observing) | 58 if (!m_observing) |
59 return connectionTypeToString(networkStateNotifier().connectionType()); | 59 return connectionTypeToString(networkStateNotifier().connectionType()); |
60 | 60 |
61 // If observing, return m_type which changes when the event fires, per spec. | 61 // If observing, return m_type which changes when the event fires, per spec. |
62 return connectionTypeToString(m_type); | 62 return connectionTypeToString(m_type); |
63 } | 63 } |
64 | 64 |
65 void NetworkInformation::connectionTypeChange(blink::WebConnectionType type) | 65 void NetworkInformation::connectionTypeChange(WebConnectionType type) |
66 { | 66 { |
67 ASSERT(executionContext()->isContextThread()); | 67 ASSERT(executionContext()->isContextThread()); |
68 | 68 |
69 // This can happen if the observer removes and then adds itself again | 69 // This can happen if the observer removes and then adds itself again |
70 // during notification. | 70 // during notification. |
71 if (m_type == type) | 71 if (m_type == type) |
72 return; | 72 return; |
73 | 73 |
74 m_type = type; | 74 m_type = type; |
75 dispatchEvent(Event::create(EventTypeNames::typechange)); | 75 dispatchEvent(Event::create(EventTypeNames::typechange)); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 NetworkInformation::NetworkInformation(ExecutionContext* context) | 143 NetworkInformation::NetworkInformation(ExecutionContext* context) |
144 : ActiveDOMObject(context) | 144 : ActiveDOMObject(context) |
145 , m_type(networkStateNotifier().connectionType()) | 145 , m_type(networkStateNotifier().connectionType()) |
146 , m_observing(false) | 146 , m_observing(false) |
147 , m_contextStopped(false) | 147 , m_contextStopped(false) |
148 { | 148 { |
149 ScriptWrappable::init(this); | 149 ScriptWrappable::init(this); |
150 } | 150 } |
151 | 151 |
152 } // namespace blink | 152 } // namespace blink |
OLD | NEW |