Chromium Code Reviews

Unified Diff: webrtc/base/networkchangenotifier.cc

Issue 1391703003: Create network change notifier. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Minor fix on the comment Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« webrtc/base/networkchangenotifier.h ('K') | « webrtc/base/networkchangenotifier.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/networkchangenotifier.cc
diff --git a/webrtc/base/networkchangenotifier.cc b/webrtc/base/networkchangenotifier.cc
new file mode 100644
index 0000000000000000000000000000000000000000..412322cabe77d54e25eef3a77ec524c17836f137
--- /dev/null
+++ b/webrtc/base/networkchangenotifier.cc
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2015 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/base/networkchangenotifier.h"
+
+#include "webrtc/base/common.h"
+
+namespace {
+rtc::NetworkChangeNotifierFactory* network_change_notifier_factory = nullptr;
pthatcher1 2015/10/09 23:11:29 Can we create the Java object from C++ and avoid n
honghaiz3 2015/10/13 23:19:56 Now we create the Java object from c++. I still k
+}
+
+namespace rtc {
+
+NetworkChangeNotifierFactory* NetworkChangeNotifierFactory::CreateFactory() {
+ return new NetworkChangeNotifierFactory();
+}
+
+NetworkChangeNotifierDelegate* NetworkChangeNotifierFactory::CreateDelegate() {
+ delegate_.reset(new NetworkChangeNotifierDelegate());
+ return delegate_.get();
+}
+
+NetworkChangeNotifierDelegate* NetworkChangeNotifierFactory::GetDelegate() {
+ return delegate_.get();
+}
+
+NetworkChangeNotifier* NetworkChangeNotifierFactory::CreateNotifier() {
+ if (!GetDelegate()) {
+ return nullptr;
+ }
+ return new NetworkChangeNotifier(GetDelegate());
+}
+
+void NetworkChangeNotifierDelegate::OnNetworkChangeNotified() {
+ LOG(LS_VERBOSE) << "Network change is notified at the delegate";
+ SignalNetworksChanged();
+}
+
+void NetworkChangeNotifier::SetFactory(NetworkChangeNotifierFactory* factory) {
+ network_change_notifier_factory = factory;
+}
+
+NetworkChangeNotifierFactory* NetworkChangeNotifier::GetFactory() {
+ return network_change_notifier_factory;
+}
+
+NetworkChangeNotifier::NetworkChangeNotifier(
+ NetworkChangeNotifierDelegate* delegate) {
+ ASSERT(delegate != nullptr);
+ delegate_ = delegate;
+ delegate_->SignalNetworksChanged.connect(
+ this, &NetworkChangeNotifier::OnNetworkChangeNotified);
+}
+
+} // namespace rtc
« webrtc/base/networkchangenotifier.h ('K') | « webrtc/base/networkchangenotifier.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine