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

Side by Side Diff: mojo/loader/url_request_context_getter.cc

Issue 27943002: Teach mojo_shell how to load http URLs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix some style nits Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 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.
4
5 #include "mojo/loader/url_request_context_getter.h"
darin (slow to review) 2013/10/18 07:11:29 nit: new line below here.
abarth-chromium 2013/10/18 07:27:17 Does Chromium style put the primary header at the
6 #include "net/cookies/cookie_monster.h"
7 #include "net/http/http_cache.h"
8 #include "net/http/http_network_session.h"
9 #include "net/http/http_server_properties_impl.h"
10 #include "net/proxy/proxy_service.h"
11 #include "net/ssl/ssl_config_service_defaults.h"
12 #include "net/url_request/static_http_user_agent_settings.h"
13 #include "net/url_request/url_request_context.h"
14 #include "net/url_request/url_request_job_factory_impl.h"
15
16 namespace mojo {
17 namespace loader {
18
19 URLRequestContextGetter::URLRequestContextGetter(
20 base::FilePath base_path,
21 base::SingleThreadTaskRunner* network_task_runner,
22 base::MessageLoopProxy* cache_task_runner)
23 : base_path_(base_path),
24 network_task_runner_(network_task_runner),
25 cache_task_runner_(cache_task_runner),
26 net_log_(new net::NetLog()) {
27 }
28
29 URLRequestContextGetter::~URLRequestContextGetter() {
30 }
31
32 net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
33 if (!url_request_context_) {
34 url_request_context_.reset(new net::URLRequestContext());
35 url_request_context_->set_net_log(net_log_.get());
36
37 storage_.reset(
38 new net::URLRequestContextStorage(url_request_context_.get()));
39
40 storage_->set_cookie_store(new net::CookieMonster(NULL, NULL));
41 storage_->set_http_user_agent_settings(
42 new net::StaticHttpUserAgentSettings("en-us,en", "Mojo/0.1"));
darin (slow to review) 2013/10/18 07:11:29 oh, look at you!
abarth-chromium 2013/10/18 07:27:17 A man can dream!
43
44 storage_->set_proxy_service(net::ProxyService::CreateDirect());
45 storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults);
46 storage_->set_http_server_properties(
47 scoped_ptr<net::HttpServerProperties>(
48 new net::HttpServerPropertiesImpl()));
49 storage_->set_host_resolver(net::HostResolver::CreateDefaultResolver(
50 url_request_context_->net_log()));
51
52 net::HttpNetworkSession::Params network_session_params;
53 network_session_params.net_log =
54 url_request_context_->net_log();
55 network_session_params.proxy_service =
56 url_request_context_->proxy_service();
57 network_session_params.ssl_config_service =
58 url_request_context_->ssl_config_service();
59 network_session_params.http_server_properties =
60 url_request_context_->http_server_properties();
61 network_session_params.host_resolver =
62 url_request_context_->host_resolver();
63
64 base::FilePath cache_path = base_path_.Append(FILE_PATH_LITERAL("Cache"));
65
66 net::HttpCache::DefaultBackend* main_backend =
67 new net::HttpCache::DefaultBackend(
68 net::DISK_CACHE,
69 net::CACHE_BACKEND_DEFAULT,
70 cache_path,
71 0,
72 cache_task_runner_.get());
73
74 net::HttpCache* main_cache = new net::HttpCache(
75 network_session_params, main_backend);
76 storage_->set_http_transaction_factory(main_cache);
77
78 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
79 new net::URLRequestJobFactoryImpl());
80
81 storage_->set_job_factory(job_factory.release());
82 }
83
84 return url_request_context_.get();
85 }
86
87 scoped_refptr<base::SingleThreadTaskRunner>
88 URLRequestContextGetter::GetNetworkTaskRunner() const {
89 return network_task_runner_;
90 }
91
92 } // namespace loader
93 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698