Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: content/renderer/media/webrtc/stun_field_trial.h

Issue 1417663004: Create an experiment to study whether too many bindings cause NAT failure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adjust the experiment design. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/thread_checker.h"
11 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 #include "content/renderer/p2p/network_list_manager.h"
15 #include "content/renderer/p2p/network_list_observer.h"
12 #include "third_party/webrtc/base/network.h" 16 #include "third_party/webrtc/base/network.h"
17 #include "third_party/webrtc/base/sigslot.h"
18 #include "third_party/webrtc/p2p/stunprober/stunprober.h"
13 19
14 namespace rtc { 20 namespace rtc {
15 class PacketSocketFactory; 21 class PacketSocketFactory;
16 class SocketAddress; 22 class SocketAddress;
17 } // namespace rtc 23 } // namespace rtc
18 24
19 namespace stunprober { 25 namespace content {
20 class StunProber;
21 } // namespace stunprober
22 26
23 namespace content { 27 using StunProber = stunprober::StunProber;
28
29 // Helper class to link the StunProbers together such that the first STUN ping
30 // in the next prober could be sent at the same interval as inside a
31 // prober. This is to maintain the consistency of intervals across the whole
32 // trial. It uses weak pointer to trigger next prober's Start(), in case if the
33 // owning PeerConnectionDependencyFactory is deleted in between.
34 class StunProberWithWeakPtr {
35 public:
36 StunProberWithWeakPtr(StunProber* prober);
Alexei Svitkine (slow) 2015/10/30 15:49:39 Nit: explicit
guoweis_webrtc 2015/10/30 16:34:13 Done.
37 virtual ~StunProberWithWeakPtr();
Alexei Svitkine (slow) 2015/10/30 15:49:39 Nit: Add a blank line below.
guoweis_webrtc 2015/10/30 16:34:13 Done.
38 void set_next_prober(StunProberWithWeakPtr* prober);
39 void Start(StunProber::Observer* observer);
40 base::WeakPtr<StunProberWithWeakPtr> GetWeakPtr() {
41 return weak_factory_.GetWeakPtr();
42 }
43 bool GetStats(StunProber::Stats* stats) { return prober_->GetStats(stats); }
44 StunProberWithWeakPtr* GetNextProber() { return next_prober_; }
45
46 private:
47 scoped_ptr<StunProber> prober_;
48 StunProberWithWeakPtr* next_prober_ = nullptr;
49 base::WeakPtrFactory<StunProberWithWeakPtr> weak_factory_;
50 };
Alexei Svitkine (slow) 2015/10/30 15:49:39 Nit: DISALLOW_COPY_AND_ASSIGN()
guoweis_webrtc 2015/10/30 16:34:13 Done.
24 51
25 // Wait for 30 seconds to avoid high CPU usage during browser start-up which 52 // 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 53 // 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 54 // 1 ms for no more than 3 seconds to see if time has passed for sending next
28 // stun probe. 55 // stun probe.
29 static const int kExperimentStartDelayMs = 30000; 56 static const int kExperimentStartDelayMs = 30000;
30 57
31 // This will use |factory| to create sockets, send stun binding requests with 58 class StunProberTrial : public StunProber::Observer,
32 // various intervals as determined by |params|, observed the success rate and 59 public sigslot::has_slots<> {
33 // latency of the stun responses and report through UMA. 60 public:
34 scoped_ptr<stunprober::StunProber> StartStunProbeTrial( 61 StunProberTrial(rtc::NetworkManager* network_manager,
35 const rtc::NetworkManager::NetworkList& networks, 62 const std::string& params,
36 const std::string& params, 63 rtc::PacketSocketFactory* factory);
37 rtc::PacketSocketFactory* factory); 64 ~StunProberTrial() override;
38 65
39 // Parsing function to decode the '/' separated parameter string |params|. 66 // This will use |factory_| to create sockets, send stun binding requests with
40 CONTENT_EXPORT bool ParseStunProbeParameters( 67 // various intervals as determined by |params|, observed the success rate and
41 const std::string& params, 68 // latency of the stun responses and report through UMA.
42 int* requests_per_ip, 69 void OnNetworksChanged();
43 int* interval_ms, 70
44 int* shared_socket_mode, 71 // Parsing function to decode the '/' separated parameter string |params|.
45 std::vector<rtc::SocketAddress>* servers); 72 static CONTENT_EXPORT bool ParseParameters(
73 const std::string& params,
74 int* requests_per_ip,
75 int* interval_ms,
76 int* shared_socket_mode,
77 int* batch_size,
78 int* total_batches,
79 std::vector<rtc::SocketAddress>* servers);
80
81 // stunprober::StunProber::Observer
82 void OnPrepared(StunProber* prober, StunProber::Status status) override;
83 void OnFinished(StunProber* prober, StunProber::Status status) override;
84
85 private:
86 void SaveHistogramData();
87
88 rtc::NetworkManager* network_manager_;
89 std::string params_;
90 rtc::PacketSocketFactory* factory_ = nullptr;
91 int total_probers_ = 0;
92 int batch_size_ = 0;
93 int ready_probers_ = 0;
94 int finished_probers_ = 0;
95 scoped_ptr<StunProberWithWeakPtr> prober_head_;
96 base::ThreadChecker thread_checker_;
97 };
Alexei Svitkine (slow) 2015/10/30 15:49:39 Nit: DISALLOW_COPY_AND_ASSIGN()
guoweis_webrtc 2015/10/30 16:34:13 Done.
46 98
47 } // namespace content 99 } // namespace content
48 100
49 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_STUN_FIELD_TRIAL_H_ 101 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_STUN_FIELD_TRIAL_H_
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc/peer_connection_dependency_factory.cc ('k') | content/renderer/media/webrtc/stun_field_trial.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698