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

Side by Side Diff: net/nqe/network_quality_estimator_test_util.cc

Issue 2863973003: Expose RTT and downlink bandwidth using experimental Javascript API (Closed)
Patch Set: Rebased Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "net/nqe/network_quality_estimator_test_util.h" 5 #include "net/nqe/network_quality_estimator_test_util.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "net/base/load_flags.h" 10 #include "net/base/load_flags.h"
11 #include "net/log/net_log_with_source.h" 11 #include "net/log/net_log_with_source.h"
12 #include "net/log/test_net_log.h"
13 #include "net/log/test_net_log_entry.h" 12 #include "net/log/test_net_log_entry.h"
14 #include "net/test/embedded_test_server/http_response.h" 13 #include "net/test/embedded_test_server/http_response.h"
15 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" 14 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
16 #include "net/url_request/url_request.h" 15 #include "net/url_request/url_request.h"
17 #include "net/url_request/url_request_test_util.h" 16 #include "net/url_request/url_request_test_util.h"
18 17
19 namespace { 18 namespace {
20 19
21 const base::FilePath::CharType kTestFilePath[] = 20 const base::FilePath::CharType kTestFilePath[] =
22 FILE_PATH_LITERAL("net/data/url_request_unittest"); 21 FILE_PATH_LITERAL("net/data/url_request_unittest");
(...skipping 21 matching lines...) Expand all
44 false, 43 false,
45 base::MakeUnique<BoundTestNetLog>()) {} 44 base::MakeUnique<BoundTestNetLog>()) {}
46 45
47 TestNetworkQualityEstimator::TestNetworkQualityEstimator( 46 TestNetworkQualityEstimator::TestNetworkQualityEstimator(
48 std::unique_ptr<net::ExternalEstimateProvider> external_estimate_provider, 47 std::unique_ptr<net::ExternalEstimateProvider> external_estimate_provider,
49 const std::map<std::string, std::string>& variation_params, 48 const std::map<std::string, std::string>& variation_params,
50 bool allow_local_host_requests_for_tests, 49 bool allow_local_host_requests_for_tests,
51 bool allow_smaller_responses_for_tests, 50 bool allow_smaller_responses_for_tests,
52 bool add_default_platform_observations, 51 bool add_default_platform_observations,
53 std::unique_ptr<BoundTestNetLog> net_log) 52 std::unique_ptr<BoundTestNetLog> net_log)
53 : TestNetworkQualityEstimator(std::move(external_estimate_provider),
54 variation_params,
55 allow_local_host_requests_for_tests,
56 allow_smaller_responses_for_tests,
57 add_default_platform_observations,
58 false,
59 std::move(net_log)) {}
60
61 TestNetworkQualityEstimator::TestNetworkQualityEstimator(
62 std::unique_ptr<net::ExternalEstimateProvider> external_estimate_provider,
63 const std::map<std::string, std::string>& variation_params,
64 bool allow_local_host_requests_for_tests,
65 bool allow_smaller_responses_for_tests,
66 bool add_default_platform_observations,
67 bool suppress_notifications_for_testing,
68 std::unique_ptr<BoundTestNetLog> net_log)
54 : NetworkQualityEstimator(std::move(external_estimate_provider), 69 : NetworkQualityEstimator(std::move(external_estimate_provider),
55 variation_params, 70 variation_params,
56 allow_local_host_requests_for_tests, 71 allow_local_host_requests_for_tests,
57 allow_smaller_responses_for_tests, 72 allow_smaller_responses_for_tests,
58 add_default_platform_observations, 73 add_default_platform_observations,
59 net_log->bound()), 74 net_log->bound()),
60 current_network_type_(NetworkChangeNotifier::CONNECTION_UNKNOWN), 75 current_network_type_(NetworkChangeNotifier::CONNECTION_UNKNOWN),
61 accuracy_recording_intervals_set_(false), 76 accuracy_recording_intervals_set_(false),
62 rand_double_(0.0), 77 rand_double_(0.0),
63 embedded_test_server_(base::FilePath(kTestFilePath)), 78 embedded_test_server_(base::FilePath(kTestFilePath)),
79 suppress_notifications_for_testing_(suppress_notifications_for_testing),
64 net_log_(std::move(net_log)) { 80 net_log_(std::move(net_log)) {
65 // Set up the embedded test server. 81 // Set up the embedded test server.
66 EXPECT_TRUE(embedded_test_server_.Start()); 82 EXPECT_TRUE(embedded_test_server_.Start());
67 } 83 }
68 84
69 TestNetworkQualityEstimator::~TestNetworkQualityEstimator() {} 85 TestNetworkQualityEstimator::~TestNetworkQualityEstimator() {}
70 86
71 void TestNetworkQualityEstimator::RunOneRequest() { 87 void TestNetworkQualityEstimator::RunOneRequest() {
72 TestDelegate test_delegate; 88 TestDelegate test_delegate;
73 TestURLRequestContext context(true); 89 TestURLRequestContext context(true);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 nqe::internal::NetworkID TestNetworkQualityEstimator::GetCurrentNetworkID() 288 nqe::internal::NetworkID TestNetworkQualityEstimator::GetCurrentNetworkID()
273 const { 289 const {
274 return nqe::internal::NetworkID(current_network_type_, current_network_id_); 290 return nqe::internal::NetworkID(current_network_type_, current_network_id_);
275 } 291 }
276 292
277 TestNetworkQualityEstimator::LocalHttpTestServer::LocalHttpTestServer( 293 TestNetworkQualityEstimator::LocalHttpTestServer::LocalHttpTestServer(
278 const base::FilePath& document_root) { 294 const base::FilePath& document_root) {
279 AddDefaultHandlers(document_root); 295 AddDefaultHandlers(document_root);
280 } 296 }
281 297
298 void TestNetworkQualityEstimator::NotifyObserversOfRTTOrThroughputComputed()
299 const {
300 if (suppress_notifications_for_testing_)
301 return;
302
303 NetworkQualityEstimator::NotifyObserversOfRTTOrThroughputComputed();
304 }
305
306 void TestNetworkQualityEstimator::
307 NotifyRTTAndThroughputEstimatesObserverIfPresent(
308 RTTAndThroughputEstimatesObserver* observer) const {
309 if (suppress_notifications_for_testing_)
310 return;
311
312 NetworkQualityEstimator::NotifyRTTAndThroughputEstimatesObserverIfPresent(
313 observer);
314 }
315
282 } // namespace net 316 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698