Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1242)

Unified Diff: Source/modules/netinfo/NetworkInfoConnection.h

Issue 291203002: Adds NetInfo v3 Web API to Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@netinfo1
Patch Set: Simplified layout tests Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/netinfo/NetworkInfoConnection.h
diff --git a/Source/modules/netinfo/NetworkInfoConnection.h b/Source/modules/netinfo/NetworkInfoConnection.h
new file mode 100644
index 0000000000000000000000000000000000000000..2087b7bc6617f2d3f0f35b54f8add326e3e1dac7
--- /dev/null
+++ b/Source/modules/netinfo/NetworkInfoConnection.h
@@ -0,0 +1,65 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NetworkInfoConnection_h
+#define NetworkInfoConnection_h
+
+#include "bindings/v8/ScriptWrappable.h"
+#include "core/dom/ActiveDOMObject.h"
+#include "core/events/EventTarget.h"
+#include "core/page/NetworkStateNotifier.h"
+#include "public/platform/WebConnectionType.h"
+
+namespace WebCore {
+
+class Dictionary;
+class ExecutionContext;
+class ServiceWorker;
+
+class NetworkInfoConnection FINAL
+ : public RefCountedWillBeGarbageCollected<NetworkInfoConnection>
+ , public ScriptWrappable
+ , public ActiveDOMObject
+ , public EventTargetWithInlineData
+ , public NetworkStateNotifier::NetworkStateObserver {
+ DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedWillBeGarbageCollected<NetworkInfoConnection>);
+
+public:
+ static PassRefPtrWillBeRawPtr<NetworkInfoConnection> create(ExecutionContext*);
+ ~NetworkInfoConnection();
+
+ String type() const;
+
+ virtual void connectionTypeChange(blink::WebConnectionType) OVERRIDE;
+
+ // EventTarget overrides.
+ virtual const AtomicString& interfaceName() const OVERRIDE;
+ virtual ExecutionContext* executionContext() const OVERRIDE;
+ virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture = false) OVERRIDE;
+ virtual bool removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture = false) OVERRIDE;
+ virtual void removeAllEventListeners() OVERRIDE;
+
+ // ActiveDOMObject overrides.
+ virtual bool hasPendingActivity() const OVERRIDE;
+ virtual void stop() OVERRIDE;
+
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(typechange);
+
+ void trace(Visitor*);
+
+private:
+ explicit NetworkInfoConnection(ExecutionContext*);
+ void startObserving();
+ void stopObserving();
+
+ // Touched only on context thread.
+ blink::WebConnectionType m_type;
+
+ // Whether this object is listening for events from NetworkStateNotifier.
+ bool m_observing;
+};
+
+} // namespace WebCore
+
+#endif // NetworkInfoConnection_h

Powered by Google App Engine
This is Rietveld 408576698