Chromium Code Reviews| Index: chrome/browser/chromeos/proxy_config_service_impl.h |
| diff --git a/chrome/browser/chromeos/proxy_config_service_impl.h b/chrome/browser/chromeos/proxy_config_service_impl.h |
| index 44a51662723a890effb5fcc651c2c389cf83b1a9..0bedbb6832350b26b74ab1687cd0aa056fb5ea18 100644 |
| --- a/chrome/browser/chromeos/proxy_config_service_impl.h |
| +++ b/chrome/browser/chromeos/proxy_config_service_impl.h |
| @@ -19,23 +19,19 @@ |
| #include "net/proxy/proxy_config_service.h" |
| #include "net/proxy/proxy_server.h" |
| +class PrefService; |
| + |
| namespace chromeos { |
| // Implementation of proxy config service for chromeos that: |
| -// - is RefCountedThreadSafe |
| -// - is wrapped by chromeos::ProxyConfigService which implements |
| -// net::ProxyConfigService interface by fowarding the methods to this class |
| // - retrieves initial system proxy configuration from cros settings persisted |
| // on chromeos device |
| -// - provides network stack with latest system proxy configuration for use on |
| -// IO thread |
| // - provides UI with methods to retrieve and modify system proxy configuration |
| // on UI thread |
| // - TODO(kuan): persists proxy configuration settings on chromeos device using |
| // cros settings |
| class ProxyConfigServiceImpl |
|
battre
2011/02/22 10:32:40
should this be called ProxyConfigService now?
Mattias Nissler (ping if slow)
2011/02/22 11:08:02
We could change the name. Maybe ChromeOSProxyConfi
|
| - : public base::RefCountedThreadSafe<ProxyConfigServiceImpl>, |
| - public SignedSettings::Delegate<bool>, |
| + : public SignedSettings::Delegate<bool>, |
| public SignedSettings::Delegate<std::string> { |
| public: |
| // ProxyConfigServiceImpl is created on the UI thread in |
| @@ -43,12 +39,6 @@ class ProxyConfigServiceImpl |
| // via ProfileImpl::GetChromeOSProxyConfigServiceImpl, and stored in Profile |
| // as a scoped_refptr (because it's RefCountedThreadSafe). |
|
battre
2011/02/22 10:32:40
ProxyConfigServiceImpl is not RefCountedThreadSafe
Mattias Nissler (ping if slow)
2011/02/22 11:08:02
Done.
|
| // |
| - // Past that point, it can be accessed from the IO or UI threads. |
| - // |
| - // From the IO thread, it is accessed periodically through the wrapper class |
| - // chromeos::ProxyConfigService via net::ProxyConfigService interface |
| - // (GetLatestProxyConfig, AddObserver, RemoveObserver). |
| - // |
| // From the UI thread, it is accessed via |
| // WebUI::GetProfile::GetChromeOSProxyConfigServiceImpl to allow user to read |
| // or modify the proxy configuration via UIGetProxyConfig or |
| @@ -113,8 +103,9 @@ class ProxyConfigServiceImpl |
| ProxyConfig() : mode(MODE_DIRECT) {} |
| - // Converts |this| to net::ProxyConfig. |
| - void ToNetProxyConfig(net::ProxyConfig* net_config); |
| + // Converts |this| to a proxy config dictionary understood by the pref |
| + // system. Ownership is transferred to the caller |
|
battre
2011/02/22 10:32:40
nit: . at the end.
Mattias Nissler (ping if slow)
2011/02/22 11:08:02
Done.
|
| + DictionaryValue* ToProxyConfigDictionary() const; |
| // Returns true if proxy config can be written by user. |
| // If mode is MODE_PROXY_PER_SCHEME, |scheme| is one of "http", "https", |
| @@ -157,28 +148,30 @@ class ProxyConfigServiceImpl |
| // Encodes |manual_proxy| and adds it as value into |key_name| of |dict|. |
| void EncodeManualProxy(const ManualProxy& manual_proxy, |
| DictionaryValue* dict, const char* key_name); |
| + |
| // Decodes value of |key_name| in |dict| into |manual_proxy| with |scheme|; |
| // if |ok_if_absent| is true, function returns true if |key_name| doesn't |
| // exist in |dict|. |
| bool DecodeManualProxy(DictionaryValue* dict, const char* key_name, |
| bool ok_if_absent, net::ProxyServer::Scheme scheme, |
| ManualProxy* manual_proxy); |
| + |
| + // Helper function for building up the manual proxy spec. A declration of |
|
battre
2011/02/22 10:32:40
nit: declaration
Mattias Nissler (ping if slow)
2011/02/22 11:08:02
Done.
|
| + // the form <scheme>=<server> is written to spec. |spec| is in/out, it is |
| + // appended to if it already contains data. |
| + static void FormatProxySpec(std::string* spec, |
| + const std::string& scheme, |
| + const net::ProxyServer& server); |
| }; |
| // Usual constructor. |
| - ProxyConfigServiceImpl(); |
| + explicit ProxyConfigServiceImpl(PrefService* local_state); |
| // Constructor for testing. |
| // |init_config| specifies the ProxyConfig to use for initialization. |
| - explicit ProxyConfigServiceImpl(const ProxyConfig& init_config); |
| + ProxyConfigServiceImpl(PrefService* local_state, |
| + const ProxyConfig& init_config); |
| virtual ~ProxyConfigServiceImpl(); |
| - // Methods called on IO thread from wrapper class chromeos::ProxyConfigService |
| - // as ProxyConfigService methods. |
| - void AddObserver(net::ProxyConfigService::Observer* observer); |
| - void RemoveObserver(net::ProxyConfigService::Observer* observer); |
| - // Called from GetLatestProxyConfig. |
| - bool IOGetProxyConfig(net::ProxyConfig* config); |
| - |
| // Called from UI thread to retrieve proxy configuration in |config|. |
| void UIGetProxyConfig(ProxyConfig* config); |
| @@ -213,12 +206,8 @@ class ProxyConfigServiceImpl |
| bool value); |
| private: |
| - friend class base::RefCountedThreadSafe<ProxyConfigServiceImpl>; |
| - |
| // Init proxy to default config, i.e. AutoDetect. |
| - // If |post_to_io_thread| is true, a task will be posted to IO thread to |
| - // update |cached_config|. |
| - void InitConfigToDefault(bool post_to_io_thread); |
| + void InitConfigToDefault(); |
| // Persists proxy config to device. |
| void PersistConfigToDevice(); |
| @@ -227,15 +216,6 @@ class ProxyConfigServiceImpl |
| // |update_to_device| is true to persist new proxy config to device. |
| void OnUISetProxyConfig(bool update_to_device); |
| - // Posted from UI thread to IO thread to carry the new config information. |
| - void IOSetProxyConfig(const ProxyConfig& new_config); |
| - |
| - // Checks that method is called on BrowserThread::IO thread. |
| - void CheckCurrentlyOnIOThread(); |
| - |
| - // Checks that method is called on BrowserThread::UI thread. |
| - void CheckCurrentlyOnUIThread(); |
| - |
| // Data members. |
| // True if tasks can be posted, which can only happen if constructor has |
| @@ -252,17 +232,14 @@ class ProxyConfigServiceImpl |
| // True if there's a pending operation to store proxy setting to device. |
| bool persist_to_device_pending_; |
| - // Cached proxy configuration, to be converted to net::ProxyConfig and |
| - // returned by IOGetProxyConfig. |
| - // Initially populated from the UI thread, but afterwards only accessed from |
| - // the IO thread. |
| - ProxyConfig cached_config_; |
| - |
| // Copy of the proxy configuration kept on the UI thread of the last seen |
| // proxy config, so as to avoid posting a call to SetNewProxyConfig when we |
| // are called by UI to set new proxy but the config has not actually changed. |
| ProxyConfig reference_config_; |
| + // The pref service to store the proxy configuration to. |
| + PrefService* local_state_; |
| + |
| // List of observers for changes in proxy config. |
| ObserverList<net::ProxyConfigService::Observer> observers_; |