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

Unified Diff: components/cronet/ios/cronet_environment.cc

Issue 2273403003: Moving gRPC support interfaces out of cronet and into a new component. (Closed)
Patch Set: Add DEPS Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
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
+ // 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);

Powered by Google App Engine
This is Rietveld 408576698