Chromium Code Reviews| Index: components/cronet/ios/cronet_environment.cc |
| diff --git a/components/cronet/ios/cronet_environment.cc b/components/cronet/ios/cronet_environment.cc |
| index cb65294ae6848fb8db178a64976d3afd92faf135..152a1b0f954ecbd172fecfc6c7b60b0987b17891 100644 |
| --- a/components/cronet/ios/cronet_environment.cc |
| +++ b/components/cronet/ios/cronet_environment.cc |
| @@ -67,10 +67,6 @@ base::MessageLoop* g_main_message_loop = nullptr; |
| namespace cronet { |
| -bool CronetEnvironment::IsOnNetworkThread() { |
| - return network_io_thread_->task_runner()->BelongsToCurrentThread(); |
| -} |
| - |
| void CronetEnvironment::PostToNetworkThread( |
| const tracked_objects::Location& from_here, |
| const base::Closure& task) { |
| @@ -83,8 +79,8 @@ void CronetEnvironment::PostToFileUserBlockingThread( |
| file_user_blocking_thread_->task_runner()->PostTask(from_here, task); |
| } |
| -net::URLRequestContext* CronetEnvironment::GetURLRequestContext() const { |
| - return main_context_.get(); |
| +net::URLRequestContextGetter* CronetEnvironment::GetURLRequestContextGetter() { |
| + return request_context_getter_.get(); |
| } |
| // static |
| @@ -223,6 +219,15 @@ void CronetEnvironment::Start() { |
| proxy_config_service_ = net::ProxyService::CreateSystemProxyConfigService( |
| network_io_thread_->task_runner(), nullptr); |
| + // Create request_context_getter_ here so that it will be availble as soon |
|
mef
2016/10/11 22:09:37
Would it be easier to have custom net::URLRequestC
Garrett Casto
2016/10/12 00:23:36
Yes. If nothing else this doesn't require getting
|
| + // as this function returns. main_context_ won't actually be setup at that |
| + // point, but any usage should happen on the network thread and the |
| + // initialization callback will be run before any other posted task. |
| + main_context_.reset(new net::URLRequestContext); |
| + main_context_->DetachFromThread(); |
| + request_context_getter_ = new net::TrivialURLRequestContextGetter( |
| + main_context_.get(), network_io_thread_->task_runner()); |
| + |
| #if defined(USE_NSS_CERTS) |
| net::SetURLRequestContextForNSSHttpIO(main_context_.get()); |
| #endif |
| @@ -243,7 +248,6 @@ void CronetEnvironment::InitializeOnNetworkThread() { |
| DCHECK(network_io_thread_->task_runner()->BelongsToCurrentThread()); |
| base::FeatureList::InitializeInstance(std::string(), std::string()); |
| // TODO(mef): Use net:UrlRequestContextBuilder instead of manual build. |
| - main_context_.reset(new net::URLRequestContext); |
| main_context_->set_net_log(net_log_.get()); |
| std::string user_agent(user_agent_product_name_ + |
| " (iOS); Cronet/" CRONET_VERSION); |