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

Side by Side Diff: ios/chrome/browser/browser_state/chrome_browser_state_impl_io_data.cc

Issue 1586833002: Convert Pass()→std::move() for iOS build. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert accidental //base change 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 2015 The Chromium Authors. All rights reserved. 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 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 "ios/chrome/browser/browser_state/chrome_browser_state_impl_io_data.h" 5 #include "ios/chrome/browser/browser_state/chrome_browser_state_impl_io_data.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/callback.h" 11 #include "base/callback.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "base/prefs/json_pref_store.h" 14 #include "base/prefs/json_pref_store.h"
14 #include "base/prefs/pref_filter.h" 15 #include "base/prefs/pref_filter.h"
15 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
16 #include "base/sequenced_task_runner.h" 17 #include "base/sequenced_task_runner.h"
17 #include "base/threading/sequenced_worker_pool.h" 18 #include "base/threading/sequenced_worker_pool.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 ChromeBrowserStateImplIOData::Handle::~Handle() { 61 ChromeBrowserStateImplIOData::Handle::~Handle() {
61 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI); 62 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI);
62 if (io_data_->http_server_properties_manager_) 63 if (io_data_->http_server_properties_manager_)
63 io_data_->http_server_properties_manager_->ShutdownOnPrefThread(); 64 io_data_->http_server_properties_manager_->ShutdownOnPrefThread();
64 65
65 // io_data_->data_reduction_proxy_io_data() might be NULL if Init() was 66 // io_data_->data_reduction_proxy_io_data() might be NULL if Init() was
66 // never called. 67 // never called.
67 if (io_data_->data_reduction_proxy_io_data()) 68 if (io_data_->data_reduction_proxy_io_data())
68 io_data_->data_reduction_proxy_io_data()->ShutdownOnUIThread(); 69 io_data_->data_reduction_proxy_io_data()->ShutdownOnUIThread();
69 70
70 io_data_->ShutdownOnUIThread(GetAllContextGetters().Pass()); 71 io_data_->ShutdownOnUIThread(GetAllContextGetters());
71 } 72 }
72 73
73 void ChromeBrowserStateImplIOData::Handle::Init( 74 void ChromeBrowserStateImplIOData::Handle::Init(
74 const base::FilePath& cookie_path, 75 const base::FilePath& cookie_path,
75 const base::FilePath& channel_id_path, 76 const base::FilePath& channel_id_path,
76 const base::FilePath& cache_path, 77 const base::FilePath& cache_path,
77 int cache_max_size, 78 int cache_max_size,
78 const base::FilePath& profile_path) { 79 const base::FilePath& profile_path) {
79 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI); 80 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI);
80 DCHECK(!io_data_->lazy_params_); 81 DCHECK(!io_data_->lazy_params_);
(...skipping 17 matching lines...) Expand all
98 // params are unified into a single object. 99 // params are unified into a single object.
99 bool enable_quic_for_data_reduction_proxy = 100 bool enable_quic_for_data_reduction_proxy =
100 IOSChromeIOThread::ShouldEnableQuicForDataReductionProxy(); 101 IOSChromeIOThread::ShouldEnableQuicForDataReductionProxy();
101 102
102 io_data_->set_data_reduction_proxy_io_data( 103 io_data_->set_data_reduction_proxy_io_data(
103 CreateIOSChromeDataReductionProxyIOData( 104 CreateIOSChromeDataReductionProxyIOData(
104 GetApplicationContext()->GetIOSChromeIOThread()->net_log(), 105 GetApplicationContext()->GetIOSChromeIOThread()->net_log(),
105 browser_state_->GetPrefs(), 106 browser_state_->GetPrefs(),
106 web::WebThread::GetTaskRunnerForThread(web::WebThread::IO), 107 web::WebThread::GetTaskRunnerForThread(web::WebThread::IO),
107 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI), 108 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI),
108 enable_quic_for_data_reduction_proxy) 109 enable_quic_for_data_reduction_proxy));
109 .Pass());
110 110
111 base::SequencedWorkerPool* pool = web::WebThread::GetBlockingPool(); 111 base::SequencedWorkerPool* pool = web::WebThread::GetBlockingPool();
112 scoped_refptr<base::SequencedTaskRunner> db_task_runner = 112 scoped_refptr<base::SequencedTaskRunner> db_task_runner =
113 pool->GetSequencedTaskRunnerWithShutdownBehavior( 113 pool->GetSequencedTaskRunnerWithShutdownBehavior(
114 pool->GetSequenceToken(), 114 pool->GetSequenceToken(),
115 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); 115 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
116 scoped_ptr<data_reduction_proxy::DataStore> store( 116 scoped_ptr<data_reduction_proxy::DataStore> store(
117 new data_reduction_proxy::DataStoreImpl(profile_path)); 117 new data_reduction_proxy::DataStoreImpl(profile_path));
118 IOSChromeDataReductionProxySettingsFactory::GetForBrowserState(browser_state_) 118 IOSChromeDataReductionProxySettingsFactory::GetForBrowserState(browser_state_)
119 ->InitDataReductionProxySettings( 119 ->InitDataReductionProxySettings(
120 io_data_->data_reduction_proxy_io_data(), browser_state_->GetPrefs(), 120 io_data_->data_reduction_proxy_io_data(), browser_state_->GetPrefs(),
121 browser_state_->GetRequestContext(), store.Pass(), 121 browser_state_->GetRequestContext(), std::move(store),
122 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI), 122 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI),
123 db_task_runner); 123 db_task_runner);
124 } 124 }
125 125
126 scoped_refptr<IOSChromeURLRequestContextGetter> 126 scoped_refptr<IOSChromeURLRequestContextGetter>
127 ChromeBrowserStateImplIOData::Handle::CreateMainRequestContextGetter( 127 ChromeBrowserStateImplIOData::Handle::CreateMainRequestContextGetter(
128 ProtocolHandlerMap* protocol_handlers, 128 ProtocolHandlerMap* protocol_handlers,
129 PrefService* local_state, 129 PrefService* local_state,
130 IOSChromeIOThread* io_thread) const { 130 IOSChromeIOThread* io_thread) const {
131 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI); 131 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 scoped_ptr<IOSChromeURLRequestContextGetterVector> context_getters( 204 scoped_ptr<IOSChromeURLRequestContextGetterVector> context_getters(
205 new IOSChromeURLRequestContextGetterVector()); 205 new IOSChromeURLRequestContextGetterVector());
206 206
207 iter = app_request_context_getter_map_.begin(); 207 iter = app_request_context_getter_map_.begin();
208 for (; iter != app_request_context_getter_map_.end(); ++iter) 208 for (; iter != app_request_context_getter_map_.end(); ++iter)
209 context_getters->push_back(iter->second); 209 context_getters->push_back(iter->second);
210 210
211 if (main_request_context_getter_.get()) 211 if (main_request_context_getter_.get())
212 context_getters->push_back(main_request_context_getter_); 212 context_getters->push_back(main_request_context_getter_);
213 213
214 return context_getters.Pass(); 214 return context_getters;
215 } 215 }
216 216
217 ChromeBrowserStateImplIOData::LazyParams::LazyParams() : cache_max_size(0) {} 217 ChromeBrowserStateImplIOData::LazyParams::LazyParams() : cache_max_size(0) {}
218 218
219 ChromeBrowserStateImplIOData::LazyParams::~LazyParams() {} 219 ChromeBrowserStateImplIOData::LazyParams::~LazyParams() {}
220 220
221 ChromeBrowserStateImplIOData::ChromeBrowserStateImplIOData() 221 ChromeBrowserStateImplIOData::ChromeBrowserStateImplIOData()
222 : ChromeBrowserStateIOData( 222 : ChromeBrowserStateIOData(
223 ios::ChromeBrowserStateType::REGULAR_BROWSER_STATE), 223 ios::ChromeBrowserStateType::REGULAR_BROWSER_STATE),
224 http_server_properties_manager_(nullptr), 224 http_server_properties_manager_(nullptr),
(...skipping 22 matching lines...) Expand all
247 247
248 ApplyProfileParamsToContext(main_context); 248 ApplyProfileParamsToContext(main_context);
249 249
250 if (http_server_properties_manager_) 250 if (http_server_properties_manager_)
251 http_server_properties_manager_->InitializeOnNetworkThread(); 251 http_server_properties_manager_->InitializeOnNetworkThread();
252 252
253 main_context->set_transport_security_state(transport_security_state()); 253 main_context->set_transport_security_state(transport_security_state());
254 254
255 main_context->set_net_log(io_thread->net_log()); 255 main_context->set_net_log(io_thread->net_log());
256 256
257 network_delegate_ = 257 network_delegate_ = data_reduction_proxy_io_data()->CreateNetworkDelegate(
258 data_reduction_proxy_io_data() 258 std::move(chrome_network_delegate), true);
259 ->CreateNetworkDelegate(chrome_network_delegate.Pass(), true)
260 .Pass();
261 259
262 main_context->set_network_delegate(network_delegate_.get()); 260 main_context->set_network_delegate(network_delegate_.get());
263 261
264 main_context->set_http_server_properties(http_server_properties()); 262 main_context->set_http_server_properties(http_server_properties());
265 263
266 main_context->set_host_resolver(io_thread_globals->host_resolver.get()); 264 main_context->set_host_resolver(io_thread_globals->host_resolver.get());
267 265
268 main_context->set_http_auth_handler_factory( 266 main_context->set_http_auth_handler_factory(
269 io_thread_globals->http_auth_handler_factory.get()); 267 io_thread_globals->http_auth_handler_factory.get());
270 268
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 309
312 set_channel_id_service(channel_id_service); 310 set_channel_id_service(channel_id_service);
313 main_context->set_channel_id_service(channel_id_service); 311 main_context->set_channel_id_service(channel_id_service);
314 312
315 scoped_ptr<net::HttpCache::BackendFactory> main_backend( 313 scoped_ptr<net::HttpCache::BackendFactory> main_backend(
316 new net::HttpCache::DefaultBackend( 314 new net::HttpCache::DefaultBackend(
317 net::DISK_CACHE, net::CACHE_BACKEND_BLOCKFILE, 315 net::DISK_CACHE, net::CACHE_BACKEND_BLOCKFILE,
318 lazy_params_->cache_path, lazy_params_->cache_max_size, 316 lazy_params_->cache_path, lazy_params_->cache_max_size,
319 web::WebThread::GetTaskRunnerForThread(web::WebThread::CACHE))); 317 web::WebThread::GetTaskRunnerForThread(web::WebThread::CACHE)));
320 http_network_session_ = CreateHttpNetworkSession(*profile_params); 318 http_network_session_ = CreateHttpNetworkSession(*profile_params);
321 main_http_factory_ = 319 main_http_factory_ = CreateMainHttpFactory(http_network_session_.get(),
322 CreateMainHttpFactory(http_network_session_.get(), main_backend.Pass()); 320 std::move(main_backend));
323 main_context->set_http_transaction_factory(main_http_factory_.get()); 321 main_context->set_http_transaction_factory(main_http_factory_.get());
324 322
325 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( 323 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory(
326 new net::URLRequestJobFactoryImpl()); 324 new net::URLRequestJobFactoryImpl());
327 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers); 325 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers);
328 326
329 // The data reduction proxy interceptor should be as close to the network as 327 // The data reduction proxy interceptor should be as close to the network as
330 // possible. 328 // possible.
331 URLRequestInterceptorScopedVector request_interceptors; 329 URLRequestInterceptorScopedVector request_interceptors;
332 request_interceptors.insert( 330 request_interceptors.insert(
333 request_interceptors.begin(), 331 request_interceptors.begin(),
334 data_reduction_proxy_io_data()->CreateInterceptor().release()); 332 data_reduction_proxy_io_data()->CreateInterceptor().release());
335 main_job_factory_ = SetUpJobFactoryDefaults(main_job_factory.Pass(), 333 main_job_factory_ = SetUpJobFactoryDefaults(std::move(main_job_factory),
336 request_interceptors.Pass(), 334 std::move(request_interceptors),
337 main_context->network_delegate()); 335 main_context->network_delegate());
338 main_context->set_job_factory(main_job_factory_.get()); 336 main_context->set_job_factory(main_job_factory_.get());
339 main_context->set_network_quality_estimator( 337 main_context->set_network_quality_estimator(
340 io_thread_globals->network_quality_estimator.get()); 338 io_thread_globals->network_quality_estimator.get());
341 339
342 // Setup SDCH for this profile. 340 // Setup SDCH for this profile.
343 sdch_manager_.reset(new net::SdchManager); 341 sdch_manager_.reset(new net::SdchManager);
344 sdch_policy_.reset(new net::SdchOwner(sdch_manager_.get(), main_context)); 342 sdch_policy_.reset(new net::SdchOwner(sdch_manager_.get(), main_context));
345 main_context->set_sdch_manager(sdch_manager_.get()); 343 main_context->set_sdch_manager(sdch_manager_.get());
346 sdch_policy_->EnablePersistentStorage(network_json_store_.get()); 344 sdch_policy_->EnablePersistentStorage(network_json_store_.get());
347 345
348 lazy_params_.reset(); 346 lazy_params_.reset();
349 } 347 }
350 348
351 net::URLRequestContext* 349 net::URLRequestContext*
352 ChromeBrowserStateImplIOData::InitializeAppRequestContext( 350 ChromeBrowserStateImplIOData::InitializeAppRequestContext(
353 net::URLRequestContext* main_context) const { 351 net::URLRequestContext* main_context) const {
354 // Copy most state from the main context. 352 // Copy most state from the main context.
355 AppRequestContext* context = new AppRequestContext(); 353 AppRequestContext* context = new AppRequestContext();
356 context->CopyFrom(main_context); 354 context->CopyFrom(main_context);
357 355
358 // Use a separate HTTP disk cache for isolated apps. 356 // Use a separate HTTP disk cache for isolated apps.
359 scoped_ptr<net::HttpCache::BackendFactory> app_backend = 357 scoped_ptr<net::HttpCache::BackendFactory> app_backend =
360 net::HttpCache::DefaultBackend::InMemory(0); 358 net::HttpCache::DefaultBackend::InMemory(0);
361 scoped_ptr<net::HttpCache> app_http_cache = 359 scoped_ptr<net::HttpCache> app_http_cache =
362 CreateHttpFactory(http_network_session_.get(), app_backend.Pass()); 360 CreateHttpFactory(http_network_session_.get(), std::move(app_backend));
363 361
364 cookie_util::CookieStoreConfig ios_cookie_config( 362 cookie_util::CookieStoreConfig ios_cookie_config(
365 base::FilePath(), 363 base::FilePath(),
366 cookie_util::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, 364 cookie_util::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
367 cookie_util::CookieStoreConfig::COOKIE_STORE_IOS, nullptr); 365 cookie_util::CookieStoreConfig::COOKIE_STORE_IOS, nullptr);
368 scoped_refptr<net::CookieStore> cookie_store = 366 scoped_refptr<net::CookieStore> cookie_store =
369 cookie_util::CreateCookieStore(ios_cookie_config); 367 cookie_util::CreateCookieStore(ios_cookie_config);
370 368
371 // Transfer ownership of the cookies and cache to AppRequestContext. 369 // Transfer ownership of the cookies and cache to AppRequestContext.
372 context->SetCookieStore(cookie_store.get()); 370 context->SetCookieStore(cookie_store.get());
373 context->SetHttpTransactionFactory(app_http_cache.Pass()); 371 context->SetHttpTransactionFactory(std::move(app_http_cache));
374 372
375 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( 373 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
376 new net::URLRequestJobFactoryImpl()); 374 new net::URLRequestJobFactoryImpl());
377 // The data reduction proxy interceptor should be as close to the network as 375 // The data reduction proxy interceptor should be as close to the network as
378 // possible. 376 // possible.
379 URLRequestInterceptorScopedVector request_interceptors; 377 URLRequestInterceptorScopedVector request_interceptors;
380 request_interceptors.insert( 378 request_interceptors.insert(
381 request_interceptors.begin(), 379 request_interceptors.begin(),
382 data_reduction_proxy_io_data()->CreateInterceptor().release()); 380 data_reduction_proxy_io_data()->CreateInterceptor().release());
383 scoped_ptr<net::URLRequestJobFactory> top_job_factory( 381 scoped_ptr<net::URLRequestJobFactory> top_job_factory(SetUpJobFactoryDefaults(
384 SetUpJobFactoryDefaults(job_factory.Pass(), request_interceptors.Pass(), 382 std::move(job_factory), std::move(request_interceptors),
385 main_context->network_delegate())); 383 main_context->network_delegate()));
386 context->SetJobFactory(top_job_factory.Pass()); 384 context->SetJobFactory(std::move(top_job_factory));
387 385
388 return context; 386 return context;
389 } 387 }
390 388
391 net::URLRequestContext* 389 net::URLRequestContext*
392 ChromeBrowserStateImplIOData::AcquireIsolatedAppRequestContext( 390 ChromeBrowserStateImplIOData::AcquireIsolatedAppRequestContext(
393 net::URLRequestContext* main_context) const { 391 net::URLRequestContext* main_context) const {
394 // We create per-app contexts on demand, unlike the others above. 392 // We create per-app contexts on demand, unlike the others above.
395 net::URLRequestContext* app_request_context = 393 net::URLRequestContext* app_request_context =
396 InitializeAppRequestContext(main_context); 394 InitializeAppRequestContext(main_context);
397 DCHECK(app_request_context); 395 DCHECK(app_request_context);
398 return app_request_context; 396 return app_request_context;
399 } 397 }
400 398
401 void ChromeBrowserStateImplIOData::ClearNetworkingHistorySinceOnIOThread( 399 void ChromeBrowserStateImplIOData::ClearNetworkingHistorySinceOnIOThread(
402 base::Time time, 400 base::Time time,
403 const base::Closure& completion) { 401 const base::Closure& completion) {
404 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::IO); 402 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::IO);
405 DCHECK(initialized()); 403 DCHECK(initialized());
406 404
407 DCHECK(transport_security_state()); 405 DCHECK(transport_security_state());
408 // Completes synchronously. 406 // Completes synchronously.
409 transport_security_state()->DeleteAllDynamicDataSince(time); 407 transport_security_state()->DeleteAllDynamicDataSince(time);
410 DCHECK(http_server_properties_manager_); 408 DCHECK(http_server_properties_manager_);
411 http_server_properties_manager_->Clear(completion); 409 http_server_properties_manager_->Clear(completion);
412 } 410 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698