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

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: Add missing include 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
« no previous file with comments | « mojo/loader/url_request_context_getter.h ('k') | mojo/mojo.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
6
7 #include "net/cookies/cookie_monster.h"
8 #include "net/http/http_cache.h"
9 #include "net/http/http_network_session.h"
10 #include "net/http/http_server_properties_impl.h"
11 #include "net/proxy/proxy_service.h"
12 #include "net/ssl/ssl_config_service_defaults.h"
13 #include "net/url_request/static_http_user_agent_settings.h"
14 #include "net/url_request/url_request_context.h"
15 #include "net/url_request/url_request_job_factory_impl.h"
16
17 namespace mojo {
18 namespace loader {
19
20 URLRequestContextGetter::URLRequestContextGetter(
21 base::FilePath base_path,
22 base::SingleThreadTaskRunner* network_task_runner,
23 base::MessageLoopProxy* cache_task_runner)
24 : base_path_(base_path),
25 network_task_runner_(network_task_runner),
26 cache_task_runner_(cache_task_runner),
27 net_log_(new net::NetLog()) {
28 }
29
30 URLRequestContextGetter::~URLRequestContextGetter() {
31 }
32
33 net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
34 if (!url_request_context_) {
35 url_request_context_.reset(new net::URLRequestContext());
36 url_request_context_->set_net_log(net_log_.get());
37
38 storage_.reset(
39 new net::URLRequestContextStorage(url_request_context_.get()));
40
41 storage_->set_cookie_store(new net::CookieMonster(NULL, NULL));
42 storage_->set_http_user_agent_settings(
43 new net::StaticHttpUserAgentSettings("en-us,en", "Mojo/0.1"));
44
45 storage_->set_proxy_service(net::ProxyService::CreateDirect());
46 storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults);
47 storage_->set_http_server_properties(
48 scoped_ptr<net::HttpServerProperties>(
49 new net::HttpServerPropertiesImpl()));
50 storage_->set_host_resolver(net::HostResolver::CreateDefaultResolver(
51 url_request_context_->net_log()));
52
53 net::HttpNetworkSession::Params network_session_params;
54 network_session_params.net_log =
55 url_request_context_->net_log();
56 network_session_params.proxy_service =
57 url_request_context_->proxy_service();
58 network_session_params.ssl_config_service =
59 url_request_context_->ssl_config_service();
60 network_session_params.http_server_properties =
61 url_request_context_->http_server_properties();
62 network_session_params.host_resolver =
63 url_request_context_->host_resolver();
64
65 base::FilePath cache_path = base_path_.Append(FILE_PATH_LITERAL("Cache"));
66
67 net::HttpCache::DefaultBackend* main_backend =
68 new net::HttpCache::DefaultBackend(
69 net::DISK_CACHE,
70 net::CACHE_BACKEND_DEFAULT,
71 cache_path,
72 0,
73 cache_task_runner_.get());
74
75 net::HttpCache* main_cache = new net::HttpCache(
76 network_session_params, main_backend);
77 storage_->set_http_transaction_factory(main_cache);
78
79 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
80 new net::URLRequestJobFactoryImpl());
81
82 storage_->set_job_factory(job_factory.release());
83 }
84
85 return url_request_context_.get();
86 }
87
88 scoped_refptr<base::SingleThreadTaskRunner>
89 URLRequestContextGetter::GetNetworkTaskRunner() const {
90 return network_task_runner_;
91 }
92
93 } // namespace loader
94 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/loader/url_request_context_getter.h ('k') | mojo/mojo.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698