| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_P2P_EMPTY_NETWORK_MANAGER_H_ | 5 #ifndef CONTENT_RENDERER_P2P_EMPTY_NETWORK_MANAGER_H_ |
| 6 #define CONTENT_RENDERER_P2P_EMPTY_NETWORK_MANAGER_H_ | 6 #define CONTENT_RENDERER_P2P_EMPTY_NETWORK_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/threading/thread_checker.h" | 9 #include "base/threading/thread_checker.h" |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 11 #include "third_party/webrtc/base/network.h" | 11 #include "third_party/webrtc/base/network.h" |
| 12 | 12 |
| 13 namespace rtc { |
| 14 class IPAddress; |
| 15 } // namespace rtc |
| 16 |
| 13 namespace content { | 17 namespace content { |
| 14 | 18 |
| 15 // A NetworkManager implementation which handles the case where local address | 19 // A NetworkManager implementation which handles the case where local address |
| 16 // enumeration is not requested and just returns empty network lists. This class | 20 // enumeration is not requested and just returns empty network lists. This class |
| 17 // is not thread safe and should only be used by WebRTC's worker thread. | 21 // is not thread safe and should only be used by WebRTC's worker thread. |
| 18 class EmptyNetworkManager : public rtc::NetworkManagerBase { | 22 class EmptyNetworkManager : public rtc::NetworkManagerBase { |
| 19 public: | 23 public: |
| 20 // This class is created by WebRTC's signaling thread but used by WebRTC's | 24 // This class is created by WebRTC's signaling thread but used by WebRTC's |
| 21 // worker thread |task_runner|. | 25 // worker thread |task_runner|. |
| 22 CONTENT_EXPORT EmptyNetworkManager(); | 26 CONTENT_EXPORT explicit EmptyNetworkManager( |
| 27 rtc::NetworkManager* network_manager); |
| 23 CONTENT_EXPORT ~EmptyNetworkManager() override; | 28 CONTENT_EXPORT ~EmptyNetworkManager() override; |
| 24 | 29 |
| 25 // rtc::NetworkManager: | 30 // rtc::NetworkManager: |
| 26 void StartUpdating() override; | 31 void StartUpdating() override; |
| 27 void StopUpdating() override; | 32 void StopUpdating() override; |
| 28 void GetNetworks(NetworkList* networks) const override; | 33 void GetNetworks(NetworkList* networks) const override; |
| 34 bool GetDefaultLocalAddress(int family, |
| 35 rtc::IPAddress* ipaddress) const override; |
| 29 | 36 |
| 30 private: | 37 private: |
| 31 void FireEvent(); | 38 void FireEvent(); |
| 32 void SendNetworksChangedSignal(); | 39 void SendNetworksChangedSignal(); |
| 33 | 40 |
| 34 base::ThreadChecker thread_checker_; | 41 base::ThreadChecker thread_checker_; |
| 35 | 42 |
| 36 // Track whether StartUpdating() has been called before. | 43 // Track whether StartUpdating() has been called before. |
| 37 bool updating_started_ = false; | 44 bool updating_started_ = false; |
| 38 | 45 |
| 46 // |network_manager_| is just a reference, owned by |
| 47 // PeerConnectionDependencyFactory. |
| 48 rtc::NetworkManager* network_manager_; |
| 49 |
| 39 base::WeakPtrFactory<EmptyNetworkManager> weak_ptr_factory_; | 50 base::WeakPtrFactory<EmptyNetworkManager> weak_ptr_factory_; |
| 40 | 51 |
| 41 DISALLOW_COPY_AND_ASSIGN(EmptyNetworkManager); | 52 DISALLOW_COPY_AND_ASSIGN(EmptyNetworkManager); |
| 42 }; | 53 }; |
| 43 | 54 |
| 44 } // namespace content | 55 } // namespace content |
| 45 | 56 |
| 46 #endif // CONTENT_RENDERER_P2P_EMPTY_NETWORK_MANAGER_H_ | 57 #endif // CONTENT_RENDERER_P2P_EMPTY_NETWORK_MANAGER_H_ |
| OLD | NEW |