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

Side by Side 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. 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 #include "webrtc/base/networkchangenotifier.h"
12
13 #include "webrtc/base/common.h"
14
15 namespace {
16 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
17 }
18
19 namespace rtc {
20
21 NetworkChangeNotifierFactory* NetworkChangeNotifierFactory::CreateFactory() {
22 return new NetworkChangeNotifierFactory();
23 }
24
25 NetworkChangeNotifierDelegate* NetworkChangeNotifierFactory::CreateDelegate() {
26 delegate_.reset(new NetworkChangeNotifierDelegate());
27 return delegate_.get();
28 }
29
30 NetworkChangeNotifierDelegate* NetworkChangeNotifierFactory::GetDelegate() {
31 return delegate_.get();
32 }
33
34 NetworkChangeNotifier* NetworkChangeNotifierFactory::CreateNotifier() {
35 if (!GetDelegate()) {
36 return nullptr;
37 }
38 return new NetworkChangeNotifier(GetDelegate());
39 }
40
41 void NetworkChangeNotifierDelegate::OnNetworkChangeNotified() {
42 LOG(LS_VERBOSE) << "Network change is notified at the delegate";
43 SignalNetworksChanged();
44 }
45
46 void NetworkChangeNotifier::SetFactory(NetworkChangeNotifierFactory* factory) {
47 network_change_notifier_factory = factory;
48 }
49
50 NetworkChangeNotifierFactory* NetworkChangeNotifier::GetFactory() {
51 return network_change_notifier_factory;
52 }
53
54 NetworkChangeNotifier::NetworkChangeNotifier(
55 NetworkChangeNotifierDelegate* delegate) {
56 ASSERT(delegate != nullptr);
57 delegate_ = delegate;
58 delegate_->SignalNetworksChanged.connect(
59 this, &NetworkChangeNotifier::OnNetworkChangeNotified);
60 }
61
62 } // namespace rtc
OLDNEW
« webrtc/base/networkchangenotifier.h ('K') | « webrtc/base/networkchangenotifier.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698