OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NetworkInformation_h |
| 6 #define NetworkInformation_h |
| 7 |
| 8 #include "bindings/v8/ScriptWrappable.h" |
| 9 #include "core/dom/ActiveDOMObject.h" |
| 10 #include "core/events/EventTarget.h" |
| 11 #include "core/page/NetworkStateNotifier.h" |
| 12 #include "public/platform/WebConnectionType.h" |
| 13 |
| 14 namespace WebCore { |
| 15 |
| 16 class ExecutionContext; |
| 17 |
| 18 class NetworkInformation FINAL |
| 19 : public RefCountedWillBeGarbageCollected<NetworkInformation> |
| 20 , public ScriptWrappable |
| 21 , public ActiveDOMObject |
| 22 , public EventTargetWithInlineData |
| 23 , public NetworkStateNotifier::NetworkStateObserver { |
| 24 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedWillBeGarbageCollected<NetworkInfo
rmation>); |
| 25 |
| 26 public: |
| 27 static PassRefPtrWillBeRawPtr<NetworkInformation> create(ExecutionContext*); |
| 28 virtual ~NetworkInformation(); |
| 29 |
| 30 String type() const; |
| 31 |
| 32 virtual void connectionTypeChange(blink::WebConnectionType) OVERRIDE; |
| 33 |
| 34 // EventTarget overrides. |
| 35 virtual const AtomicString& interfaceName() const OVERRIDE; |
| 36 virtual ExecutionContext* executionContext() const OVERRIDE; |
| 37 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even
tListener>, bool useCapture = false) OVERRIDE; |
| 38 virtual bool removeEventListener(const AtomicString& eventType, EventListene
r*, bool useCapture = false) OVERRIDE; |
| 39 virtual void removeAllEventListeners() OVERRIDE; |
| 40 |
| 41 // ActiveDOMObject overrides. |
| 42 virtual bool hasPendingActivity() const OVERRIDE; |
| 43 virtual void stop() OVERRIDE; |
| 44 |
| 45 DEFINE_ATTRIBUTE_EVENT_LISTENER(typechange); |
| 46 |
| 47 private: |
| 48 explicit NetworkInformation(ExecutionContext*); |
| 49 void startObserving(); |
| 50 void stopObserving(); |
| 51 |
| 52 // Touched only on context thread. |
| 53 blink::WebConnectionType m_type; |
| 54 |
| 55 // Whether this object is listening for events from NetworkStateNotifier. |
| 56 bool m_observing; |
| 57 |
| 58 // Whether ActiveDomObject::stop has been called. |
| 59 bool m_contextStopped; |
| 60 }; |
| 61 |
| 62 } // namespace WebCore |
| 63 |
| 64 #endif // NetworkInformation_h |
OLD | NEW |