| Index: net/proxy/proxy_config_service_linux.cc
|
| diff --git a/net/proxy/proxy_config_service_linux.cc b/net/proxy/proxy_config_service_linux.cc
|
| index 1ac2f09b6d9c6f1fe3a122d202c752b7e4b5ba54..af0e4cda060a97a890abbbd3d896786d5d28ac99 100644
|
| --- a/net/proxy/proxy_config_service_linux.cc
|
| +++ b/net/proxy/proxy_config_service_linux.cc
|
| @@ -30,6 +30,7 @@
|
| #include "base/file_util.h"
|
| #include "base/logging.h"
|
| #include "base/message_loop.h"
|
| +#include "base/message_loop_proxy.h"
|
| #include "base/nix/xdg_util.h"
|
| #include "base/string_number_conversions.h"
|
| #include "base/string_tokenizer.h"
|
| @@ -212,7 +213,7 @@ class SettingGetterImplGConf : public ProxyConfigServiceLinux::SettingGetter {
|
| // and pending tasks may then be deleted without being run.
|
| if (client_) {
|
| // gconf client was not cleaned up.
|
| - if (MessageLoop::current() == loop_) {
|
| + if (loop_->BelongsToCurrentThread()) {
|
| // We are on the UI thread so we can clean it safely. This is
|
| // the case at least for ui_tests running under Valgrind in
|
| // bug 16076.
|
| @@ -230,9 +231,9 @@ class SettingGetterImplGConf : public ProxyConfigServiceLinux::SettingGetter {
|
| DCHECK(!client_);
|
| }
|
|
|
| - virtual bool Init(MessageLoop* glib_default_loop,
|
| + virtual bool Init(base::MessageLoopProxy* glib_default_loop,
|
| MessageLoopForIO* file_loop) OVERRIDE {
|
| - DCHECK(MessageLoop::current() == glib_default_loop);
|
| + DCHECK(glib_default_loop->BelongsToCurrentThread());
|
| DCHECK(!client_);
|
| DCHECK(!loop_);
|
| loop_ = glib_default_loop;
|
| @@ -271,7 +272,7 @@ class SettingGetterImplGConf : public ProxyConfigServiceLinux::SettingGetter {
|
|
|
| void ShutDown() {
|
| if (client_) {
|
| - DCHECK(MessageLoop::current() == loop_);
|
| + DCHECK(loop_->BelongsToCurrentThread());
|
| // We must explicitly disable gconf notifications here, because the gconf
|
| // client will be shared between all setting getters, and they do not all
|
| // have the same lifetimes. (For instance, incognito sessions get their
|
| @@ -288,7 +289,7 @@ class SettingGetterImplGConf : public ProxyConfigServiceLinux::SettingGetter {
|
|
|
| bool SetUpNotifications(ProxyConfigServiceLinux::Delegate* delegate) {
|
| DCHECK(client_);
|
| - DCHECK(MessageLoop::current() == loop_);
|
| + DCHECK(loop_->BelongsToCurrentThread());
|
| GError* error = NULL;
|
| notify_delegate_ = delegate;
|
| // We have to keep track of the IDs returned by gconf_client_notify_add() so
|
| @@ -315,7 +316,7 @@ class SettingGetterImplGConf : public ProxyConfigServiceLinux::SettingGetter {
|
| return true;
|
| }
|
|
|
| - virtual MessageLoop* GetNotificationLoop() OVERRIDE {
|
| + virtual base::MessageLoopProxy* GetNotificationLoop() OVERRIDE {
|
| return loop_;
|
| }
|
|
|
| @@ -385,7 +386,7 @@ class SettingGetterImplGConf : public ProxyConfigServiceLinux::SettingGetter {
|
| private:
|
| bool GetStringByPath(const char* key, std::string* result) {
|
| DCHECK(client_);
|
| - DCHECK(MessageLoop::current() == loop_);
|
| + DCHECK(loop_->BelongsToCurrentThread());
|
| GError* error = NULL;
|
| gchar* value = gconf_client_get_string(client_, key, &error);
|
| if (HandleGError(error, key))
|
| @@ -398,7 +399,7 @@ class SettingGetterImplGConf : public ProxyConfigServiceLinux::SettingGetter {
|
| }
|
| bool GetBoolByPath(const char* key, bool* result) {
|
| DCHECK(client_);
|
| - DCHECK(MessageLoop::current() == loop_);
|
| + DCHECK(loop_->BelongsToCurrentThread());
|
| GError* error = NULL;
|
| // We want to distinguish unset values from values defaulting to
|
| // false. For that we need to use the type-generic
|
| @@ -421,7 +422,7 @@ class SettingGetterImplGConf : public ProxyConfigServiceLinux::SettingGetter {
|
| }
|
| bool GetIntByPath(const char* key, int* result) {
|
| DCHECK(client_);
|
| - DCHECK(MessageLoop::current() == loop_);
|
| + DCHECK(loop_->BelongsToCurrentThread());
|
| GError* error = NULL;
|
| int value = gconf_client_get_int(client_, key, &error);
|
| if (HandleGError(error, key))
|
| @@ -433,7 +434,7 @@ class SettingGetterImplGConf : public ProxyConfigServiceLinux::SettingGetter {
|
| }
|
| bool GetStringListByPath(const char* key, std::vector<std::string>* result) {
|
| DCHECK(client_);
|
| - DCHECK(MessageLoop::current() == loop_);
|
| + DCHECK(loop_->BelongsToCurrentThread());
|
| GError* error = NULL;
|
| GSList* list = gconf_client_get_list(client_, key,
|
| GCONF_VALUE_STRING, &error);
|
| @@ -463,7 +464,7 @@ class SettingGetterImplGConf : public ProxyConfigServiceLinux::SettingGetter {
|
|
|
| // This is the callback from the debounce timer.
|
| void OnDebouncedNotification() {
|
| - DCHECK(MessageLoop::current() == loop_);
|
| + DCHECK(loop_->BelongsToCurrentThread());
|
| CHECK(notify_delegate_);
|
| // Forward to a method on the proxy config service delegate object.
|
| notify_delegate_->OnCheckProxyConfigSettings();
|
| @@ -501,7 +502,7 @@ class SettingGetterImplGConf : public ProxyConfigServiceLinux::SettingGetter {
|
| // Message loop of the thread that we make gconf calls on. It should
|
| // be the UI thread and all our methods should be called on this
|
| // thread. Only for assertions.
|
| - MessageLoop* loop_;
|
| + scoped_refptr<base::MessageLoopProxy> loop_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(SettingGetterImplGConf);
|
| };
|
| @@ -541,7 +542,7 @@ class SettingGetterImplGSettings
|
| // without being run.
|
| if (client_) {
|
| // gconf client was not cleaned up.
|
| - if (MessageLoop::current() == loop_) {
|
| + if (loop_->BelongsToCurrentThread()) {
|
| // We are on the UI thread so we can clean it safely. This is
|
| // the case at least for ui_tests running under Valgrind in
|
| // bug 16076.
|
| @@ -574,9 +575,9 @@ class SettingGetterImplGSettings
|
| // LoadAndCheckVersion() must be called *before* Init()!
|
| bool LoadAndCheckVersion(base::Environment* env);
|
|
|
| - virtual bool Init(MessageLoop* glib_default_loop,
|
| + virtual bool Init(base::MessageLoopProxy* glib_default_loop,
|
| MessageLoopForIO* file_loop) OVERRIDE {
|
| - DCHECK(MessageLoop::current() == glib_default_loop);
|
| + DCHECK(glib_default_loop->BelongsToCurrentThread());
|
| DCHECK(!client_);
|
| DCHECK(!loop_);
|
|
|
| @@ -598,7 +599,7 @@ class SettingGetterImplGSettings
|
|
|
| void ShutDown() {
|
| if (client_) {
|
| - DCHECK(MessageLoop::current() == loop_);
|
| + DCHECK(loop_->BelongsToCurrentThread());
|
| // This also disables gsettings notifications.
|
| g_object_unref(socks_client_);
|
| g_object_unref(ftp_client_);
|
| @@ -613,7 +614,7 @@ class SettingGetterImplGSettings
|
|
|
| bool SetUpNotifications(ProxyConfigServiceLinux::Delegate* delegate) {
|
| DCHECK(client_);
|
| - DCHECK(MessageLoop::current() == loop_);
|
| + DCHECK(loop_->BelongsToCurrentThread());
|
| notify_delegate_ = delegate;
|
| // We could watch for the change-event signal instead of changed, but
|
| // since we have to watch more than one object, we'd still have to
|
| @@ -633,7 +634,7 @@ class SettingGetterImplGSettings
|
| return true;
|
| }
|
|
|
| - virtual MessageLoop* GetNotificationLoop() OVERRIDE {
|
| + virtual base::MessageLoopProxy* GetNotificationLoop() OVERRIDE {
|
| return loop_;
|
| }
|
|
|
| @@ -744,7 +745,7 @@ class SettingGetterImplGSettings
|
|
|
| bool GetStringByPath(GSettings* client, const char* key,
|
| std::string* result) {
|
| - DCHECK(MessageLoop::current() == loop_);
|
| + DCHECK(loop_->BelongsToCurrentThread());
|
| gchar* value = g_settings_get_string(client, key);
|
| if (!value)
|
| return false;
|
| @@ -753,18 +754,18 @@ class SettingGetterImplGSettings
|
| return true;
|
| }
|
| bool GetBoolByPath(GSettings* client, const char* key, bool* result) {
|
| - DCHECK(MessageLoop::current() == loop_);
|
| + DCHECK(loop_->BelongsToCurrentThread());
|
| *result = static_cast<bool>(g_settings_get_boolean(client, key));
|
| return true;
|
| }
|
| bool GetIntByPath(GSettings* client, const char* key, int* result) {
|
| - DCHECK(MessageLoop::current() == loop_);
|
| + DCHECK(loop_->BelongsToCurrentThread());
|
| *result = g_settings_get_int(client, key);
|
| return true;
|
| }
|
| bool GetStringListByPath(GSettings* client, const char* key,
|
| std::vector<std::string>* result) {
|
| - DCHECK(MessageLoop::current() == loop_);
|
| + DCHECK(loop_->BelongsToCurrentThread());
|
| gchar** list = g_settings_get_strv(client, key);
|
| if (!list)
|
| return false;
|
| @@ -778,7 +779,7 @@ class SettingGetterImplGSettings
|
|
|
| // This is the callback from the debounce timer.
|
| void OnDebouncedNotification() {
|
| - DCHECK(MessageLoop::current() == loop_);
|
| + DCHECK(loop_->BelongsToCurrentThread());
|
| CHECK(notify_delegate_);
|
| // Forward to a method on the proxy config service delegate object.
|
| notify_delegate_->OnCheckProxyConfigSettings();
|
| @@ -814,7 +815,7 @@ class SettingGetterImplGSettings
|
| // Message loop of the thread that we make gsettings calls on. It should
|
| // be the UI thread and all our methods should be called on this
|
| // thread. Only for assertions.
|
| - MessageLoop* loop_;
|
| + scoped_refptr<base::MessageLoopProxy> loop_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(SettingGetterImplGSettings);
|
| };
|
| @@ -978,7 +979,7 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter,
|
| DCHECK(inotify_fd_ < 0);
|
| }
|
|
|
| - virtual bool Init(MessageLoop* glib_default_loop,
|
| + virtual bool Init(base::MessageLoopProxy* glib_default_loop,
|
| MessageLoopForIO* file_loop) OVERRIDE {
|
| // This has to be called on the UI thread (http://crbug.com/69057).
|
| base::ThreadRestrictions::ScopedAllowIO allow_io;
|
| @@ -1031,8 +1032,8 @@ class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter,
|
| return true;
|
| }
|
|
|
| - virtual MessageLoop* GetNotificationLoop() OVERRIDE {
|
| - return file_loop_;
|
| + virtual base::MessageLoopProxy* GetNotificationLoop() OVERRIDE {
|
| + return file_loop_->message_loop_proxy();
|
| }
|
|
|
| // Implement base::MessagePumpLibevent::Watcher.
|
| @@ -1595,11 +1596,12 @@ ProxyConfigServiceLinux::Delegate::Delegate(
|
| }
|
|
|
| void ProxyConfigServiceLinux::Delegate::SetUpAndFetchInitialConfig(
|
| - MessageLoop* glib_default_loop, MessageLoop* io_loop,
|
| + base::MessageLoopProxy* glib_default_loop,
|
| + base::MessageLoopProxy* io_loop,
|
| MessageLoopForIO* file_loop) {
|
| // We should be running on the default glib main loop thread right
|
| // now. gconf can only be accessed from this thread.
|
| - DCHECK(MessageLoop::current() == glib_default_loop);
|
| + DCHECK(glib_default_loop->BelongsToCurrentThread());
|
| glib_default_loop_ = glib_default_loop;
|
| io_loop_ = io_loop;
|
|
|
| @@ -1648,8 +1650,9 @@ void ProxyConfigServiceLinux::Delegate::SetUpAndFetchInitialConfig(
|
| // fetch and before setting up notifications. We'll detect the common case
|
| // of no changes in OnCheckProxyConfigSettings() (or sooner) and ignore it.
|
| if (io_loop && file_loop) {
|
| - MessageLoop* required_loop = setting_getter_->GetNotificationLoop();
|
| - if (!required_loop || MessageLoop::current() == required_loop) {
|
| + scoped_refptr<base::MessageLoopProxy> required_loop =
|
| + setting_getter_->GetNotificationLoop();
|
| + if (!required_loop || required_loop->BelongsToCurrentThread()) {
|
| // In this case we are already on an acceptable thread.
|
| SetUpNotifications();
|
| } else {
|
| @@ -1675,8 +1678,9 @@ void ProxyConfigServiceLinux::Delegate::SetUpAndFetchInitialConfig(
|
| // Depending on the SettingGetter in use, this method will be called
|
| // on either the UI thread (GConf) or the file thread (KDE).
|
| void ProxyConfigServiceLinux::Delegate::SetUpNotifications() {
|
| - MessageLoop* required_loop = setting_getter_->GetNotificationLoop();
|
| - DCHECK(!required_loop || MessageLoop::current() == required_loop);
|
| + scoped_refptr<base::MessageLoopProxy> required_loop =
|
| + setting_getter_->GetNotificationLoop();
|
| + DCHECK(!required_loop || required_loop->BelongsToCurrentThread());
|
| if (!setting_getter_->SetUpNotifications(this))
|
| LOG(ERROR) << "Unable to set up proxy configuration change notifications";
|
| }
|
| @@ -1693,7 +1697,7 @@ ProxyConfigService::ConfigAvailability
|
| ProxyConfigServiceLinux::Delegate::GetLatestProxyConfig(
|
| ProxyConfig* config) {
|
| // This is called from the IO thread.
|
| - DCHECK(!io_loop_ || MessageLoop::current() == io_loop_);
|
| + DCHECK(!io_loop_ || io_loop_->BelongsToCurrentThread());
|
|
|
| // Simply return the last proxy configuration that glib_default_loop
|
| // notified us of.
|
| @@ -1711,8 +1715,9 @@ ProxyConfigService::ConfigAvailability
|
| // Depending on the SettingGetter in use, this method will be called
|
| // on either the UI thread (GConf) or the file thread (KDE).
|
| void ProxyConfigServiceLinux::Delegate::OnCheckProxyConfigSettings() {
|
| - MessageLoop* required_loop = setting_getter_->GetNotificationLoop();
|
| - DCHECK(!required_loop || MessageLoop::current() == required_loop);
|
| + scoped_refptr<base::MessageLoopProxy> required_loop =
|
| + setting_getter_->GetNotificationLoop();
|
| + DCHECK(!required_loop || required_loop->BelongsToCurrentThread());
|
| ProxyConfig new_config;
|
| bool valid = GetConfigFromSettings(&new_config);
|
| if (valid)
|
| @@ -1735,7 +1740,7 @@ void ProxyConfigServiceLinux::Delegate::OnCheckProxyConfigSettings() {
|
|
|
| void ProxyConfigServiceLinux::Delegate::SetNewProxyConfig(
|
| const ProxyConfig& new_config) {
|
| - DCHECK(MessageLoop::current() == io_loop_);
|
| + DCHECK(io_loop_->BelongsToCurrentThread());
|
| VLOG(1) << "Proxy configuration changed";
|
| cached_config_ = new_config;
|
| FOR_EACH_OBSERVER(
|
| @@ -1746,8 +1751,9 @@ void ProxyConfigServiceLinux::Delegate::SetNewProxyConfig(
|
| void ProxyConfigServiceLinux::Delegate::PostDestroyTask() {
|
| if (!setting_getter_.get())
|
| return;
|
| - MessageLoop* shutdown_loop = setting_getter_->GetNotificationLoop();
|
| - if (!shutdown_loop || MessageLoop::current() == shutdown_loop) {
|
| + scoped_refptr<base::MessageLoopProxy> shutdown_loop =
|
| + setting_getter_->GetNotificationLoop();
|
| + if (!shutdown_loop || shutdown_loop->BelongsToCurrentThread()) {
|
| // Already on the right thread, call directly.
|
| // This is the case for the unittests.
|
| OnDestroy();
|
| @@ -1759,8 +1765,9 @@ void ProxyConfigServiceLinux::Delegate::PostDestroyTask() {
|
| }
|
| }
|
| void ProxyConfigServiceLinux::Delegate::OnDestroy() {
|
| - MessageLoop* shutdown_loop = setting_getter_->GetNotificationLoop();
|
| - DCHECK(!shutdown_loop || MessageLoop::current() == shutdown_loop);
|
| + scoped_refptr<base::MessageLoopProxy> shutdown_loop =
|
| + setting_getter_->GetNotificationLoop();
|
| + DCHECK(!shutdown_loop || shutdown_loop->BelongsToCurrentThread());
|
| setting_getter_->ShutDown();
|
| }
|
|
|
|
|