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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/loader/url_request_context_getter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/loader/url_request_context_getter.cc
diff --git a/mojo/loader/url_request_context_getter.cc b/mojo/loader/url_request_context_getter.cc
index 99c16e0c480a427d7168dfca89ece14b524f0f22..11e4af16bee11c77b6875b46271b3f764c3cd241 100644
--- a/mojo/loader/url_request_context_getter.cc
+++ b/mojo/loader/url_request_context_getter.cc
@@ -4,17 +4,25 @@
#include "mojo/loader/url_request_context_getter.h"
#include "net/cookies/cookie_monster.h"
+#include "net/http/http_cache.h"
+#include "net/http/http_network_session.h"
+#include "net/http/http_server_properties_impl.h"
#include "net/proxy/proxy_service.h"
#include "net/ssl/ssl_config_service_defaults.h"
#include "net/url_request/data_protocol_handler.h"
+#include "net/url_request/static_http_user_agent_settings.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_job_factory_impl.h"
namespace mojo {
namespace loader {
-URLRequestContextGetter::URLRequestContextGetter()
- : net_log_(new net::NetLog()) {
+URLRequestContextGetter::URLRequestContextGetter(
+ base::SingleThreadTaskRunner* network_task_runner,
+ base::MessageLoopProxy* cache_task_runner)
+ : network_task_runner_(network_task_runner),
+ cache_task_runner_(cache_task_runner),
+ net_log_(new net::NetLog()) {
}
URLRequestContextGetter::~URLRequestContextGetter() {
@@ -29,11 +37,44 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
new net::URLRequestContextStorage(url_request_context_.get()));
storage_->set_cookie_store(new net::CookieMonster(NULL, NULL));
+ storage_->set_http_user_agent_settings(
+ new net::StaticHttpUserAgentSettings("en-us,en", "Mojo/0.1"));
+
storage_->set_proxy_service(net::ProxyService::CreateDirect());
storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults);
+ storage_->set_http_server_properties(
+ scoped_ptr<net::HttpServerProperties>(
+ new net::HttpServerPropertiesImpl()));
storage_->set_host_resolver(net::HostResolver::CreateDefaultResolver(
url_request_context_->net_log()));
+ net::HttpNetworkSession::Params network_session_params;
+ network_session_params.net_log =
+ url_request_context_->net_log();
+ network_session_params.proxy_service =
+ url_request_context_->proxy_service();
+ network_session_params.ssl_config_service =
+ url_request_context_->ssl_config_service();
+ network_session_params.http_server_properties =
+ url_request_context_->http_server_properties();
+ network_session_params.host_resolver =
+ url_request_context_->host_resolver();
+
+ base::FilePath cache_path =
+ base::FilePath().Append(FILE_PATH_LITERAL("tmp/mojo/Cache"));
abarth-chromium 2013/10/18 01:20:45 Where do we want to store the HTTP cache?
+
+ net::HttpCache::DefaultBackend* main_backend =
+ new net::HttpCache::DefaultBackend(
+ net::DISK_CACHE,
+ net::CACHE_BACKEND_DEFAULT,
+ cache_path,
+ 0,
+ cache_task_runner_.get());
+
+ net::HttpCache* main_cache = new net::HttpCache(
+ network_session_params, main_backend);
+ storage_->set_http_transaction_factory(main_cache);
+
scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
new net::URLRequestJobFactoryImpl());
@@ -49,8 +90,7 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
scoped_refptr<base::SingleThreadTaskRunner>
URLRequestContextGetter::GetNetworkTaskRunner() const {
- // TODO(abarth): Move network requests to a background thread.
- return base::MessageLoopProxy::current();
+ return network_task_runner_;
}
} // namespace loader
« no previous file with comments | « mojo/loader/url_request_context_getter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698