1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/shell/shell_url_request_context_getter.h"
#include "base/logging.h"
#include "base/string_split.h"
#include "content/browser/browser_thread.h"
#include "net/base/cert_verifier.h"
#include "net/base/cookie_monster.h"
#include "net/base/default_origin_bound_cert_store.h"
#include "net/base/dnsrr_resolver.h"
#include "net/base/host_resolver.h"
#include "net/http/http_auth_handler_factory.h"
#include "net/http/http_cache.h"
#include "net/base/origin_bound_cert_service.h"
#include "net/base/ssl_config_service_defaults.h"
#include "net/proxy/proxy_service.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_job_factory.h"
namespace content {
ShellURLRequestContextGetter::ShellURLRequestContextGetter(
const FilePath& base_path_,
MessageLoop* io_loop,
MessageLoop* file_loop)
: io_loop_(io_loop),
file_loop_(file_loop) {
}
ShellURLRequestContextGetter::~ShellURLRequestContextGetter() {
}
net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (!url_request_context_) {
FilePath cache_path = base_path_.Append(FILE_PATH_LITERAL("Cache"));
net::HttpCache::DefaultBackend* main_backend =
new net::HttpCache::DefaultBackend(
net::DISK_CACHE,
cache_path,
0,
BrowserThread::GetMessageLoopProxyForThread(
BrowserThread::CACHE));
net::NetLog* net_log = NULL;
host_resolver_.reset(net::CreateSystemHostResolver(
net::HostResolver::kDefaultParallelism,
net::HostResolver::kDefaultRetryAttempts,
net_log));
cert_verifier_.reset(new net::CertVerifier());
origin_bound_cert_service_.reset(new net::OriginBoundCertService(
new net::DefaultOriginBoundCertStore(NULL)));
dnsrr_resolver_.reset(new net::DnsRRResolver());
net::ProxyConfigService* proxy_config_service =
net::ProxyService::CreateSystemProxyConfigService(
io_loop_,
file_loop_);
// TODO(jam): use v8 if possible, look at chrome code.
proxy_service_.reset(
net::ProxyService::CreateUsingSystemProxyResolver(
proxy_config_service,
0,
net_log));
url_security_manager_.reset(net::URLSecurityManager::Create(NULL, NULL));
std::vector<std::string> supported_schemes;
base::SplitString("basic,digest,ntlm,negotiate", ',', &supported_schemes);
http_auth_handler_factory_.reset(
net::HttpAuthHandlerRegistryFactory::Create(
supported_schemes,
url_security_manager_.get(),
host_resolver_.get(),
std::string(), // gssapi_library_name
false, // negotiate_disable_cname_lookup
false)); // negotiate_enable_port
net::HttpCache* main_cache = new net::HttpCache(
host_resolver_.get(),
cert_verifier_.get(),
origin_bound_cert_service_.get(),
dnsrr_resolver_.get(),
NULL, //dns_cert_checker
proxy_service_.get(),
new net::SSLConfigServiceDefaults(),
http_auth_handler_factory_.get(),
NULL, // network_delegate
net_log,
main_backend);
main_http_factory_.reset(main_cache);
scoped_refptr<net::CookieStore> cookie_store =
new net::CookieMonster(NULL, NULL);
url_request_context_ = new net::URLRequestContext();
job_factory_.reset(new net::URLRequestJobFactory);
url_request_context_->set_job_factory(job_factory_.get());
url_request_context_->set_http_transaction_factory(main_cache);
url_request_context_->set_origin_bound_cert_service(
origin_bound_cert_service_.get());
url_request_context_->set_dnsrr_resolver(dnsrr_resolver_.get());
url_request_context_->set_proxy_service(proxy_service_.get());
url_request_context_->set_cookie_store(cookie_store);
}
return url_request_context_;
}
net::CookieStore* ShellURLRequestContextGetter::DONTUSEME_GetCookieStore() {
if (BrowserThread::CurrentlyOn(BrowserThread::IO))
return GetURLRequestContext()->cookie_store();
NOTIMPLEMENTED();
return NULL;
}
scoped_refptr<base::MessageLoopProxy>
ShellURLRequestContextGetter::GetIOMessageLoopProxy() const {
return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
}
} // namespace content
|