OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h" | 5 #include "chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 net::HttpNetworkSession* http_network_session = | 89 net::HttpNetworkSession* http_network_session = |
90 context->http_transaction_factory()->GetSession(); | 90 context->http_transaction_factory()->GetSession(); |
91 net::HttpServerProperties* http_server_properties = | 91 net::HttpServerProperties* http_server_properties = |
92 http_network_session->http_server_properties(); | 92 http_network_session->http_server_properties(); |
93 net::HostPortPair origin(hostname, port); | 93 net::HostPortPair origin(hostname, port); |
94 http_server_properties->SetPipelineCapability(origin, capability); | 94 http_server_properties->SetPipelineCapability(origin, capability); |
95 } | 95 } |
96 | 96 |
97 // Called on IO thread. Adds an entry to the list of known HTTP pipelining | 97 // Called on IO thread. Adds an entry to the list of known HTTP pipelining |
98 // hosts. | 98 // hosts. |
99 void EnableHttpPipeliningOnIOThread(bool enable) { | 99 void EnableHttpPipeliningOnIOThread( |
| 100 net::URLRequestContextGetter* context_getter, bool enable) { |
100 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 101 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
101 net::HttpStreamFactory::set_http_pipelining_enabled(enable); | 102 net::URLRequestContext* context = context_getter->GetURLRequestContext(); |
| 103 net::HttpNetworkSession* http_network_session = |
| 104 context->http_transaction_factory()->GetSession(); |
| 105 http_network_session->set_http_pipelining_enabled(enable); |
102 } | 106 } |
103 | 107 |
104 } // namespace | 108 } // namespace |
105 | 109 |
106 //////////////////////////////////////////////////////////////////////////////// | 110 //////////////////////////////////////////////////////////////////////////////// |
107 // NetInternalsTest::MessageHandler | 111 // NetInternalsTest::MessageHandler |
108 //////////////////////////////////////////////////////////////////////////////// | 112 //////////////////////////////////////////////////////////////////////////////// |
109 | 113 |
110 // Class to handle messages from the renderer needed by certain tests. | 114 // Class to handle messages from the renderer needed by certain tests. |
111 class NetInternalsTest::MessageHandler : public content::WebUIMessageHandler { | 115 class NetInternalsTest::MessageHandler : public content::WebUIMessageHandler { |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 // thought it may not have been destroyed yet. | 272 // thought it may not have been destroyed yet. |
269 incognito_browser_ = NULL; | 273 incognito_browser_ = NULL; |
270 } | 274 } |
271 | 275 |
272 void NetInternalsTest::MessageHandler::EnableHttpPipelining( | 276 void NetInternalsTest::MessageHandler::EnableHttpPipelining( |
273 const ListValue* list_value) { | 277 const ListValue* list_value) { |
274 bool enable; | 278 bool enable; |
275 ASSERT_TRUE(list_value->GetBoolean(0, &enable)); | 279 ASSERT_TRUE(list_value->GetBoolean(0, &enable)); |
276 BrowserThread::PostTask( | 280 BrowserThread::PostTask( |
277 BrowserThread::IO, FROM_HERE, | 281 BrowserThread::IO, FROM_HERE, |
278 base::Bind(&EnableHttpPipeliningOnIOThread, enable)); | 282 base::Bind(&EnableHttpPipeliningOnIOThread, |
| 283 make_scoped_refptr(browser()->profile()->GetRequestContext()), |
| 284 enable)); |
279 } | 285 } |
280 | 286 |
281 void NetInternalsTest::MessageHandler::AddDummyHttpPipelineFeedback( | 287 void NetInternalsTest::MessageHandler::AddDummyHttpPipelineFeedback( |
282 const ListValue* list_value) { | 288 const ListValue* list_value) { |
283 std::string hostname; | 289 std::string hostname; |
284 double port; | 290 double port; |
285 std::string raw_capability; | 291 std::string raw_capability; |
286 net::HttpPipelinedHostCapability capability; | 292 net::HttpPipelinedHostCapability capability; |
287 ASSERT_TRUE(list_value->GetString(0, &hostname)); | 293 ASSERT_TRUE(list_value->GetString(0, &hostname)); |
288 ASSERT_TRUE(list_value->GetDouble(1, &port)); | 294 ASSERT_TRUE(list_value->GetDouble(1, &port)); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 GURL url_loader = test_server()->GetURL(replacement_path); | 357 GURL url_loader = test_server()->GetURL(replacement_path); |
352 return url_loader; | 358 return url_loader; |
353 } | 359 } |
354 | 360 |
355 bool NetInternalsTest::StartTestServer() { | 361 bool NetInternalsTest::StartTestServer() { |
356 if (test_server_started_) | 362 if (test_server_started_) |
357 return true; | 363 return true; |
358 test_server_started_ = test_server()->Start(); | 364 test_server_started_ = test_server()->Start(); |
359 return test_server_started_; | 365 return test_server_started_; |
360 } | 366 } |
OLD | NEW |