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

Unified Diff: mojo/loader/url_request_context_getter.cc

Issue 27536014: Teach mojo_shell how to load data 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') | mojo/mojo.gyp » ('j') | 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
new file mode 100644
index 0000000000000000000000000000000000000000..99c16e0c480a427d7168dfca89ece14b524f0f22
--- /dev/null
+++ b/mojo/loader/url_request_context_getter.cc
@@ -0,0 +1,57 @@
+// Copyright (c) 2013 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 "mojo/loader/url_request_context_getter.h"
+#include "net/cookies/cookie_monster.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/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() {
+}
+
+net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
+ if (!url_request_context_) {
+ url_request_context_.reset(new net::URLRequestContext());
+ url_request_context_->set_net_log(net_log_.get());
+
+ storage_.reset(
+ new net::URLRequestContextStorage(url_request_context_.get()));
+
+ storage_->set_cookie_store(new net::CookieMonster(NULL, NULL));
+ storage_->set_proxy_service(net::ProxyService::CreateDirect());
+ storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults);
+ storage_->set_host_resolver(net::HostResolver::CreateDefaultResolver(
+ url_request_context_->net_log()));
+
+ scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
+ new net::URLRequestJobFactoryImpl());
+
+ bool set_protocol = job_factory->SetProtocolHandler(
+ "data", new net::DataProtocolHandler());
+ CHECK(set_protocol);
+
+ storage_->set_job_factory(job_factory.release());
+ }
+
+ return url_request_context_.get();
+}
+
+scoped_refptr<base::SingleThreadTaskRunner>
+URLRequestContextGetter::GetNetworkTaskRunner() const {
+ // TODO(abarth): Move network requests to a background thread.
+ return base::MessageLoopProxy::current();
+}
+
+} // namespace loader
+} // namespace mojo
« 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