| Index: components/cronet/ios/cronet_environment.cc
|
| diff --git a/components/cronet/ios/cronet_environment.cc b/components/cronet/ios/cronet_environment.cc
|
| index 5f4028f170ee17d9bccc8e75fa62b71718ffcfde..6c811d23956e6d268bde7e41c3d434972fc416e6 100644
|
| --- a/components/cronet/ios/cronet_environment.cc
|
| +++ b/components/cronet/ios/cronet_environment.cc
|
| @@ -66,10 +66,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) {
|
| @@ -82,8 +78,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
|
| @@ -222,6 +218,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
|
| + // 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
|
| @@ -242,7 +247,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);
|
|
|