Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(558)

Unified Diff: net/proxy/proxy_config_service_linux.h

Issue 10912132: Move ProxyConfigService construction onto the IO thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tiny fix for get_server_time Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/proxy/proxy_config_service_linux.h
diff --git a/net/proxy/proxy_config_service_linux.h b/net/proxy/proxy_config_service_linux.h
index 8d46d998c6396b6599a83779dc29f4b3d3914d4d..0601bbce9f8b021de6b4d40ec41961eca0ffc93c 100644
--- a/net/proxy/proxy_config_service_linux.h
+++ b/net/proxy/proxy_config_service_linux.h
@@ -158,10 +158,10 @@ class NET_EXPORT_PRIVATE ProxyConfigServiceLinux : public ProxyConfigService {
// ProxyConfigServiceLinux is deleted from the IO thread.
//
// The substance of the ProxyConfigServiceLinux implementation is
- // wrapped in the Delegate ref counted class. On deleting the
- // ProxyConfigServiceLinux, Delegate::OnDestroy() is posted to either
- // the UI thread (gconf/gsettings) or the file thread (KDE) where change
- // notifications will be safely stopped before releasing Delegate.
+ // wrapped in the Delegate ref counted class. Destruction of the Delegate
+ // is commenced by StartTearDown() which calls Delegate::OnDestroy() on
+ // the UI thread (gconf/gsettings) or posts it to the file thread (KDE) where
+ // change notifications will be safely stopped before releasing Delegate.
class Delegate : public base::RefCountedThreadSafe<Delegate> {
public:
@@ -172,14 +172,13 @@ class NET_EXPORT_PRIVATE ProxyConfigServiceLinux : public ProxyConfigService {
// to use, and takes ownership of them. Used for testing.
Delegate(base::Environment* env_var_getter, SettingGetter* setting_getter);
- // Synchronously obtains the proxy configuration. If gconf,
+ // Asynchronously obtains the proxy configuration. If gconf,
// gsettings, or kioslaverc are used, also enables notifications for
- // setting changes. gconf/gsettings must only be accessed from the
- // thread running the default glib main loop, and so this method
- // must be called from the UI thread. The message loop for the IO
- // thread is specified so that notifications can post tasks to it
- // (and for assertions). The message loop for the file thread is
- // used to read any files needed to determine proxy settings.
+ // setting changes. This method must be called from the IO thread. The
+ // message loop for the IO thread is specified so that notifications
+ // can post tasks to it (and for assertions). The message loop for the
+ // file thread is used to read any files needed to determine proxy
+ // settings.
void SetUpAndFetchInitialConfig(
base::SingleThreadTaskRunner* glib_thread_task_runner,
base::SingleThreadTaskRunner* io_thread_task_runner,
@@ -199,7 +198,8 @@ class NET_EXPORT_PRIVATE ProxyConfigServiceLinux : public ProxyConfigService {
ProxyConfig* config);
// Posts a call to OnDestroy() to the UI or FILE thread, depending on the
- // setting getter in use. Called from ProxyConfigServiceLinux's destructor.
+ // setting getter in use. Called from ProxyConfigServiceLinux's
+ // StartTearDown.
void PostDestroyTask();
// Safely stops change notifications. Posted to either the UI or FILE
// thread, depending on the setting getter in use.
@@ -210,6 +210,17 @@ class NET_EXPORT_PRIVATE ProxyConfigServiceLinux : public ProxyConfigService {
~Delegate();
+ // Synchronously obtains the proxy configuration. If gconf,
+ // gsettings, or kioslaverc are used, also enables notifications for
+ // setting changes. gconf/gsettings must only be accessed from the
+ // thread running the default glib main loop, and so this method
+ // must be called from the UI thread. The message loop for the IO
+ // thread is specified so that notifications can post tasks to it
+ // (and for assertions). The message loop for the file thread is
+ // used to read any files needed to determine proxy settings.
+ void SetUpAndFetchInitialConfigOnUIThread(
+ MessageLoopForIO* file_loop);
+
// Obtains an environment variable's value. Parses a proxy server
// specification from it and puts it in result. Returns true if the
// requested variable is defined and the value valid.
@@ -241,9 +252,11 @@ class NET_EXPORT_PRIVATE ProxyConfigServiceLinux : public ProxyConfigService {
scoped_ptr<base::Environment> env_var_getter_;
scoped_ptr<SettingGetter> setting_getter_;
+ // Has initialization completed and it's safe to read cached_config_.
+ bool finished_initialization_;
+
// Cached proxy configuration, to be returned by
- // GetLatestProxyConfig. Initially populated from the UI thread, but
- // afterwards only accessed from the IO thread.
+ // GetLatestProxyConfig. Only accessed from the IO thread.
ProxyConfig cached_config_;
// A copy kept on the UI thread of the last seen proxy config, so as
@@ -272,7 +285,10 @@ class NET_EXPORT_PRIVATE ProxyConfigServiceLinux : public ProxyConfigService {
// Thin wrapper shell around Delegate.
// Usual constructor
- ProxyConfigServiceLinux();
+ ProxyConfigServiceLinux(
+ base::SingleThreadTaskRunner* glib_thread_task_runner,
+ base::SingleThreadTaskRunner* io_thread_task_runner,
+ MessageLoopForIO* file_loop);
// For testing: take alternate setting and env var getter implementations.
explicit ProxyConfigServiceLinux(base::Environment* env_var_getter);
ProxyConfigServiceLinux(base::Environment* env_var_getter,
@@ -280,6 +296,7 @@ class NET_EXPORT_PRIVATE ProxyConfigServiceLinux : public ProxyConfigService {
virtual ~ProxyConfigServiceLinux();
+ // This is only public for testing.
void SetupAndFetchInitialConfig(
base::SingleThreadTaskRunner* glib_thread_task_runner,
base::SingleThreadTaskRunner* io_thread_task_runner,
@@ -297,7 +314,8 @@ class NET_EXPORT_PRIVATE ProxyConfigServiceLinux : public ProxyConfigService {
virtual void RemoveObserver(Observer* observer) OVERRIDE;
virtual ProxyConfigService::ConfigAvailability GetLatestProxyConfig(
ProxyConfig* config) OVERRIDE;
-
+ // Called from Glib thread.
+ virtual void StartTearDown() OVERRIDE;
private:
scoped_refptr<Delegate> delegate_;

Powered by Google App Engine
This is Rietveld 408576698