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

Unified Diff: webrtc/base/networkchangenotifier.h

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. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/base/networkchangenotifier.h
diff --git a/webrtc/base/networkchangenotifier.h b/webrtc/base/networkchangenotifier.h
new file mode 100644
index 0000000000000000000000000000000000000000..3d3d3212558fd93b6eeafad002fa444a8b289a8a
--- /dev/null
+++ b/webrtc/base/networkchangenotifier.h
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+#ifndef WEBRTC_BASE_NETWORKCHANGENOTIFIER_H_
+#define WEBRTC_BASE_NETWORKCHANGENOTIFIER_H_
+
+#include "webrtc/base/logging.h"
+#include "webrtc/base/scoped_ptr.h"
+#include "webrtc/base/sigslot.h"
+
+namespace rtc {
+class NetworkChangeNotifier;
+class NetworkChangeNotifierDelegate;
+
+/*
+ * NetworkChangeNotifierFactory creates a notifier and a delegate.
+ * The delegate receives the network change notification from the
+ * external source (e.g., OS events) and passes it down to the notifier.
+ */
+class NetworkChangeNotifierFactory {
+ public:
+ static NetworkChangeNotifierFactory* CreateFactory();
+
+ NetworkChangeNotifierDelegate* CreateDelegate();
+ NetworkChangeNotifierDelegate* GetDelegate();
+
+ NetworkChangeNotifier* CreateNotifier();
+
+ private:
+ NetworkChangeNotifierFactory() {}
+ scoped_ptr<NetworkChangeNotifierDelegate> delegate_;
+};
+
+/*
+ * The purpose of the delegate is to separate the class receiving the
+ * notification from the one notifying the NetworkManager.
+ */
+class NetworkChangeNotifierDelegate {
+ public:
+ // Signal to be fired when it was notified network changes.
+ sigslot::signal0<> SignalNetworksChanged;
+
+ NetworkChangeNotifierDelegate() {}
+
+ // Called when it was notified about network changes.
+ void OnNetworkChangeNotified();
+};
+
+class NetworkChangeNotifier : public sigslot::has_slots<> {
+ public:
+ static void SetFactory(NetworkChangeNotifierFactory* factory);
+ static NetworkChangeNotifierFactory* GetFactory();
+ sigslot::signal0<> SignalNetworksChanged;
+
+ explicit NetworkChangeNotifier(NetworkChangeNotifierDelegate* delegate);
+
+ private:
+ // Called when it was notified about network changes by the delegate.
+ void OnNetworkChangeNotified() {
+ SignalNetworksChanged();
+ }
+
+ NetworkChangeNotifierDelegate* delegate_;
+};
pthatcher1 2015/10/09 23:11:29 This seems really complex. Let's try and simplify
honghaiz3 2015/10/13 23:19:56 Done.
+
+} // namespace rtc
+
+#endif // WEBRTC_BASE_NETWORKCHANGENOTIFIER_H_

Powered by Google App Engine
This is Rietveld 408576698