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 NetworkInfoConnection_h |
| 6 #define NetworkInfoConnection_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 Dictionary; |
| 17 class ExecutionContext; |
| 18 class ServiceWorker; |
| 19 |
| 20 class NetworkInfoConnection FINAL |
| 21 : public RefCountedWillBeGarbageCollected<NetworkInfoConnection> |
| 22 , public ScriptWrappable |
| 23 , public ActiveDOMObject |
| 24 , public EventTargetWithInlineData |
| 25 , public NetworkStateNotifier::NetworkStateObserver { |
| 26 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedWillBeGarbageCollected<NetworkInfo
Connection>); |
| 27 |
| 28 public: |
| 29 static PassRefPtrWillBeRawPtr<NetworkInfoConnection> create(ExecutionContext
*); |
| 30 ~NetworkInfoConnection(); |
| 31 |
| 32 String type() const; |
| 33 |
| 34 virtual void connectionTypeChange(blink::WebConnectionType) OVERRIDE; |
| 35 |
| 36 // EventTarget overrides. |
| 37 virtual const AtomicString& interfaceName() const OVERRIDE; |
| 38 virtual ExecutionContext* executionContext() const OVERRIDE; |
| 39 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even
tListener>, bool useCapture = false) OVERRIDE; |
| 40 virtual bool removeEventListener(const AtomicString& eventType, EventListene
r*, bool useCapture = false) OVERRIDE; |
| 41 virtual void removeAllEventListeners() OVERRIDE; |
| 42 |
| 43 // ActiveDOMObject overrides. |
| 44 virtual bool hasPendingActivity() const OVERRIDE; |
| 45 virtual void stop() OVERRIDE; |
| 46 |
| 47 DEFINE_ATTRIBUTE_EVENT_LISTENER(typechange); |
| 48 |
| 49 void trace(Visitor*); |
| 50 |
| 51 private: |
| 52 explicit NetworkInfoConnection(ExecutionContext*); |
| 53 void startObserving(); |
| 54 void stopObserving(); |
| 55 |
| 56 // Touched only on context thread. |
| 57 blink::WebConnectionType m_type; |
| 58 |
| 59 // Whether this object is listening for events from NetworkStateNotifier. |
| 60 bool m_observing; |
| 61 }; |
| 62 |
| 63 } // namespace WebCore |
| 64 |
| 65 #endif // NetworkInfoConnection_h |
OLD | NEW |