Chromium Code Reviews| 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 |