| OLD | NEW |
| 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/off_the_record_chrome_browser_state_i
o_data.h" | 5 #include "ios/chrome/browser/browser_state/off_the_record_chrome_browser_state_i
o_data.h" |
| 6 | 6 |
| 7 #import <UIKit/UIkit.h> | 7 #import <UIKit/UIkit.h> |
| 8 | 8 |
| 9 #include <utility> |
| 10 |
| 9 #include "base/bind.h" | 11 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 13 #include "base/logging.h" |
| 12 #include "base/mac/bind_objc_block.h" | 14 #include "base/mac/bind_objc_block.h" |
| 13 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
| 14 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 15 #include "base/threading/worker_pool.h" | 17 #include "base/threading/worker_pool.h" |
| 16 #include "components/net_log/chrome_net_log.h" | 18 #include "components/net_log/chrome_net_log.h" |
| 17 #include "ios/chrome/browser/chrome_constants.h" | 19 #include "ios/chrome/browser/chrome_constants.h" |
| 18 #include "ios/chrome/browser/ios_chrome_io_thread.h" | 20 #include "ios/chrome/browser/ios_chrome_io_thread.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 browser_state->GetStatePath().Append(kIOSChromeChannelIDFilename); | 83 browser_state->GetStatePath().Append(kIOSChromeChannelIDFilename); |
| 82 } | 84 } |
| 83 | 85 |
| 84 OffTheRecordChromeBrowserStateIOData::Handle::~Handle() { | 86 OffTheRecordChromeBrowserStateIOData::Handle::~Handle() { |
| 85 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI); | 87 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI); |
| 86 | 88 |
| 87 // Stop listening to notifications. | 89 // Stop listening to notifications. |
| 88 CFNotificationCenterRemoveObserver(CFNotificationCenterGetLocalCenter(), this, | 90 CFNotificationCenterRemoveObserver(CFNotificationCenterGetLocalCenter(), this, |
| 89 nullptr, nullptr); | 91 nullptr, nullptr); |
| 90 | 92 |
| 91 io_data_->ShutdownOnUIThread(GetAllContextGetters().Pass()); | 93 io_data_->ShutdownOnUIThread(GetAllContextGetters()); |
| 92 } | 94 } |
| 93 | 95 |
| 94 scoped_refptr<IOSChromeURLRequestContextGetter> | 96 scoped_refptr<IOSChromeURLRequestContextGetter> |
| 95 OffTheRecordChromeBrowserStateIOData::Handle::CreateMainRequestContextGetter( | 97 OffTheRecordChromeBrowserStateIOData::Handle::CreateMainRequestContextGetter( |
| 96 ProtocolHandlerMap* protocol_handlers) const { | 98 ProtocolHandlerMap* protocol_handlers) const { |
| 97 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI); | 99 DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::UI); |
| 98 LazyInitialize(); | 100 LazyInitialize(); |
| 99 DCHECK(!main_request_context_getter_.get()); | 101 DCHECK(!main_request_context_getter_.get()); |
| 100 main_request_context_getter_ = | 102 main_request_context_getter_ = |
| 101 IOSChromeURLRequestContextGetter::Create(io_data_, protocol_handlers); | 103 IOSChromeURLRequestContextGetter::Create(io_data_, protocol_handlers); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 129 nullptr, CFNotificationSuspensionBehaviorCoalesce); | 131 nullptr, CFNotificationSuspensionBehaviorCoalesce); |
| 130 } | 132 } |
| 131 | 133 |
| 132 scoped_ptr<ChromeBrowserStateIOData::IOSChromeURLRequestContextGetterVector> | 134 scoped_ptr<ChromeBrowserStateIOData::IOSChromeURLRequestContextGetterVector> |
| 133 OffTheRecordChromeBrowserStateIOData::Handle::GetAllContextGetters() { | 135 OffTheRecordChromeBrowserStateIOData::Handle::GetAllContextGetters() { |
| 134 scoped_ptr<IOSChromeURLRequestContextGetterVector> context_getters( | 136 scoped_ptr<IOSChromeURLRequestContextGetterVector> context_getters( |
| 135 new IOSChromeURLRequestContextGetterVector()); | 137 new IOSChromeURLRequestContextGetterVector()); |
| 136 if (main_request_context_getter_.get()) | 138 if (main_request_context_getter_.get()) |
| 137 context_getters->push_back(main_request_context_getter_); | 139 context_getters->push_back(main_request_context_getter_); |
| 138 | 140 |
| 139 return context_getters.Pass(); | 141 return context_getters; |
| 140 } | 142 } |
| 141 | 143 |
| 142 OffTheRecordChromeBrowserStateIOData::OffTheRecordChromeBrowserStateIOData() | 144 OffTheRecordChromeBrowserStateIOData::OffTheRecordChromeBrowserStateIOData() |
| 143 : ChromeBrowserStateIOData( | 145 : ChromeBrowserStateIOData( |
| 144 ios::ChromeBrowserStateType::INCOGNITO_BROWSER_STATE) {} | 146 ios::ChromeBrowserStateType::INCOGNITO_BROWSER_STATE) {} |
| 145 | 147 |
| 146 OffTheRecordChromeBrowserStateIOData::~OffTheRecordChromeBrowserStateIOData() {} | 148 OffTheRecordChromeBrowserStateIOData::~OffTheRecordChromeBrowserStateIOData() {} |
| 147 | 149 |
| 148 void OffTheRecordChromeBrowserStateIOData::InitializeInternal( | 150 void OffTheRecordChromeBrowserStateIOData::InitializeInternal( |
| 149 scoped_ptr<IOSChromeNetworkDelegate> chrome_network_delegate, | 151 scoped_ptr<IOSChromeNetworkDelegate> chrome_network_delegate, |
| 150 ProfileParams* profile_params, | 152 ProfileParams* profile_params, |
| 151 ProtocolHandlerMap* protocol_handlers) const { | 153 ProtocolHandlerMap* protocol_handlers) const { |
| 152 net::URLRequestContext* main_context = main_request_context(); | 154 net::URLRequestContext* main_context = main_request_context(); |
| 153 | 155 |
| 154 IOSChromeIOThread* const io_thread = profile_params->io_thread; | 156 IOSChromeIOThread* const io_thread = profile_params->io_thread; |
| 155 IOSChromeIOThread::Globals* const io_thread_globals = io_thread->globals(); | 157 IOSChromeIOThread::Globals* const io_thread_globals = io_thread->globals(); |
| 156 | 158 |
| 157 ApplyProfileParamsToContext(main_context); | 159 ApplyProfileParamsToContext(main_context); |
| 158 | 160 |
| 159 main_context->set_transport_security_state(transport_security_state()); | 161 main_context->set_transport_security_state(transport_security_state()); |
| 160 | 162 |
| 161 main_context->set_net_log(io_thread->net_log()); | 163 main_context->set_net_log(io_thread->net_log()); |
| 162 | 164 |
| 163 main_context->set_network_delegate(chrome_network_delegate.get()); | 165 main_context->set_network_delegate(chrome_network_delegate.get()); |
| 164 | 166 |
| 165 network_delegate_ = chrome_network_delegate.Pass(); | 167 network_delegate_ = std::move(chrome_network_delegate); |
| 166 | 168 |
| 167 main_context->set_host_resolver(io_thread_globals->host_resolver.get()); | 169 main_context->set_host_resolver(io_thread_globals->host_resolver.get()); |
| 168 main_context->set_http_auth_handler_factory( | 170 main_context->set_http_auth_handler_factory( |
| 169 io_thread_globals->http_auth_handler_factory.get()); | 171 io_thread_globals->http_auth_handler_factory.get()); |
| 170 main_context->set_proxy_service(proxy_service()); | 172 main_context->set_proxy_service(proxy_service()); |
| 171 | 173 |
| 172 main_context->set_cert_transparency_verifier( | 174 main_context->set_cert_transparency_verifier( |
| 173 io_thread_globals->cert_transparency_verifier.get()); | 175 io_thread_globals->cert_transparency_verifier.get()); |
| 174 main_context->set_backoff_manager( | 176 main_context->set_backoff_manager( |
| 175 io_thread_globals->url_request_backoff_manager.get()); | 177 io_thread_globals->url_request_backoff_manager.get()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 204 main_http_factory_ = CreateMainHttpFactory( | 206 main_http_factory_ = CreateMainHttpFactory( |
| 205 http_network_session_.get(), net::HttpCache::DefaultBackend::InMemory(0)); | 207 http_network_session_.get(), net::HttpCache::DefaultBackend::InMemory(0)); |
| 206 | 208 |
| 207 main_context->set_http_transaction_factory(main_http_factory_.get()); | 209 main_context->set_http_transaction_factory(main_http_factory_.get()); |
| 208 | 210 |
| 209 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( | 211 scoped_ptr<net::URLRequestJobFactoryImpl> main_job_factory( |
| 210 new net::URLRequestJobFactoryImpl()); | 212 new net::URLRequestJobFactoryImpl()); |
| 211 | 213 |
| 212 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers); | 214 InstallProtocolHandlers(main_job_factory.get(), protocol_handlers); |
| 213 URLRequestInterceptorScopedVector empty_interceptors; | 215 URLRequestInterceptorScopedVector empty_interceptors; |
| 214 main_job_factory_ = SetUpJobFactoryDefaults(main_job_factory.Pass(), | 216 main_job_factory_ = SetUpJobFactoryDefaults(std::move(main_job_factory), |
| 215 empty_interceptors.Pass(), | 217 std::move(empty_interceptors), |
| 216 main_context->network_delegate()); | 218 main_context->network_delegate()); |
| 217 main_context->set_job_factory(main_job_factory_.get()); | 219 main_context->set_job_factory(main_job_factory_.get()); |
| 218 | 220 |
| 219 // Setup SDCH for this profile. | 221 // Setup SDCH for this profile. |
| 220 sdch_manager_.reset(new net::SdchManager); | 222 sdch_manager_.reset(new net::SdchManager); |
| 221 sdch_policy_.reset(new net::SdchOwner(sdch_manager_.get(), main_context)); | 223 sdch_policy_.reset(new net::SdchOwner(sdch_manager_.get(), main_context)); |
| 222 main_context->set_sdch_manager(sdch_manager_.get()); | 224 main_context->set_sdch_manager(sdch_manager_.get()); |
| 223 } | 225 } |
| 224 | 226 |
| 225 net::URLRequestContext* | 227 net::URLRequestContext* |
| 226 OffTheRecordChromeBrowserStateIOData::InitializeAppRequestContext( | 228 OffTheRecordChromeBrowserStateIOData::InitializeAppRequestContext( |
| 227 net::URLRequestContext* main_context) const { | 229 net::URLRequestContext* main_context) const { |
| 228 NOTREACHED(); | 230 NOTREACHED(); |
| 229 return nullptr; | 231 return nullptr; |
| 230 } | 232 } |
| 231 | 233 |
| 232 net::URLRequestContext* | 234 net::URLRequestContext* |
| 233 OffTheRecordChromeBrowserStateIOData::AcquireIsolatedAppRequestContext( | 235 OffTheRecordChromeBrowserStateIOData::AcquireIsolatedAppRequestContext( |
| 234 net::URLRequestContext* main_context) const { | 236 net::URLRequestContext* main_context) const { |
| 235 NOTREACHED(); | 237 NOTREACHED(); |
| 236 return nullptr; | 238 return nullptr; |
| 237 } | 239 } |
| OLD | NEW |