| Index: net/proxy/proxy_config_service_linux_unittest.cc
|
| diff --git a/net/proxy/proxy_config_service_linux_unittest.cc b/net/proxy/proxy_config_service_linux_unittest.cc
|
| index a0534c8a126dc2526a16c6cef5fc15867cb3bbdd..8045df4c0d2eefb196ecd2ae782a20b410bec11e 100644
|
| --- a/net/proxy/proxy_config_service_linux_unittest.cc
|
| +++ b/net/proxy/proxy_config_service_linux_unittest.cc
|
| @@ -262,6 +262,7 @@ class SynchConfigGetter {
|
| explicit SynchConfigGetter(net::ProxyConfigServiceLinux* config_service)
|
| : event_(false, false),
|
| io_thread_("IO_Thread"),
|
| + glib_task_runner_(base::MessageLoopProxy::current()),
|
| config_service_(config_service) {
|
| // Start an IO thread.
|
| base::Thread::Options options;
|
| @@ -284,16 +285,18 @@ class SynchConfigGetter {
|
| Wait();
|
| }
|
|
|
| - // Does gconf setup and initial fetch of the proxy config,
|
| - // all on the calling thread (meant to be the thread with the
|
| - // default glib main loop, which is the UI thread).
|
| + // Does gconf setup and initial fetch of the proxy config.
|
| void SetupAndInitialFetch() {
|
| - MessageLoop* file_loop = io_thread_.message_loop();
|
| - DCHECK_EQ(MessageLoop::TYPE_IO, file_loop->type());
|
| - // We pass the mock IO thread as both the IO and file threads.
|
| - config_service_->SetupAndFetchInitialConfig(
|
| - base::MessageLoopProxy::current(), io_thread_.message_loop_proxy(),
|
| - static_cast<MessageLoopForIO*>(file_loop));
|
| + io_thread_.message_loop()->PostTask(FROM_HERE,
|
| + base::Bind(&SynchConfigGetter::SetupAndInitialFetchOnIOThread,
|
| + base::Unretained(this)));
|
| + Wait();
|
| + // ProxyConfigServiceLinux will post back to the UI thread, so let it run
|
| + MessageLoop::current()->RunAllPending();
|
| + // ProxyConfigServiceLinux will post back to the IO thread, so let it run
|
| + io_thread_.message_loop()->PostTask(FROM_HERE,
|
| + base::Bind(&SynchConfigGetter::CleanUp, base::Unretained(this)));
|
| + Wait();
|
| }
|
| // Synchronously gets the proxy config.
|
| net::ProxyConfigService::ConfigAvailability SyncGetLatestProxyConfig(
|
| @@ -320,6 +323,17 @@ class SynchConfigGetter {
|
| event_.Signal();
|
| }
|
|
|
| + void SetupAndInitialFetchOnIOThread() {
|
| + MessageLoop* file_loop = io_thread_.message_loop();
|
| + DCHECK_EQ(MessageLoop::TYPE_IO, file_loop->type());
|
| + DCHECK(io_thread_.message_loop_proxy()->RunsTasksOnCurrentThread());
|
| + // We pass the mock IO thread as both the IO and file threads.
|
| + config_service_->SetupAndFetchInitialConfig(
|
| + glib_task_runner_, io_thread_.message_loop_proxy(),
|
| + static_cast<MessageLoopForIO*>(file_loop));
|
| + event_.Signal();
|
| + }
|
| +
|
| // [Runs on |io_thread_|] Signals |event_| on cleanup completion.
|
| void CleanUp() {
|
| MessageLoop::current()->RunAllPending();
|
| @@ -333,6 +347,7 @@ class SynchConfigGetter {
|
|
|
| base::WaitableEvent event_;
|
| base::Thread io_thread_;
|
| + base::SingleThreadTaskRunner *glib_task_runner_;
|
|
|
| net::ProxyConfigServiceLinux* config_service_;
|
|
|
|
|