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

Side by Side Diff: android_webview/browser/net/aw_url_request_context_getter.cc

Issue 1552723002: Convert Pass()→std::move() in //android_webview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "android_webview/browser/net/aw_url_request_context_getter.h" 5 #include "android_webview/browser/net/aw_url_request_context_getter.h"
6 6
7 #include <utility>
7 #include <vector> 8 #include <vector>
8 9
9 #include "android_webview/browser/aw_browser_context.h" 10 #include "android_webview/browser/aw_browser_context.h"
10 #include "android_webview/browser/aw_content_browser_client.h" 11 #include "android_webview/browser/aw_content_browser_client.h"
11 #include "android_webview/browser/net/aw_http_user_agent_settings.h" 12 #include "android_webview/browser/net/aw_http_user_agent_settings.h"
12 #include "android_webview/browser/net/aw_network_delegate.h" 13 #include "android_webview/browser/net/aw_network_delegate.h"
13 #include "android_webview/browser/net/aw_request_interceptor.h" 14 #include "android_webview/browser/net/aw_request_interceptor.h"
14 #include "android_webview/browser/net/aw_url_request_job_factory.h" 15 #include "android_webview/browser/net/aw_url_request_job_factory.h"
15 #include "android_webview/browser/net/init_native_callback.h" 16 #include "android_webview/browser/net/init_native_callback.h"
16 #include "android_webview/common/aw_content_client.h" 17 #include "android_webview/common/aw_content_client.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // factories. This for WebViewClassic compatibility where it was not 137 // factories. This for WebViewClassic compatibility where it was not
137 // possible to intercept resource loads to resolvable content:// and 138 // possible to intercept resource loads to resolvable content:// and
138 // file:// URIs. 139 // file:// URIs.
139 // This logical dependency is also the reason why the Content 140 // This logical dependency is also the reason why the Content
140 // URLRequestInterceptor has to be added as an interceptor rather than as a 141 // URLRequestInterceptor has to be added as an interceptor rather than as a
141 // ProtocolHandler. 142 // ProtocolHandler.
142 request_interceptors.push_back(new AwRequestInterceptor()); 143 request_interceptors.push_back(new AwRequestInterceptor());
143 144
144 // The chain of responsibility will execute the handlers in reverse to the 145 // The chain of responsibility will execute the handlers in reverse to the
145 // order in which the elements of the chain are created. 146 // order in which the elements of the chain are created.
146 scoped_ptr<net::URLRequestJobFactory> job_factory(aw_job_factory.Pass()); 147 scoped_ptr<net::URLRequestJobFactory> job_factory(std::move(aw_job_factory));
147 for (content::URLRequestInterceptorScopedVector::reverse_iterator i = 148 for (content::URLRequestInterceptorScopedVector::reverse_iterator i =
148 request_interceptors.rbegin(); 149 request_interceptors.rbegin();
149 i != request_interceptors.rend(); 150 i != request_interceptors.rend();
150 ++i) { 151 ++i) {
151 job_factory.reset(new net::URLRequestInterceptingJobFactory( 152 job_factory.reset(new net::URLRequestInterceptingJobFactory(
152 job_factory.Pass(), make_scoped_ptr(*i))); 153 std::move(job_factory), make_scoped_ptr(*i)));
153 } 154 }
154 request_interceptors.weak_clear(); 155 request_interceptors.weak_clear();
155 156
156 return job_factory.Pass(); 157 return job_factory;
157 } 158 }
158 159
159 } // namespace 160 } // namespace
160 161
161 AwURLRequestContextGetter::AwURLRequestContextGetter( 162 AwURLRequestContextGetter::AwURLRequestContextGetter(
162 const base::FilePath& cache_path, 163 const base::FilePath& cache_path,
163 net::CookieStore* cookie_store, 164 net::CookieStore* cookie_store,
164 scoped_ptr<net::ProxyConfigService> config_service, 165 scoped_ptr<net::ProxyConfigService> config_service,
165 PrefService* user_pref_service) 166 PrefService* user_pref_service)
166 : cache_path_(cache_path), 167 : cache_path_(cache_path),
167 net_log_(new net::NetLog()), 168 net_log_(new net::NetLog()),
168 proxy_config_service_(config_service.Pass()), 169 proxy_config_service_(std::move(config_service)),
169 cookie_store_(cookie_store), 170 cookie_store_(cookie_store),
170 http_user_agent_settings_(new AwHttpUserAgentSettings()) { 171 http_user_agent_settings_(new AwHttpUserAgentSettings()) {
171 // CreateSystemProxyConfigService for Android must be called on main thread. 172 // CreateSystemProxyConfigService for Android must be called on main thread.
172 DCHECK_CURRENTLY_ON(BrowserThread::UI); 173 DCHECK_CURRENTLY_ON(BrowserThread::UI);
173 174
174 scoped_refptr<base::SingleThreadTaskRunner> io_thread_proxy = 175 scoped_refptr<base::SingleThreadTaskRunner> io_thread_proxy =
175 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); 176 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
176 177
177 auth_server_whitelist_.Init( 178 auth_server_whitelist_.Init(
178 prefs::kAuthServerWhitelist, user_pref_service, 179 prefs::kAuthServerWhitelist, user_pref_service,
(...skipping 16 matching lines...) Expand all
195 DCHECK_CURRENTLY_ON(BrowserThread::IO); 196 DCHECK_CURRENTLY_ON(BrowserThread::IO);
196 DCHECK(!url_request_context_); 197 DCHECK(!url_request_context_);
197 198
198 net::URLRequestContextBuilder builder; 199 net::URLRequestContextBuilder builder;
199 scoped_ptr<AwNetworkDelegate> aw_network_delegate(new AwNetworkDelegate()); 200 scoped_ptr<AwNetworkDelegate> aw_network_delegate(new AwNetworkDelegate());
200 201
201 AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); 202 AwBrowserContext* browser_context = AwBrowserContext::GetDefault();
202 DCHECK(browser_context); 203 DCHECK(browser_context);
203 204
204 builder.set_network_delegate( 205 builder.set_network_delegate(
205 browser_context->GetDataReductionProxyIOData() 206 browser_context->GetDataReductionProxyIOData()->CreateNetworkDelegate(
206 ->CreateNetworkDelegate( 207 std::move(aw_network_delegate),
207 aw_network_delegate.Pass(), 208 false /* No UMA is produced to track bypasses. */));
208 false /* No UMA is produced to track bypasses. */)
209 .Pass());
210 #if !defined(DISABLE_FTP_SUPPORT) 209 #if !defined(DISABLE_FTP_SUPPORT)
211 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. 210 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet.
212 #endif 211 #endif
213 DCHECK(proxy_config_service_.get()); 212 DCHECK(proxy_config_service_.get());
214 // Android provides a local HTTP proxy that handles all the proxying. 213 // Android provides a local HTTP proxy that handles all the proxying.
215 // Create the proxy without a resolver since we rely on this local HTTP proxy. 214 // Create the proxy without a resolver since we rely on this local HTTP proxy.
216 // TODO(sgurun) is this behavior guaranteed through SDK? 215 // TODO(sgurun) is this behavior guaranteed through SDK?
217 builder.set_proxy_service(net::ProxyService::CreateWithoutProxyResolver( 216 builder.set_proxy_service(net::ProxyService::CreateWithoutProxyResolver(
218 proxy_config_service_.Pass(), net_log_.get())); 217 std::move(proxy_config_service_), net_log_.get()));
219 builder.set_net_log(net_log_.get()); 218 builder.set_net_log(net_log_.get());
220 builder.SetCookieAndChannelIdStores(cookie_store_, NULL); 219 builder.SetCookieAndChannelIdStores(cookie_store_, NULL);
221 220
222 net::URLRequestContextBuilder::HttpCacheParams cache_params; 221 net::URLRequestContextBuilder::HttpCacheParams cache_params;
223 cache_params.type = 222 cache_params.type =
224 net::URLRequestContextBuilder::HttpCacheParams::DISK_SIMPLE; 223 net::URLRequestContextBuilder::HttpCacheParams::DISK_SIMPLE;
225 cache_params.max_size = 20 * 1024 * 1024; // 20M 224 cache_params.max_size = 20 * 1024 * 1024; // 20M
226 cache_params.path = cache_path_; 225 cache_params.path = cache_path_;
227 builder.EnableHttpCache(cache_params); 226 builder.EnableHttpCache(cache_params);
228 builder.SetFileTaskRunner( 227 builder.SetFileTaskRunner(
229 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); 228 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE));
230 229
231 net::URLRequestContextBuilder::HttpNetworkSessionParams 230 net::URLRequestContextBuilder::HttpNetworkSessionParams
232 network_session_params; 231 network_session_params;
233 ApplyCmdlineOverridesToNetworkSessionParams(&network_session_params); 232 ApplyCmdlineOverridesToNetworkSessionParams(&network_session_params);
234 builder.set_http_network_session_params(network_session_params); 233 builder.set_http_network_session_params(network_session_params);
235 builder.SetSpdyAndQuicEnabled(true, false); 234 builder.SetSpdyAndQuicEnabled(true, false);
236 235
237 scoped_ptr<net::MappedHostResolver> host_resolver(new net::MappedHostResolver( 236 scoped_ptr<net::MappedHostResolver> host_resolver(new net::MappedHostResolver(
238 net::HostResolver::CreateDefaultResolver(nullptr))); 237 net::HostResolver::CreateDefaultResolver(nullptr)));
239 ApplyCmdlineOverridesToHostResolver(host_resolver.get()); 238 ApplyCmdlineOverridesToHostResolver(host_resolver.get());
240 builder.SetHttpAuthHandlerFactory( 239 builder.SetHttpAuthHandlerFactory(
241 CreateAuthHandlerFactory(host_resolver.get()).Pass()); 240 CreateAuthHandlerFactory(host_resolver.get()));
242 builder.set_host_resolver(host_resolver.Pass()); 241 builder.set_host_resolver(std::move(host_resolver));
243 242
244 url_request_context_ = builder.Build().Pass(); 243 url_request_context_ = builder.Build();
245 244
246 job_factory_ = CreateJobFactory(&protocol_handlers_, 245 job_factory_ =
247 request_interceptors_.Pass()); 246 CreateJobFactory(&protocol_handlers_, std::move(request_interceptors_));
248 job_factory_.reset(new net::URLRequestInterceptingJobFactory( 247 job_factory_.reset(new net::URLRequestInterceptingJobFactory(
249 job_factory_.Pass(), 248 std::move(job_factory_),
250 browser_context->GetDataReductionProxyIOData()->CreateInterceptor())); 249 browser_context->GetDataReductionProxyIOData()->CreateInterceptor()));
251 url_request_context_->set_job_factory(job_factory_.get()); 250 url_request_context_->set_job_factory(job_factory_.get());
252 url_request_context_->set_http_user_agent_settings( 251 url_request_context_->set_http_user_agent_settings(
253 http_user_agent_settings_.get()); 252 http_user_agent_settings_.get());
254 } 253 }
255 254
256 net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() { 255 net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() {
257 DCHECK_CURRENTLY_ON(BrowserThread::IO); 256 DCHECK_CURRENTLY_ON(BrowserThread::IO);
258 if (!url_request_context_) 257 if (!url_request_context_)
259 InitializeURLRequestContext(); 258 InitializeURLRequestContext();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 http_auth_preferences_->set_server_whitelist( 303 http_auth_preferences_->set_server_whitelist(
305 auth_server_whitelist_.GetValue()); 304 auth_server_whitelist_.GetValue());
306 } 305 }
307 306
308 void AwURLRequestContextGetter::UpdateAndroidAuthNegotiateAccountType() { 307 void AwURLRequestContextGetter::UpdateAndroidAuthNegotiateAccountType() {
309 http_auth_preferences_->set_auth_android_negotiate_account_type( 308 http_auth_preferences_->set_auth_android_negotiate_account_type(
310 auth_android_negotiate_account_type_.GetValue()); 309 auth_android_negotiate_account_type_.GetValue());
311 } 310 }
312 311
313 } // namespace android_webview 312 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/net/aw_request_interceptor.cc ('k') | android_webview/browser/net/aw_url_request_job_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698