OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/proxy/proxy_config_service_linux.h" | 5 #include "net/proxy/proxy_config_service_linux.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
19 #include "base/synchronization/waitable_event.h" | 19 #include "base/synchronization/waitable_event.h" |
| 20 #include "base/thread_task_runner_handle.h" |
20 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
21 #include "net/proxy/proxy_config.h" | 22 #include "net/proxy/proxy_config.h" |
22 #include "net/proxy/proxy_config_service_common_unittest.h" | 23 #include "net/proxy/proxy_config_service_common_unittest.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
24 #include "testing/platform_test.h" | 25 #include "testing/platform_test.h" |
25 | 26 |
26 namespace net { | 27 namespace net { |
27 namespace { | 28 namespace { |
28 | 29 |
29 // Set of values for all environment variables that we might | 30 // Set of values for all environment variables that we might |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 base::Bind(&SynchConfigGetter::CleanUp, base::Unretained(this))); | 281 base::Bind(&SynchConfigGetter::CleanUp, base::Unretained(this))); |
281 Wait(); | 282 Wait(); |
282 } | 283 } |
283 | 284 |
284 // Does gconf setup and initial fetch of the proxy config, | 285 // Does gconf setup and initial fetch of the proxy config, |
285 // all on the calling thread (meant to be the thread with the | 286 // all on the calling thread (meant to be the thread with the |
286 // default glib main loop, which is the UI thread). | 287 // default glib main loop, which is the UI thread). |
287 void SetupAndInitialFetch() { | 288 void SetupAndInitialFetch() { |
288 // We pass the mock IO thread as both the IO and file threads. | 289 // We pass the mock IO thread as both the IO and file threads. |
289 config_service_->SetupAndFetchInitialConfig( | 290 config_service_->SetupAndFetchInitialConfig( |
290 base::MessageLoopProxy::current(), | 291 base::ThreadTaskRunnerHandle::Get(), io_thread_.message_loop_proxy(), |
291 io_thread_.message_loop_proxy(), | |
292 io_thread_.message_loop_proxy()); | 292 io_thread_.message_loop_proxy()); |
293 } | 293 } |
294 // Synchronously gets the proxy config. | 294 // Synchronously gets the proxy config. |
295 ProxyConfigService::ConfigAvailability SyncGetLatestProxyConfig( | 295 ProxyConfigService::ConfigAvailability SyncGetLatestProxyConfig( |
296 ProxyConfig* config) { | 296 ProxyConfig* config) { |
297 io_thread_.message_loop()->PostTask(FROM_HERE, | 297 io_thread_.message_loop()->PostTask(FROM_HERE, |
298 base::Bind(&SynchConfigGetter::GetLatestConfigOnIOThread, | 298 base::Bind(&SynchConfigGetter::GetLatestConfigOnIOThread, |
299 base::Unretained(this))); | 299 base::Unretained(this))); |
300 Wait(); | 300 Wait(); |
301 *config = proxy_config_; | 301 *config = proxy_config_; |
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1603 EXPECT_EQ(ProxyConfigService::CONFIG_VALID, | 1603 EXPECT_EQ(ProxyConfigService::CONFIG_VALID, |
1604 sync_config_getter.SyncGetLatestProxyConfig(&config)); | 1604 sync_config_getter.SyncGetLatestProxyConfig(&config)); |
1605 EXPECT_TRUE(config.auto_detect()); | 1605 EXPECT_TRUE(config.auto_detect()); |
1606 EXPECT_EQ(GURL(), config.pac_url()); | 1606 EXPECT_EQ(GURL(), config.pac_url()); |
1607 } | 1607 } |
1608 } | 1608 } |
1609 | 1609 |
1610 } // namespace | 1610 } // namespace |
1611 | 1611 |
1612 } // namespace net | 1612 } // namespace net |
OLD | NEW |