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

Unified 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, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/webrtc/stun_field_trial.h
diff --git a/content/renderer/media/webrtc/stun_field_trial.h b/content/renderer/media/webrtc/stun_field_trial.h
index 4095bede6812c01ab81f8b934d2f642a2731e52f..dd496db6d0c5fcebf3c7e2a6233918dbf042617d 100644
--- a/content/renderer/media/webrtc/stun_field_trial.h
+++ b/content/renderer/media/webrtc/stun_field_trial.h
@@ -7,19 +7,22 @@
#include <string>
+#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
+#include "base/threading/thread_checker.h"
+#include "base/timer/timer.h"
#include "content/common/content_export.h"
+#include "content/renderer/p2p/network_list_manager.h"
+#include "content/renderer/p2p/network_list_observer.h"
#include "third_party/webrtc/base/network.h"
+#include "third_party/webrtc/base/sigslot.h"
+#include "third_party/webrtc/p2p/stunprober/stunprober.h"
namespace rtc {
class PacketSocketFactory;
class SocketAddress;
} // namespace rtc
-namespace stunprober {
-class StunProber;
-} // namespace stunprober
-
namespace content {
// Wait for 30 seconds to avoid high CPU usage during browser start-up which
@@ -28,21 +31,62 @@ namespace content {
// stun probe.
static const int kExperimentStartDelayMs = 30000;
-// This will use |factory| to create sockets, send stun binding requests with
-// various intervals as determined by |params|, observed the success rate and
-// latency of the stun responses and report through UMA.
-scoped_ptr<stunprober::StunProber> StartStunProbeTrial(
- const rtc::NetworkManager::NetworkList& networks,
- const std::string& params,
- rtc::PacketSocketFactory* factory);
-
-// Parsing function to decode the '/' separated parameter string |params|.
-CONTENT_EXPORT bool ParseStunProbeParameters(
- const std::string& params,
- int* requests_per_ip,
- int* interval_ms,
- int* shared_socket_mode,
- std::vector<rtc::SocketAddress>* servers);
+class StunProberTrial : public stunprober::StunProber::Observer,
+ public sigslot::has_slots<> {
+ public:
+ struct Param {
+ Param();
+ ~Param();
+ int requests_per_ip = 0;
+ int interval_ms = 0;
+ int shared_socket_mode = 0;
+ int batch_size = 0;
+ int total_batches = 0;
+ std::vector<rtc::SocketAddress> servers;
+ };
+
+ StunProberTrial(rtc::NetworkManager* network_manager,
+ const std::string& params,
+ rtc::PacketSocketFactory* factory);
+ ~StunProberTrial() override;
+
+ // This will use |factory_| to create sockets, send stun binding requests with
+ // various intervals as determined by |params|, observed the success rate and
+ // latency of the stun responses and report through UMA.
+ 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.
+
+ // Parsing function to decode the '/' separated parameter string |params|.
+ 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.
+ Param* params);
+
+ // stunprober::StunProber::Observer:
+ 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.
+ stunprober::StunProber::Status status) override;
+ void OnFinished(stunprober::StunProber* prober,
+ stunprober::StunProber::Status status) override;
+
+ // This will be invoked repeatedly for |total_probers_| times with the
+ // interval equal to the estimated run time of a prober.
+ 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.
+
+ private:
+ void SaveHistogramData();
+
+ rtc::NetworkManager* network_manager_;
+ std::string param_line_;
+ rtc::PacketSocketFactory* factory_ = nullptr;
+ int total_probers_ = 0;
+ int batch_size_ = 0;
+ int ready_probers_ = 0;
+ int started_probers_ = 0;
+ int finished_probers_ = 0;
+ 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.
+ base::ThreadChecker thread_checker_;
+
+ base::RepeatingTimer timer_;
+
+ DISALLOW_COPY_AND_ASSIGN(StunProberTrial);
+};
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698