Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromecast/shell/browser/url_request_context_factory.h" | 5 #include "chromecast/shell/browser/url_request_context_factory.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 // Cast http user agent settings must be initialized in UI thread | 143 // Cast http user agent settings must be initialized in UI thread |
| 144 // because it registers itself to pref notification observer which is not | 144 // because it registers itself to pref notification observer which is not |
| 145 // thread safe. | 145 // thread safe. |
| 146 http_user_agent_settings_.reset(new CastHttpUserAgentSettings()); | 146 http_user_agent_settings_.reset(new CastHttpUserAgentSettings()); |
| 147 } | 147 } |
| 148 | 148 |
| 149 net::URLRequestContextGetter* URLRequestContextFactory::CreateMainGetter( | 149 net::URLRequestContextGetter* URLRequestContextFactory::CreateMainGetter( |
| 150 content::BrowserContext* browser_context, | 150 content::BrowserContext* browser_context, |
| 151 content::ProtocolHandlerMap* protocol_handlers, | 151 content::ProtocolHandlerMap* protocol_handlers, |
| 152 content::URLRequestInterceptorScopedVector request_interceptors) { | 152 content::URLRequestInterceptorScopedVector request_interceptors) { |
| 153 DCHECK(!main_getter_) << "Main URLRequestContextGetter already initialized"; | 153 DCHECK(!main_getter_.get()) |
| 154 << "Main URLRequestContextGetter already initialized"; | |
| 154 main_getter_ = new MainURLRequestContextGetter(this, | 155 main_getter_ = new MainURLRequestContextGetter(this, |
| 155 browser_context, | 156 browser_context, |
| 156 protocol_handlers, | 157 protocol_handlers, |
| 157 request_interceptors.Pass()); | 158 request_interceptors.Pass()); |
| 158 return main_getter_.get(); | 159 return main_getter_.get(); |
| 159 } | 160 } |
| 160 | 161 |
| 161 net::URLRequestContextGetter* URLRequestContextFactory::GetMainGetter() { | 162 net::URLRequestContextGetter* URLRequestContextFactory::GetMainGetter() { |
| 162 CHECK(main_getter_); | 163 CHECK(main_getter_.get()); |
| 163 return main_getter_.get(); | 164 return main_getter_.get(); |
| 164 } | 165 } |
| 165 | 166 |
| 166 net::URLRequestContextGetter* URLRequestContextFactory::GetSystemGetter() { | 167 net::URLRequestContextGetter* URLRequestContextFactory::GetSystemGetter() { |
| 167 if (!system_getter_) { | 168 if (!system_getter_.get()) { |
| 168 system_getter_ = new URLRequestContextGetter(this, false); | 169 system_getter_ = new URLRequestContextGetter(this, false); |
| 169 } | 170 } |
| 170 return system_getter_.get(); | 171 return system_getter_.get(); |
| 171 } | 172 } |
| 172 | 173 |
| 173 net::URLRequestContextGetter* URLRequestContextFactory::GetMediaGetter() { | 174 net::URLRequestContextGetter* URLRequestContextFactory::GetMediaGetter() { |
| 174 if (!media_getter_) { | 175 if (!media_getter_.get()) { |
| 175 media_getter_ = new URLRequestContextGetter(this, true); | 176 media_getter_ = new URLRequestContextGetter(this, true); |
| 176 } | 177 } |
| 177 return media_getter_.get(); | 178 return media_getter_.get(); |
| 178 } | 179 } |
| 179 | 180 |
| 180 void URLRequestContextFactory::InitializeSystemContextDependencies() { | 181 void URLRequestContextFactory::InitializeSystemContextDependencies() { |
| 181 if (system_dependencies_initialized_) | 182 if (system_dependencies_initialized_) |
| 182 return; | 183 return; |
| 183 | 184 |
| 184 host_resolver_ = net::HostResolver::CreateDefaultResolver(NULL); | 185 host_resolver_ = net::HostResolver::CreateDefaultResolver(NULL); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 197 transport_security_state_.reset(new net::TransportSecurityState()); | 198 transport_security_state_.reset(new net::TransportSecurityState()); |
| 198 http_auth_handler_factory_.reset( | 199 http_auth_handler_factory_.reset( |
| 199 net::HttpAuthHandlerFactory::CreateDefault(host_resolver_.get())); | 200 net::HttpAuthHandlerFactory::CreateDefault(host_resolver_.get())); |
| 200 | 201 |
| 201 http_server_properties_.reset(new net::HttpServerPropertiesImpl); | 202 http_server_properties_.reset(new net::HttpServerPropertiesImpl); |
| 202 | 203 |
| 203 proxy_service_.reset(net::ProxyService::CreateUsingSystemProxyResolver( | 204 proxy_service_.reset(net::ProxyService::CreateUsingSystemProxyResolver( |
| 204 net::ProxyService::CreateSystemProxyConfigService( | 205 net::ProxyService::CreateSystemProxyConfigService( |
| 205 content::BrowserThread::GetMessageLoopProxyForThread( | 206 content::BrowserThread::GetMessageLoopProxyForThread( |
| 206 content::BrowserThread::IO).get(), | 207 content::BrowserThread::IO).get(), |
| 207 content::BrowserThread::UnsafeGetMessageLoopForThread( | 208 content::BrowserThread::GetMessageLoopProxyForThread( |
| 208 content::BrowserThread::FILE)), | 209 content::BrowserThread::FILE).get()), |
|
damienv1
2014/09/08 16:27:21
Why do you need raw pointers here ?
See prototype:
lcwu1
2014/09/08 18:01:58
This is indeed a bug. Thanks for catching this. Do
| |
| 209 0, | 210 0, |
| 210 NULL)); | 211 NULL)); |
| 211 system_dependencies_initialized_ = true; | 212 system_dependencies_initialized_ = true; |
| 212 } | 213 } |
| 213 | 214 |
| 214 void URLRequestContextFactory::InitializeMainContextDependencies( | 215 void URLRequestContextFactory::InitializeMainContextDependencies( |
| 215 net::HttpTransactionFactory* transaction_factory, | 216 net::HttpTransactionFactory* transaction_factory, |
| 216 content::ProtocolHandlerMap* protocol_handlers, | 217 content::ProtocolHandlerMap* protocol_handlers, |
| 217 content::URLRequestInterceptorScopedVector request_interceptors) { | 218 content::URLRequestInterceptorScopedVector request_interceptors) { |
| 218 if (main_dependencies_initialized_) | 219 if (main_dependencies_initialized_) |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 system_transaction_factory_.get()); | 306 system_transaction_factory_.get()); |
| 306 system_context->set_http_user_agent_settings( | 307 system_context->set_http_user_agent_settings( |
| 307 http_user_agent_settings_.get()); | 308 http_user_agent_settings_.get()); |
| 308 system_context->set_cookie_store( | 309 system_context->set_cookie_store( |
| 309 content::CreateCookieStore(content::CookieStoreConfig())); | 310 content::CreateCookieStore(content::CookieStoreConfig())); |
| 310 return system_context; | 311 return system_context; |
| 311 } | 312 } |
| 312 | 313 |
| 313 net::URLRequestContext* URLRequestContextFactory::CreateMediaRequestContext() { | 314 net::URLRequestContext* URLRequestContextFactory::CreateMediaRequestContext() { |
| 314 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 315 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 315 DCHECK(main_getter_) | 316 DCHECK(main_getter_.get()) |
| 316 << "Getting MediaRequestContext before MainRequestContext"; | 317 << "Getting MediaRequestContext before MainRequestContext"; |
| 317 net::URLRequestContext* main_context = main_getter_->GetURLRequestContext(); | 318 net::URLRequestContext* main_context = main_getter_->GetURLRequestContext(); |
| 318 | 319 |
| 319 // Set non caching backend. | 320 // Set non caching backend. |
| 320 net::HttpNetworkSession* main_session = | 321 net::HttpNetworkSession* main_session = |
| 321 main_transaction_factory_->GetSession(); | 322 main_transaction_factory_->GetSession(); |
| 322 InitializeMediaContextDependencies( | 323 InitializeMediaContextDependencies( |
| 323 new net::HttpNetworkLayer(main_session)); | 324 new net::HttpNetworkLayer(main_session)); |
| 324 | 325 |
| 325 net::URLRequestContext* media_context = new net::URLRequestContext(); | 326 net::URLRequestContext* media_context = new net::URLRequestContext(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 http_user_agent_settings_.get()); | 378 http_user_agent_settings_.get()); |
| 378 | 379 |
| 379 main_context->set_http_transaction_factory( | 380 main_context->set_http_transaction_factory( |
| 380 main_transaction_factory_.get()); | 381 main_transaction_factory_.get()); |
| 381 main_context->set_job_factory(main_job_factory_.get()); | 382 main_context->set_job_factory(main_job_factory_.get()); |
| 382 return main_context; | 383 return main_context; |
| 383 } | 384 } |
| 384 | 385 |
| 385 } // namespace shell | 386 } // namespace shell |
| 386 } // namespace chromecast | 387 } // namespace chromecast |
| OLD | NEW |