Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/networkmonitor.h" | |
| 12 | |
| 13 #include "webrtc/base/common.h" | |
| 14 | |
| 15 namespace { | |
| 16 const uint32_t UPDATE_NETWORKS_MESSAGE = 1; | |
| 17 | |
| 18 // A global network monitor factory injected by the peer connection client. | |
|
pthatcher1
2015/10/15 08:11:43
I don't think you need to say "by the peer connect
honghaiz3
2015/10/15 19:02:41
Done.
| |
| 19 // This can be NULL if the client has not injected any factory. In that case, | |
| 20 // no network monitor will be created. If a client injected a factory, it is | |
|
pthatcher1
2015/10/15 08:11:43
Isn't it up to callers to decided what to do if th
honghaiz3
2015/10/15 19:02:41
Done.
| |
| 21 // up to the client to release the resource by setting it to nullptr. | |
| 22 rtc::NetworkMonitorFactory* network_monitor_factory = nullptr; | |
| 23 } // namespace | |
| 24 | |
| 25 namespace rtc { | |
| 26 void NetworkMonitor::OnNetworksChanged() { | |
| 27 LOG(LS_VERBOSE) << "Network change is received at the network monitor"; | |
| 28 thread_->Post(this, UPDATE_NETWORKS_MESSAGE); | |
| 29 } | |
| 30 | |
| 31 void NetworkMonitor::OnMessage(Message* msg) { | |
| 32 ASSERT(msg->message_id == UPDATE_NETWORKS_MESSAGE); | |
| 33 SignalNetworksChanged(); | |
| 34 } | |
| 35 | |
| 36 void NetworkMonitorFactory::SetFactory(NetworkMonitorFactory* factory) { | |
| 37 if (network_monitor_factory != nullptr) { | |
| 38 delete network_monitor_factory; | |
| 39 } | |
| 40 network_monitor_factory = factory; | |
|
pthatcher1
2015/10/15 08:11:43
What's the thread safety on this? Do we have to s
honghaiz3
2015/10/15 19:02:41
Added comments.
| |
| 41 } | |
| 42 | |
| 43 NetworkMonitorFactory* NetworkMonitorFactory::GetFactory() { | |
| 44 return network_monitor_factory; | |
| 45 } | |
| 46 | |
| 47 } // namespace rtc | |
| OLD | NEW |