OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include <stdio.h> | 11 #include <stdio.h> |
12 #include <stdlib.h> | 12 #include <stdlib.h> |
13 #include <string.h> | 13 #include <string.h> |
14 | 14 |
15 #include <iostream> | 15 #include <iostream> |
16 #include <map> | 16 #include <map> |
| 17 #include <memory> |
| 18 |
17 #include "webrtc/base/checks.h" | 19 #include "webrtc/base/checks.h" |
18 #include "webrtc/base/flags.h" | 20 #include "webrtc/base/flags.h" |
19 #include "webrtc/base/helpers.h" | 21 #include "webrtc/base/helpers.h" |
20 #include "webrtc/base/nethelpers.h" | 22 #include "webrtc/base/nethelpers.h" |
21 #include "webrtc/base/network.h" | 23 #include "webrtc/base/network.h" |
22 #include "webrtc/base/logging.h" | 24 #include "webrtc/base/logging.h" |
23 #include "webrtc/base/scoped_ptr.h" | |
24 #include "webrtc/base/ssladapter.h" | 25 #include "webrtc/base/ssladapter.h" |
25 #include "webrtc/base/stringutils.h" | 26 #include "webrtc/base/stringutils.h" |
26 #include "webrtc/base/thread.h" | 27 #include "webrtc/base/thread.h" |
27 #include "webrtc/base/timeutils.h" | 28 #include "webrtc/base/timeutils.h" |
28 #include "webrtc/p2p/base/basicpacketsocketfactory.cc" | 29 #include "webrtc/p2p/base/basicpacketsocketfactory.cc" |
29 #include "webrtc/p2p/stunprober/stunprober.h" | 30 #include "webrtc/p2p/stunprober/stunprober.h" |
30 | 31 |
31 using stunprober::StunProber; | 32 using stunprober::StunProber; |
32 using stunprober::AsyncCallback; | 33 using stunprober::AsyncCallback; |
33 | 34 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 if (!addr.FromString(server)) { | 113 if (!addr.FromString(server)) { |
113 LOG(LS_ERROR) << "Parsing " << server << " failed."; | 114 LOG(LS_ERROR) << "Parsing " << server << " failed."; |
114 return -1; | 115 return -1; |
115 } | 116 } |
116 server_addresses.push_back(addr); | 117 server_addresses.push_back(addr); |
117 } | 118 } |
118 | 119 |
119 rtc::InitializeSSL(); | 120 rtc::InitializeSSL(); |
120 rtc::InitRandom(rtc::Time32()); | 121 rtc::InitRandom(rtc::Time32()); |
121 rtc::Thread* thread = rtc::ThreadManager::Instance()->WrapCurrentThread(); | 122 rtc::Thread* thread = rtc::ThreadManager::Instance()->WrapCurrentThread(); |
122 rtc::scoped_ptr<rtc::BasicPacketSocketFactory> socket_factory( | 123 std::unique_ptr<rtc::BasicPacketSocketFactory> socket_factory( |
123 new rtc::BasicPacketSocketFactory()); | 124 new rtc::BasicPacketSocketFactory()); |
124 rtc::scoped_ptr<rtc::BasicNetworkManager> network_manager( | 125 std::unique_ptr<rtc::BasicNetworkManager> network_manager( |
125 new rtc::BasicNetworkManager()); | 126 new rtc::BasicNetworkManager()); |
126 rtc::NetworkManager::NetworkList networks; | 127 rtc::NetworkManager::NetworkList networks; |
127 network_manager->GetNetworks(&networks); | 128 network_manager->GetNetworks(&networks); |
128 StunProber* prober = | 129 StunProber* prober = |
129 new StunProber(socket_factory.get(), rtc::Thread::Current(), networks); | 130 new StunProber(socket_factory.get(), rtc::Thread::Current(), networks); |
130 auto finish_callback = [thread](StunProber* prober, int result) { | 131 auto finish_callback = [thread](StunProber* prober, int result) { |
131 StopTrial(thread, prober, result); | 132 StopTrial(thread, prober, result); |
132 }; | 133 }; |
133 prober->Start(server_addresses, FLAG_shared_socket, FLAG_interval, | 134 prober->Start(server_addresses, FLAG_shared_socket, FLAG_interval, |
134 FLAG_pings_per_ip, FLAG_timeout, | 135 FLAG_pings_per_ip, FLAG_timeout, |
135 AsyncCallback(finish_callback)); | 136 AsyncCallback(finish_callback)); |
136 thread->Run(); | 137 thread->Run(); |
137 delete prober; | 138 delete prober; |
138 return 0; | 139 return 0; |
139 } | 140 } |
OLD | NEW |