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

Side by Side Diff: chrome/browser/io_thread_unittest.cc

Issue 998383002: Created policy QuicAllowed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « chrome/browser/io_thread.cc ('k') | chrome/browser/policy/policy_network_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 InitializeNetworkSessionParamsFromGlobals( 42 static void InitializeNetworkSessionParamsFromGlobals(
41 const IOThread::Globals& globals, 43 const IOThread::Globals& globals,
42 net::HttpNetworkSession::Params* params) { 44 net::HttpNetworkSession::Params* params) {
43 IOThread::InitializeNetworkSessionParamsFromGlobals(globals, params); 45 IOThread::InitializeNetworkSessionParamsFromGlobals(globals, params);
44 } 46 }
45 47
46 static void ConfigureSpdyFromTrial(const std::string& trial_group, 48 static void ConfigureSpdyFromTrial(const std::string& trial_group,
47 IOThread::Globals* globals) { 49 IOThread::Globals* globals) {
48 IOThread::ConfigureSpdyFromTrial(trial_group, globals); 50 IOThread::ConfigureSpdyFromTrial(trial_group, globals);
49 } 51 }
50 }; 52 };
51 53
52 class IOThreadTest : public testing::Test { 54 class IOThreadTest : public testing::Test {
53 public: 55 public:
54 IOThreadTest() : command_line_(base::CommandLine::NO_PROGRAM) { 56 IOThreadTest() : command_line_(base::CommandLine::NO_PROGRAM),
57 is_quic_allowed_by_policy_(true) {
Ryan Hamilton 2015/03/20 18:21:58 Can you wrap the : command_line_(...) onto the nex
peletskyi 2015/03/23 10:03:18 Done.
55 globals_.http_server_properties.reset(new net::HttpServerPropertiesImpl()); 58 globals_.http_server_properties.reset(new net::HttpServerPropertiesImpl());
56 } 59 }
57 60
58 void ConfigureQuicGlobals() { 61 void ConfigureQuicGlobals() {
59 IOThreadPeer::ConfigureQuicGlobals(command_line_, field_trial_group_, 62 IOThreadPeer::ConfigureQuicGlobals(command_line_,
60 field_trial_params_, &globals_); 63 field_trial_group_,
64 field_trial_params_,
65 is_quic_allowed_by_policy_,
66 &globals_);
61 } 67 }
62 68
63 void InitializeNetworkSessionParams(net::HttpNetworkSession::Params* params) { 69 void InitializeNetworkSessionParams(net::HttpNetworkSession::Params* params) {
64 IOThreadPeer::InitializeNetworkSessionParamsFromGlobals(globals_, params); 70 IOThreadPeer::InitializeNetworkSessionParamsFromGlobals(globals_, params);
65 } 71 }
66 72
67 base::CommandLine command_line_; 73 base::CommandLine command_line_;
68 IOThread::Globals globals_; 74 IOThread::Globals globals_;
69 std::string field_trial_group_; 75 std::string field_trial_group_;
76 bool is_quic_allowed_by_policy_;
70 std::map<std::string, std::string> field_trial_params_; 77 std::map<std::string, std::string> field_trial_params_;
71 }; 78 };
72 79
73 TEST_F(IOThreadTest, InitializeNetworkSessionParamsFromGlobals) { 80 TEST_F(IOThreadTest, InitializeNetworkSessionParamsFromGlobals) {
74 globals_.quic_connection_options.push_back(net::kPACE); 81 globals_.quic_connection_options.push_back(net::kPACE);
75 globals_.quic_connection_options.push_back(net::kTBBR); 82 globals_.quic_connection_options.push_back(net::kTBBR);
76 globals_.quic_connection_options.push_back(net::kTIME); 83 globals_.quic_connection_options.push_back(net::kTIME);
77 84
78 net::HttpNetworkSession::Params params; 85 net::HttpNetworkSession::Params params;
79 InitializeNetworkSessionParams(&params); 86 InitializeNetworkSessionParams(&params);
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 AlternateProtocolProbabilityThresholdFromParams) { 368 AlternateProtocolProbabilityThresholdFromParams) {
362 field_trial_group_ = "Enabled"; 369 field_trial_group_ = "Enabled";
363 field_trial_params_["alternate_protocol_probability_threshold"] = ".5"; 370 field_trial_params_["alternate_protocol_probability_threshold"] = ".5";
364 371
365 ConfigureQuicGlobals(); 372 ConfigureQuicGlobals();
366 net::HttpNetworkSession::Params params; 373 net::HttpNetworkSession::Params params;
367 InitializeNetworkSessionParams(&params); 374 InitializeNetworkSessionParams(&params);
368 EXPECT_EQ(.5, params.alternate_protocol_probability_threshold); 375 EXPECT_EQ(.5, params.alternate_protocol_probability_threshold);
369 } 376 }
370 377
378 TEST_F(IOThreadTest, QuicDisallowedByPolicy) {
379 command_line_.AppendSwitch("enable-quic");
380 is_quic_allowed_by_policy_ = false;
381 ConfigureQuicGlobals();
382
383 net::HttpNetworkSession::Params params;
384 InitializeNetworkSessionParams(&params);
385 EXPECT_FALSE(params.enable_quic);
386 }
387
371 } // namespace test 388 } // namespace test
OLDNEW
« no previous file with comments | « chrome/browser/io_thread.cc ('k') | chrome/browser/policy/policy_network_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698