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/test/chromedriver/net/url_request_context_getter.h" | 5 #include "chrome/test/chromedriver/net/url_request_context_getter.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "net/proxy/proxy_config_service_fixed.h" | 9 #include "net/proxy/proxy_config_service_fixed.h" |
10 #include "net/url_request/url_request_context.h" | 10 #include "net/url_request/url_request_context.h" |
11 #include "net/url_request/url_request_context_builder.h" | 11 #include "net/url_request/url_request_context_builder.h" |
12 | 12 |
13 URLRequestContextGetter::URLRequestContextGetter( | 13 URLRequestContextGetter::URLRequestContextGetter( |
14 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) | 14 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) |
15 : network_task_runner_(network_task_runner) { | 15 : network_task_runner_(network_task_runner) { |
16 } | 16 } |
17 | 17 |
18 net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { | 18 net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { |
19 CHECK(network_task_runner_->BelongsToCurrentThread()); | 19 CHECK(network_task_runner_->BelongsToCurrentThread()); |
20 if (!url_request_context_) { | 20 if (!url_request_context_) { |
21 net::URLRequestContextBuilder builder; | 21 net::URLRequestContextBuilder builder; |
22 // net::HttpServer fails to parse headers if user-agent header is blank. | 22 // net::HttpServer fails to parse headers if user-agent header is blank. |
23 builder.set_user_agent("chromedriver"); | 23 builder.set_user_agent("chromedriver"); |
24 builder.DisableHttpCache(); | 24 builder.DisableHttpCache(); |
25 builder.set_proxy_config_service( | 25 builder.set_proxy_config_service(make_scoped_ptr( |
26 new net::ProxyConfigServiceFixed(net::ProxyConfig::CreateDirect())); | 26 new net::ProxyConfigServiceFixed(net::ProxyConfig::CreateDirect()))); |
27 url_request_context_.reset(builder.Build()); | 27 url_request_context_ = builder.Build().Pass(); |
28 } | 28 } |
29 return url_request_context_.get(); | 29 return url_request_context_.get(); |
30 } | 30 } |
31 | 31 |
32 scoped_refptr<base::SingleThreadTaskRunner> | 32 scoped_refptr<base::SingleThreadTaskRunner> |
33 URLRequestContextGetter::GetNetworkTaskRunner() const { | 33 URLRequestContextGetter::GetNetworkTaskRunner() const { |
34 return network_task_runner_; | 34 return network_task_runner_; |
35 } | 35 } |
36 | 36 |
37 URLRequestContextGetter::~URLRequestContextGetter() {} | 37 URLRequestContextGetter::~URLRequestContextGetter() {} |
OLD | NEW |