| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/metrics/field_trial.h" | 6 #include "base/metrics/field_trial.h" |
| 7 #include "chrome/browser/io_thread.h" | 7 #include "chrome/browser/io_thread.h" |
| 8 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | 8 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
| 9 #include "net/http/http_network_session.h" | 9 #include "net/http/http_network_session.h" |
| 10 #include "net/http/http_server_properties_impl.h" | 10 #include "net/http/http_server_properties_impl.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 return 0.5; | 25 return 0.5; |
| 26 } | 26 } |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 class IOThreadPeer { | 29 class IOThreadPeer { |
| 30 public: | 30 public: |
| 31 static void ConfigureQuicGlobals( | 31 static void ConfigureQuicGlobals( |
| 32 const base::CommandLine& command_line, | 32 const base::CommandLine& command_line, |
| 33 base::StringPiece quic_trial_group, | 33 base::StringPiece quic_trial_group, |
| 34 const std::map<std::string, std::string>& quic_trial_params, | 34 const std::map<std::string, std::string>& quic_trial_params, |
| 35 bool is_quic_allowed_by_policy, |
| 35 IOThread::Globals* globals) { | 36 IOThread::Globals* globals) { |
| 36 IOThread::ConfigureQuicGlobals(command_line, quic_trial_group, | 37 IOThread::ConfigureQuicGlobals(command_line, quic_trial_group, |
| 37 quic_trial_params, globals); | 38 quic_trial_params, is_quic_allowed_by_policy, |
| 39 globals); |
| 38 } | 40 } |
| 39 | 41 |
| 40 static void ConfigureSpdyGlobals( | 42 static void ConfigureSpdyGlobals( |
| 41 const base::CommandLine& command_line, | 43 const base::CommandLine& command_line, |
| 42 base::StringPiece spdy_trial_group, | 44 base::StringPiece spdy_trial_group, |
| 43 const std::map<std::string, std::string>& spdy_trial_params, | 45 const std::map<std::string, std::string>& spdy_trial_params, |
| 44 IOThread::Globals* globals) { | 46 IOThread::Globals* globals) { |
| 45 IOThread::ConfigureSpdyGlobals(command_line, spdy_trial_group, | 47 IOThread::ConfigureSpdyGlobals(command_line, spdy_trial_group, |
| 46 spdy_trial_params, globals); | 48 spdy_trial_params, globals); |
| 47 } | 49 } |
| 48 | 50 |
| 49 static void InitializeNetworkSessionParamsFromGlobals( | 51 static void InitializeNetworkSessionParamsFromGlobals( |
| 50 const IOThread::Globals& globals, | 52 const IOThread::Globals& globals, |
| 51 net::HttpNetworkSession::Params* params) { | 53 net::HttpNetworkSession::Params* params) { |
| 52 IOThread::InitializeNetworkSessionParamsFromGlobals(globals, params); | 54 IOThread::InitializeNetworkSessionParamsFromGlobals(globals, params); |
| 53 } | 55 } |
| 54 }; | 56 }; |
| 55 | 57 |
| 56 class IOThreadTest : public testing::Test { | 58 class IOThreadTest : public testing::Test { |
| 57 public: | 59 public: |
| 58 IOThreadTest() : command_line_(base::CommandLine::NO_PROGRAM) { | 60 IOThreadTest() |
| 61 : command_line_(base::CommandLine::NO_PROGRAM), |
| 62 is_quic_allowed_by_policy_(true) { |
| 59 globals_.http_server_properties.reset(new net::HttpServerPropertiesImpl()); | 63 globals_.http_server_properties.reset(new net::HttpServerPropertiesImpl()); |
| 60 } | 64 } |
| 61 | 65 |
| 62 void ConfigureQuicGlobals() { | 66 void ConfigureQuicGlobals() { |
| 63 IOThreadPeer::ConfigureQuicGlobals(command_line_, field_trial_group_, | 67 IOThreadPeer::ConfigureQuicGlobals(command_line_, |
| 64 field_trial_params_, &globals_); | 68 field_trial_group_, |
| 69 field_trial_params_, |
| 70 is_quic_allowed_by_policy_, |
| 71 &globals_); |
| 65 } | 72 } |
| 66 | 73 |
| 67 void ConfigureSpdyGlobals() { | 74 void ConfigureSpdyGlobals() { |
| 68 IOThreadPeer::ConfigureSpdyGlobals(command_line_, field_trial_group_, | 75 IOThreadPeer::ConfigureSpdyGlobals(command_line_, field_trial_group_, |
| 69 field_trial_params_, &globals_); | 76 field_trial_params_, &globals_); |
| 70 } | 77 } |
| 71 | 78 |
| 72 void InitializeNetworkSessionParams(net::HttpNetworkSession::Params* params) { | 79 void InitializeNetworkSessionParams(net::HttpNetworkSession::Params* params) { |
| 73 IOThreadPeer::InitializeNetworkSessionParamsFromGlobals(globals_, params); | 80 IOThreadPeer::InitializeNetworkSessionParamsFromGlobals(globals_, params); |
| 74 } | 81 } |
| 75 | 82 |
| 76 base::CommandLine command_line_; | 83 base::CommandLine command_line_; |
| 77 IOThread::Globals globals_; | 84 IOThread::Globals globals_; |
| 78 std::string field_trial_group_; | 85 std::string field_trial_group_; |
| 86 bool is_quic_allowed_by_policy_; |
| 79 std::map<std::string, std::string> field_trial_params_; | 87 std::map<std::string, std::string> field_trial_params_; |
| 80 }; | 88 }; |
| 81 | 89 |
| 82 TEST_F(IOThreadTest, InitializeNetworkSessionParamsFromGlobals) { | 90 TEST_F(IOThreadTest, InitializeNetworkSessionParamsFromGlobals) { |
| 83 globals_.quic_connection_options.push_back(net::kPACE); | 91 globals_.quic_connection_options.push_back(net::kPACE); |
| 84 globals_.quic_connection_options.push_back(net::kTBBR); | 92 globals_.quic_connection_options.push_back(net::kTBBR); |
| 85 globals_.quic_connection_options.push_back(net::kTIME); | 93 globals_.quic_connection_options.push_back(net::kTIME); |
| 86 | 94 |
| 87 net::HttpNetworkSession::Params params; | 95 net::HttpNetworkSession::Params params; |
| 88 InitializeNetworkSessionParams(¶ms); | 96 InitializeNetworkSessionParams(¶ms); |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 AlternateProtocolProbabilityThresholdFromParams) { | 463 AlternateProtocolProbabilityThresholdFromParams) { |
| 456 field_trial_group_ = "Enabled"; | 464 field_trial_group_ = "Enabled"; |
| 457 field_trial_params_["alternate_protocol_probability_threshold"] = ".5"; | 465 field_trial_params_["alternate_protocol_probability_threshold"] = ".5"; |
| 458 | 466 |
| 459 ConfigureQuicGlobals(); | 467 ConfigureQuicGlobals(); |
| 460 net::HttpNetworkSession::Params params; | 468 net::HttpNetworkSession::Params params; |
| 461 InitializeNetworkSessionParams(¶ms); | 469 InitializeNetworkSessionParams(¶ms); |
| 462 EXPECT_EQ(.5, params.alternate_protocol_probability_threshold); | 470 EXPECT_EQ(.5, params.alternate_protocol_probability_threshold); |
| 463 } | 471 } |
| 464 | 472 |
| 473 TEST_F(IOThreadTest, QuicDisallowedByPolicy) { |
| 474 command_line_.AppendSwitch("enable-quic"); |
| 475 is_quic_allowed_by_policy_ = false; |
| 476 ConfigureQuicGlobals(); |
| 477 |
| 478 net::HttpNetworkSession::Params params; |
| 479 InitializeNetworkSessionParams(¶ms); |
| 480 EXPECT_FALSE(params.enable_quic); |
| 481 } |
| 482 |
| 465 } // namespace test | 483 } // namespace test |
| OLD | NEW |