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_MEDIA_WEBRTC_STUN_FIELD_TRIAL_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_STUN_FIELD_TRIAL_H_ |
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_STUN_FIELD_TRIAL_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_STUN_FIELD_TRIAL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | |
9 | 10 |
10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | |
11 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
12 #include "third_party/webrtc/base/network.h" | 14 #include "third_party/webrtc/base/network.h" |
15 #include "third_party/webrtc/p2p/stunprober/stunprober.h" | |
13 | 16 |
14 namespace rtc { | 17 namespace rtc { |
15 class PacketSocketFactory; | 18 class PacketSocketFactory; |
16 class SocketAddress; | 19 class SocketAddress; |
17 } // namespace rtc | 20 } // namespace rtc |
18 | 21 |
19 namespace stunprober { | 22 namespace content { |
20 class StunProber; | |
21 } // namespace stunprober | |
22 | 23 |
23 namespace content { | 24 // Helper class to link the StunProbers together such that they could be started |
25 // in the right timing. | |
26 class StunProberWithWeakPtr { | |
27 public: | |
28 StunProberWithWeakPtr(stunprober::StunProber* prober); | |
29 virtual ~StunProberWithWeakPtr(); | |
30 void set_next_prober(StunProberWithWeakPtr* prober); | |
31 void Start(stunprober::AsyncCallback callback); | |
32 base::WeakPtr<StunProberWithWeakPtr> GetWeakPtr() { | |
33 return weak_factory_.GetWeakPtr(); | |
34 } | |
35 bool GetStats(stunprober::StunProber::Stats* stats) { | |
36 return prober_->GetStats(stats); | |
37 } | |
38 StunProberWithWeakPtr* GetNextProber() { return next_prober_; } | |
39 | |
40 private: | |
41 scoped_ptr<stunprober::StunProber> prober_; | |
42 StunProberWithWeakPtr* next_prober_ = nullptr; | |
pthatcher2
2015/10/22 05:27:52
So a StunProberWithWeakPtr is really a linked list
| |
43 base::WeakPtrFactory<StunProberWithWeakPtr> weak_factory_; | |
44 }; | |
45 | |
46 typedef std::vector<StunProberWithWeakPtr*> ListOfStunProbers; | |
pthatcher2
2015/10/22 05:27:52
Doesn't the style guide discourage typedefs like t
| |
24 | 47 |
25 // Wait for 30 seconds to avoid high CPU usage during browser start-up which | 48 // Wait for 30 seconds to avoid high CPU usage during browser start-up which |
26 // might affect the accuracy of the trial. The trial wakes up the browser every | 49 // might affect the accuracy of the trial. The trial wakes up the browser every |
27 // 1 ms for no more than 3 seconds to see if time has passed for sending next | 50 // 1 ms for no more than 3 seconds to see if time has passed for sending next |
28 // stun probe. | 51 // stun probe. |
29 static const int kExperimentStartDelayMs = 30000; | 52 static const int kExperimentStartDelayMs = 30000; |
30 | 53 |
31 // This will use |factory| to create sockets, send stun binding requests with | 54 // This will use |factory| to create sockets, send stun binding requests with |
32 // various intervals as determined by |params|, observed the success rate and | 55 // various intervals as determined by |params|, observed the success rate and |
33 // latency of the stun responses and report through UMA. | 56 // latency of the stun responses and report through UMA. |
34 scoped_ptr<stunprober::StunProber> StartStunProbeTrial( | 57 void StartStunProbeTrial(const rtc::NetworkManager::NetworkList& networks, |
35 const rtc::NetworkManager::NetworkList& networks, | 58 const std::string& params, |
36 const std::string& params, | 59 rtc::PacketSocketFactory* factory, |
37 rtc::PacketSocketFactory* factory); | 60 ListOfStunProbers* probers); |
38 | 61 |
39 // Parsing function to decode the '/' separated parameter string |params|. | 62 // Parsing function to decode the '/' separated parameter string |params|. |
40 CONTENT_EXPORT bool ParseStunProbeParameters( | 63 CONTENT_EXPORT bool ParseStunProbeParameters( |
41 const std::string& params, | 64 const std::string& params, |
42 int* requests_per_ip, | 65 int* requests_per_ip, |
43 int* interval_ms, | 66 int* interval_ms, |
44 int* shared_socket_mode, | 67 int* shared_socket_mode, |
68 int* rounds, | |
45 std::vector<rtc::SocketAddress>* servers); | 69 std::vector<rtc::SocketAddress>* servers); |
46 | 70 |
47 } // namespace content | 71 } // namespace content |
48 | 72 |
49 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_STUN_FIELD_TRIAL_H_ | 73 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_STUN_FIELD_TRIAL_H_ |
OLD | NEW |