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
3 // found in the LICENSE file.
5 #include "remoting/base/url_request_context_getter.h"
7 #include "base/single_thread_task_runner.h"
8 #include "net/proxy/proxy_config_service.h"
9 #include "net/url_request/url_request_context.h"
10 #include "net/url_request/url_request_context_builder.h"
11 #include "remoting/base/vlog_net_log.h"
15 URLRequestContextGetter::URLRequestContextGetter(
16 scoped_refptr
<base::SingleThreadTaskRunner
> network_task_runner
,
17 scoped_refptr
<base::SingleThreadTaskRunner
> file_task_runner
)
18 : network_task_runner_(network_task_runner
) {
19 proxy_config_service_
.reset(net::ProxyService::CreateSystemProxyConfigService(
20 network_task_runner_
, file_task_runner
));
23 net::URLRequestContext
* URLRequestContextGetter::GetURLRequestContext() {
24 if (!url_request_context_
.get()) {
25 net::URLRequestContextBuilder builder
;
26 builder
.set_net_log(new VlogNetLog());
27 builder
.DisableHttpCache();
28 builder
.set_proxy_config_service(proxy_config_service_
.release());
29 url_request_context_
.reset(builder
.Build());
31 return url_request_context_
.get();
34 scoped_refptr
<base::SingleThreadTaskRunner
>
35 URLRequestContextGetter::GetNetworkTaskRunner() const {
36 return network_task_runner_
;
39 URLRequestContextGetter::~URLRequestContextGetter() {
42 } // namespace remoting