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 |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 &values.ignore_hosts; | 187 &values.ignore_hosts; |
188 Reset(); | 188 Reset(); |
189 } | 189 } |
190 | 190 |
191 // Zeros all environment values. | 191 // Zeros all environment values. |
192 void Reset() { | 192 void Reset() { |
193 GConfValues zero_values = {0}; | 193 GConfValues zero_values = {0}; |
194 values = zero_values; | 194 values = zero_values; |
195 } | 195 } |
196 | 196 |
197 bool Init(const scoped_refptr<base::SingleThreadTaskRunner>& glib_task_runner, | 197 bool Init(const scoped_refptr<base::SingleThreadTaskRunner>& glib_task_runner) |
198 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner) | |
199 override { | 198 override { |
200 task_runner_ = glib_task_runner; | 199 task_runner_ = glib_task_runner; |
201 return true; | 200 return true; |
202 } | 201 } |
203 | 202 |
204 void ShutDown() override {} | 203 void ShutDown() override {} |
205 | 204 |
206 bool SetUpNotifications( | 205 bool SetUpNotifications( |
207 ProxyConfigServiceLinux::Delegate* delegate) override { | 206 ProxyConfigServiceLinux::Delegate* delegate) override { |
208 return true; | 207 return true; |
209 } | 208 } |
210 | 209 |
211 const scoped_refptr<base::SingleThreadTaskRunner>& GetNotificationTaskRunner() | 210 const scoped_refptr<base::SequencedTaskRunner>& GetNotificationTaskRunner() |
212 override { | 211 override { |
213 return task_runner_; | 212 return task_runner_; |
214 } | 213 } |
215 | 214 |
216 ProxyConfigSource GetConfigSource() override { | 215 ProxyConfigSource GetConfigSource() override { |
217 return PROXY_CONFIG_SOURCE_TEST; | 216 return PROXY_CONFIG_SOURCE_TEST; |
218 } | 217 } |
219 | 218 |
220 bool GetString(StringSetting key, std::string* result) override { | 219 bool GetString(StringSetting key, std::string* result) override { |
221 const char* value = strings_table.Get(key); | 220 const char* value = strings_table.Get(key); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 253 } |
255 | 254 |
256 bool BypassListIsReversed() override { return false; } | 255 bool BypassListIsReversed() override { return false; } |
257 | 256 |
258 bool MatchHostsUsingSuffixMatching() override { return false; } | 257 bool MatchHostsUsingSuffixMatching() override { return false; } |
259 | 258 |
260 // Intentionally public, for convenience when setting up a test. | 259 // Intentionally public, for convenience when setting up a test. |
261 GConfValues values; | 260 GConfValues values; |
262 | 261 |
263 private: | 262 private: |
264 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 263 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
265 SettingsTable<StringSetting, const char*> strings_table; | 264 SettingsTable<StringSetting, const char*> strings_table; |
266 SettingsTable<BoolSetting, BoolSettingValue> bools_table; | 265 SettingsTable<BoolSetting, BoolSettingValue> bools_table; |
267 SettingsTable<IntSetting, int> ints_table; | 266 SettingsTable<IntSetting, int> ints_table; |
268 SettingsTable<StringListSetting, std::vector<std::string>> string_lists_table; | 267 SettingsTable<StringListSetting, std::vector<std::string>> string_lists_table; |
269 }; | 268 }; |
270 | 269 |
271 // This helper class runs ProxyConfigServiceLinux::GetLatestProxyConfig() on | 270 // This helper class runs ProxyConfigServiceLinux::GetLatestProxyConfig() on |
272 // the IO thread and synchronously waits for the result. | 271 // the IO thread and synchronously waits for the result. |
273 // Some code duplicated from proxy_script_fetcher_unittest.cc. | 272 // Some code duplicated from proxy_script_fetcher_unittest.cc. |
274 class SynchConfigGetter : public ProxyConfigService::Observer { | 273 class SynchConfigGetter : public ProxyConfigService::Observer { |
(...skipping 24 matching lines...) Expand all Loading... |
299 io_thread_.task_runner()->PostTask( | 298 io_thread_.task_runner()->PostTask( |
300 FROM_HERE, | 299 FROM_HERE, |
301 base::Bind(&SynchConfigGetter::CleanUp, base::Unretained(this))); | 300 base::Bind(&SynchConfigGetter::CleanUp, base::Unretained(this))); |
302 Wait(); | 301 Wait(); |
303 } | 302 } |
304 | 303 |
305 // Does gconf setup and initial fetch of the proxy config, | 304 // Does gconf setup and initial fetch of the proxy config, |
306 // all on the calling thread (meant to be the thread with the | 305 // all on the calling thread (meant to be the thread with the |
307 // default glib main loop, which is the UI thread). | 306 // default glib main loop, which is the UI thread). |
308 void SetupAndInitialFetch() { | 307 void SetupAndInitialFetch() { |
309 // We pass the mock IO thread as both the IO and file threads. | |
310 config_service_->SetupAndFetchInitialConfig( | 308 config_service_->SetupAndFetchInitialConfig( |
311 base::ThreadTaskRunnerHandle::Get(), io_thread_.task_runner(), | 309 base::ThreadTaskRunnerHandle::Get(), io_thread_.task_runner()); |
312 io_thread_.task_runner()); | |
313 } | 310 } |
314 // Synchronously gets the proxy config. | 311 // Synchronously gets the proxy config. |
315 ProxyConfigService::ConfigAvailability SyncGetLatestProxyConfig( | 312 ProxyConfigService::ConfigAvailability SyncGetLatestProxyConfig( |
316 ProxyConfig* config) { | 313 ProxyConfig* config) { |
317 io_thread_.task_runner()->PostTask( | 314 io_thread_.task_runner()->PostTask( |
318 FROM_HERE, base::Bind(&SynchConfigGetter::GetLatestConfigOnIOThread, | 315 FROM_HERE, base::Bind(&SynchConfigGetter::GetLatestConfigOnIOThread, |
319 base::Unretained(this))); | 316 base::Unretained(this))); |
320 Wait(); | 317 Wait(); |
321 *config = proxy_config_; | 318 *config = proxy_config_; |
322 return get_latest_config_result_; | 319 return get_latest_config_result_; |
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1805 | 1802 |
1806 //----------------------------------------------------- | 1803 //----------------------------------------------------- |
1807 | 1804 |
1808 // TODO(eroman): Add a test where kioslaverc is deleted next. Currently this | 1805 // TODO(eroman): Add a test where kioslaverc is deleted next. Currently this |
1809 // doesn't trigger any notifications, but it probably should. | 1806 // doesn't trigger any notifications, but it probably should. |
1810 } | 1807 } |
1811 | 1808 |
1812 } // namespace | 1809 } // namespace |
1813 | 1810 |
1814 } // namespace net | 1811 } // namespace net |
OLD | NEW |