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

Unified Diff: Source/modules/netinfo/NavigatorNetworkInformation.cpp

Issue 291203002: Adds NetInfo v3 Web API to Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@netinfo1
Patch Set: Comment typo 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/NavigatorNetworkInformation.cpp
diff --git a/Source/modules/netinfo/NavigatorNetworkInformation.cpp b/Source/modules/netinfo/NavigatorNetworkInformation.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b1525364453268080dada101dbca6931727014f9
--- /dev/null
+++ b/Source/modules/netinfo/NavigatorNetworkInformation.cpp
@@ -0,0 +1,64 @@
+// 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.
+
+#include "config.h"
+#include "modules/netinfo/NavigatorNetworkInformation.h"
+
+#include "core/frame/DOMWindow.h"
+#include "core/frame/LocalFrame.h"
+#include "core/frame/Navigator.h"
+#include "modules/netinfo/NetworkInformation.h"
+
+namespace WebCore {
+
+NavigatorNetworkInformation::NavigatorNetworkInformation(Navigator& navigator)
+ : DOMWindowProperty(navigator.frame())
+{
+}
+
+NavigatorNetworkInformation::~NavigatorNetworkInformation()
+{
+}
+
+NavigatorNetworkInformation& NavigatorNetworkInformation::from(Navigator& navigator)
+{
+ NavigatorNetworkInformation* supplement = toNavigatorNetworkInformation(navigator);
+ if (!supplement) {
+ supplement = new NavigatorNetworkInformation(navigator);
+ provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement));
+ }
+ return *supplement;
+}
+
+NavigatorNetworkInformation* NavigatorNetworkInformation::toNavigatorNetworkInformation(Navigator& navigator)
+{
+ return static_cast<NavigatorNetworkInformation*>(WillBeHeapSupplement<Navigator>::from(navigator, supplementName()));
+}
+
+const char* NavigatorNetworkInformation::supplementName()
+{
+ return "NavigatorNetworkInformation";
+}
+
+NetworkInformation* NavigatorNetworkInformation::connection(Navigator& navigator)
+{
+ return NavigatorNetworkInformation::from(navigator).connection();
+}
+
+NetworkInformation* NavigatorNetworkInformation::connection()
+{
+ if (!m_connection && frame()) {
+ ASSERT(frame()->domWindow());
+ m_connection = NetworkInformation::create(frame()->domWindow()->executionContext());
+ }
+ return m_connection.get();
+}
+
+void NavigatorNetworkInformation::trace(Visitor* visitor)
+{
+ visitor->trace(m_connection);
+ WillBeHeapSupplement<Navigator>::trace(visitor);
+}
+
+} // namespace WebCore
« no previous file with comments | « Source/modules/netinfo/NavigatorNetworkInformation.h ('k') | Source/modules/netinfo/NavigatorNetworkInformation.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698