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

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: Adjust comments 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..58928b58bbf0e3b47ef0b9110d6e998355dd60c3 100644
--- a/net/proxy/proxy_config_service_linux.h
+++ b/net/proxy/proxy_config_service_linux.h
@@ -139,10 +139,9 @@ class NET_EXPORT_PRIVATE ProxyConfigServiceLinux : public ProxyConfigService {
DISALLOW_COPY_AND_ASSIGN(SettingGetter);
};
- // ProxyConfigServiceLinux is created on the UI thread, and
- // SetUpAndFetchInitialConfig() is immediately called to synchronously
- // fetch the original configuration and set up change notifications on
- // the UI thread.
+ // ProxyConfigServiceLinux is created on the IO thread, and begins
+ // asynchronously on the UI thread fetching the original configuration
+ // and setting up change notifications.
//
// Past that point, it is accessed periodically through the
// ProxyConfigService interface (GetLatestProxyConfig, AddObserver,
@@ -155,13 +154,15 @@ class NET_EXPORT_PRIVATE ProxyConfigServiceLinux : public ProxyConfigService {
// Delegate::SetNewProxyConfig(). We then notify observers on the IO
// thread of the configuration change.
//
- // ProxyConfigServiceLinux is deleted from the IO thread.
+ // ProxyConfigServiceLinux is deleted from the IO thread but may require
+ // prior shutdown performed on other threads via StartTearDown().
+ // This prior shutdown safely stops change notifications.
//
// 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 +173,8 @@ 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,
- // 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.
+ // Posts SetUpAndFetchInitialConfigOnUIThread() to UI thread. Called
+ // from the IO thread.
void SetUpAndFetchInitialConfig(
base::SingleThreadTaskRunner* glib_thread_task_runner,
base::SingleThreadTaskRunner* io_thread_task_runner,
@@ -199,7 +194,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::StartTearDown().
void PostDestroyTask();
// Safely stops change notifications. Posted to either the UI or FILE
// thread, depending on the setting getter in use.
@@ -210,6 +206,14 @@ 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.
digit1 2012/10/19 10:32:46 On the other hand, this comment is probably perfec
+ 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 +245,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 +278,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 +289,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 +307,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