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

Side by Side Diff: blimp/engine/app/blimp_url_request_context_getter.cc

Issue 2629743003: Remove all blimp engine code (Closed)
Patch Set: Use consistent comment style in //chrome Created 3 years, 11 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
« no previous file with comments | « blimp/engine/app/blimp_url_request_context_getter.h ('k') | blimp/engine/app/engine_settings.h » ('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 2015 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 "blimp/engine/app/blimp_url_request_context_getter.h"
6
7 #include <utility>
8 #include <vector>
9
10 #include "base/logging.h"
11 #include "base/memory/ptr_util.h"
12 #include "base/single_thread_task_runner.h"
13 #include "blimp/engine/app/blimp_network_delegate.h"
14 #include "blimp/engine/common/blimp_user_agent.h"
15 #include "content/public/browser/browser_thread.h"
16 #include "net/proxy/proxy_config_service.h"
17 #include "net/proxy/proxy_service.h"
18 #include "net/url_request/url_request_context.h"
19 #include "net/url_request/url_request_context_builder.h"
20 #include "net/url_request/url_request_interceptor.h"
21
22 namespace blimp {
23 namespace engine {
24
25 BlimpURLRequestContextGetter::BlimpURLRequestContextGetter(
26 bool ignore_certificate_errors,
27 const base::FilePath& base_path,
28 const scoped_refptr<base::SingleThreadTaskRunner>& io_loop_task_runner,
29 const scoped_refptr<base::SingleThreadTaskRunner>& file_loop_task_runner,
30 content::ProtocolHandlerMap* protocol_handlers,
31 content::URLRequestInterceptorScopedVector request_interceptors,
32 net::NetLog* net_log)
33 : ignore_certificate_errors_(ignore_certificate_errors),
34 base_path_(base_path),
35 io_loop_task_runner_(io_loop_task_runner),
36 file_loop_task_runner_(file_loop_task_runner),
37 net_log_(net_log),
38 request_interceptors_(std::move(request_interceptors)) {
39 // Must first be created on the UI thread.
40 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
41
42 std::swap(protocol_handlers_, *protocol_handlers);
43
44 // We must create the proxy config service on the UI loop on Linux because it
45 // must synchronously run on the glib message loop. This will be passed to
46 // the URLRequestContextBuilder on the IO thread.
47 proxy_config_service_ = net::ProxyService::CreateSystemProxyConfigService(
48 io_loop_task_runner_, file_loop_task_runner_);
49 }
50
51 BlimpURLRequestContextGetter::~BlimpURLRequestContextGetter() {}
52
53 net::URLRequestContext* BlimpURLRequestContextGetter::GetURLRequestContext() {
54 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
55 if (!url_request_context_.get()) {
56 net::URLRequestContextBuilder builder;
57 builder.set_accept_language("en-us,en");
58 builder.set_user_agent(GetBlimpEngineUserAgent());
59 builder.set_proxy_config_service(std::move(proxy_config_service_));
60 builder.set_network_delegate(base::WrapUnique(new BlimpNetworkDelegate));
61 builder.set_net_log(net_log_);
62 builder.set_data_enabled(true);
63 for (auto& scheme_handler : protocol_handlers_) {
64 builder.SetProtocolHandler(
65 scheme_handler.first,
66 base::WrapUnique(scheme_handler.second.release()));
67 }
68 protocol_handlers_.clear();
69 builder.SetInterceptors(std::move(request_interceptors_));
70
71 net::URLRequestContextBuilder::HttpCacheParams cache_params;
72 cache_params.type =
73 net::URLRequestContextBuilder::HttpCacheParams::IN_MEMORY;
74 builder.EnableHttpCache(cache_params);
75
76 net::URLRequestContextBuilder::HttpNetworkSessionParams params;
77 params.ignore_certificate_errors = ignore_certificate_errors_;
78 builder.set_http_network_session_params(params);
79
80 url_request_context_ = builder.Build();
81 }
82 return url_request_context_.get();
83 }
84
85 scoped_refptr<base::SingleThreadTaskRunner>
86 BlimpURLRequestContextGetter::GetNetworkTaskRunner() const {
87 return content::BrowserThread::GetTaskRunnerForThread(
88 content::BrowserThread::IO);
89 }
90
91 net::HostResolver* BlimpURLRequestContextGetter::host_resolver() {
92 return url_request_context_->host_resolver();
93 }
94
95 } // namespace engine
96 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/engine/app/blimp_url_request_context_getter.h ('k') | blimp/engine/app/engine_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698