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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_BASE_NETWORKCHANGENOTIFIER_H_
12 #define WEBRTC_BASE_NETWORKCHANGENOTIFIER_H_
13
14 #include "webrtc/base/logging.h"
15 #include "webrtc/base/scoped_ptr.h"
16 #include "webrtc/base/sigslot.h"
17
18 namespace rtc {
19 class NetworkChangeNotifier;
20 class NetworkChangeNotifierDelegate;
21
22 /*
23 * NetworkChangeNotifierFactory creates a notifier and a delegate.
24 * The delegate receives the network change notification from the
25 * external source (e.g., OS events) and passes it down to the notifier.
26 */
27 class NetworkChangeNotifierFactory {
28 public:
29 static NetworkChangeNotifierFactory* CreateFactory();
30
31 NetworkChangeNotifierDelegate* CreateDelegate();
32 NetworkChangeNotifierDelegate* GetDelegate();
33
34 NetworkChangeNotifier* CreateNotifier();
35
36 private:
37 NetworkChangeNotifierFactory() {}
38 scoped_ptr<NetworkChangeNotifierDelegate> delegate_;
39 };
40
41 /*
42 * The purpose of the delegate is to separate the class receiving the
43 * notification from the one notifying the NetworkManager.
44 */
45 class NetworkChangeNotifierDelegate {
46 public:
47 // Signal to be fired when it was notified network changes.
48 sigslot::signal0<> SignalNetworksChanged;
49
50 NetworkChangeNotifierDelegate() {}
51
52 // Called when it was notified about network changes.
53 void OnNetworkChangeNotified();
54 };
55
56 class NetworkChangeNotifier : public sigslot::has_slots<> {
57 public:
58 static void SetFactory(NetworkChangeNotifierFactory* factory);
59 static NetworkChangeNotifierFactory* GetFactory();
60 sigslot::signal0<> SignalNetworksChanged;
61
62 explicit NetworkChangeNotifier(NetworkChangeNotifierDelegate* delegate);
63
64 private:
65 // Called when it was notified about network changes by the delegate.
66 void OnNetworkChangeNotified() {
67 SignalNetworksChanged();
68 }
69
70 NetworkChangeNotifierDelegate* delegate_;
71 };
pthatcher1 2015/10/09 23:11:29 This seems really complex. Let's try and simplify
honghaiz3 2015/10/13 23:19:56 Done.
72
73 } // namespace rtc
74
75 #endif // WEBRTC_BASE_NETWORKCHANGENOTIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698