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

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: Remove StunProberWithWeakPtr and replace with a timer 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/macros.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/threading/thread_checker.h"
13 #include "base/timer/timer.h"
11 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 #include "content/renderer/p2p/network_list_manager.h"
16 #include "content/renderer/p2p/network_list_observer.h"
12 #include "third_party/webrtc/base/network.h" 17 #include "third_party/webrtc/base/network.h"
18 #include "third_party/webrtc/base/sigslot.h"
19 #include "third_party/webrtc/p2p/stunprober/stunprober.h"
13 20
14 namespace rtc { 21 namespace rtc {
15 class PacketSocketFactory; 22 class PacketSocketFactory;
16 class SocketAddress; 23 class SocketAddress;
17 } // namespace rtc 24 } // namespace rtc
18 25
19 namespace stunprober {
20 class StunProber;
21 } // namespace stunprober
22
23 namespace content { 26 namespace content {
24 27
25 // Wait for 30 seconds to avoid high CPU usage during browser start-up which 28 // 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 29 // 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 30 // 1 ms for no more than 3 seconds to see if time has passed for sending next
28 // stun probe. 31 // stun probe.
29 static const int kExperimentStartDelayMs = 30000; 32 static const int kExperimentStartDelayMs = 30000;
30 33
31 // This will use |factory| to create sockets, send stun binding requests with 34 class StunProberTrial : public stunprober::StunProber::Observer,
32 // various intervals as determined by |params|, observed the success rate and 35 public sigslot::has_slots<> {
33 // latency of the stun responses and report through UMA. 36 public:
34 scoped_ptr<stunprober::StunProber> StartStunProbeTrial( 37 struct Param {
35 const rtc::NetworkManager::NetworkList& networks, 38 Param();
36 const std::string& params, 39 ~Param();
37 rtc::PacketSocketFactory* factory); 40 int requests_per_ip = 0;
41 int interval_ms = 0;
42 int shared_socket_mode = 0;
43 int batch_size = 0;
44 int total_batches = 0;
45 std::vector<rtc::SocketAddress> servers;
46 };
38 47
39 // Parsing function to decode the '/' separated parameter string |params|. 48 StunProberTrial(rtc::NetworkManager* network_manager,
40 CONTENT_EXPORT bool ParseStunProbeParameters( 49 const std::string& params,
41 const std::string& params, 50 rtc::PacketSocketFactory* factory);
42 int* requests_per_ip, 51 ~StunProberTrial() override;
43 int* interval_ms, 52
44 int* shared_socket_mode, 53 // This will use |factory_| to create sockets, send stun binding requests with
45 std::vector<rtc::SocketAddress>* servers); 54 // various intervals as determined by |params|, observed the success rate and
55 // latency of the stun responses and report through UMA.
56 void OnNetworksChanged();
Sergey Ulanov 2015/10/30 22:50:06 This doesn't need to be public.
guoweis_left_chromium 2015/10/30 23:15:00 Done.
57
58 // Parsing function to decode the '/' separated parameter string |params|.
59 static CONTENT_EXPORT bool ParseParameters(const std::string& param_line,
Sergey Ulanov 2015/10/30 22:50:06 It looks like this function is public just so that
guoweis_left_chromium 2015/10/30 23:15:00 Done.
60 Param* params);
61
62 // stunprober::StunProber::Observer:
63 void OnPrepared(stunprober::StunProber* prober,
Sergey Ulanov 2015/10/30 22:50:06 Move this to the private section to indicate that
guoweis_left_chromium 2015/10/30 23:14:59 Done.
64 stunprober::StunProber::Status status) override;
65 void OnFinished(stunprober::StunProber* prober,
66 stunprober::StunProber::Status status) override;
67
68 // This will be invoked repeatedly for |total_probers_| times with the
69 // interval equal to the estimated run time of a prober.
70 void OnTimer();
Sergey Ulanov 2015/10/30 22:50:06 This doesn't need to be public.
guoweis_left_chromium 2015/10/30 23:14:59 Done.
71
72 private:
73 void SaveHistogramData();
74
75 rtc::NetworkManager* network_manager_;
76 std::string param_line_;
77 rtc::PacketSocketFactory* factory_ = nullptr;
78 int total_probers_ = 0;
79 int batch_size_ = 0;
80 int ready_probers_ = 0;
81 int started_probers_ = 0;
82 int finished_probers_ = 0;
83 std::vector<stunprober::StunProber*> probers_;
Sergey Ulanov 2015/10/30 22:50:06 add #include <vector>
guoweis_left_chromium 2015/10/30 23:15:00 Done.
84 base::ThreadChecker thread_checker_;
85
86 base::RepeatingTimer timer_;
87
88 DISALLOW_COPY_AND_ASSIGN(StunProberTrial);
89 };
46 90
47 } // namespace content 91 } // namespace content
48 92
49 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_STUN_FIELD_TRIAL_H_ 93 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_STUN_FIELD_TRIAL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698