Index: components/cronet/android/url_request_context_adapter.cc |
diff --git a/components/cronet/android/url_request_context_adapter.cc b/components/cronet/android/url_request_context_adapter.cc |
index 00e463e7f83d0f3cefbb14abfe0891ed28366c08..d7d681f15b08e7d52fdaead37bdf7da9f3747159 100644 |
--- a/components/cronet/android/url_request_context_adapter.cc |
+++ b/components/cronet/android/url_request_context_adapter.cc |
@@ -14,7 +14,7 @@ |
#include "net/http/http_auth_handler_factory.h" |
#include "net/http/http_network_layer.h" |
#include "net/http/http_server_properties.h" |
-#include "net/proxy/proxy_config_service_fixed.h" |
+#include "net/proxy/proxy_config_service.h" |
#include "net/proxy/proxy_service.h" |
#include "net/ssl/ssl_config_service_defaults.h" |
#include "net/url_request/static_http_user_agent_settings.h" |
@@ -125,12 +125,26 @@ void URLRequestContextAdapter::Initialize( |
base::Thread::Options options; |
options.message_loop_type = base::MessageLoop::TYPE_IO; |
network_thread_->StartWithOptions(options); |
+ config_ = config.Pass(); |
+ delegate_->InitProxyConfigService(); |
+} |
+ |
+// Called on application's main UI thread. |
+void URLRequestContextAdapter::InitProxyConfigServiceOnUIThread() { |
+ if (!base::MessageLoop::current()) { |
+ main_message_loop_.reset(new base::MessageLoopForUI); |
+ base::MessageLoopForUI::current()->Start(); |
mmenke
2014/10/02 16:17:26
I hadn't realized it was so easy to set up a base:
|
+ } |
+ net::ProxyConfigService* service = |
+ net::ProxyService::CreateSystemProxyConfigService(GetNetworkTaskRunner(), |
+ NULL); |
+ proxy_config_service_.reset(service); |
mmenke
2014/10/02 16:17:25
Hrm...So we ensure that the Java URLRequestContext
xunjieli
2014/10/02 17:21:31
I am open to suggestions :) There is probably a be
|
GetNetworkTaskRunner()->PostTask( |
FROM_HERE, |
base::Bind(&URLRequestContextAdapter::InitializeURLRequestContext, |
this, |
- Passed(&config))); |
+ Passed(&config_))); |
} |
void URLRequestContextAdapter::InitializeURLRequestContext( |
@@ -138,8 +152,7 @@ void URLRequestContextAdapter::InitializeURLRequestContext( |
// TODO(mmenke): Add method to have the builder enable SPDY. |
net::URLRequestContextBuilder context_builder; |
context_builder.set_network_delegate(new BasicNetworkDelegate()); |
- context_builder.set_proxy_config_service( |
- new net::ProxyConfigServiceFixed(net::ProxyConfig())); |
+ context_builder.set_proxy_config_service(proxy_config_service_.get()); |
config->ConfigureURLRequestContextBuilder(&context_builder); |
context_.reset(context_builder.Build()); |