diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-24 21:49:43 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-24 21:49:43 +0000 |
commit | 6a1c98e047b636a346481b306ccdb9e59f11f0dd (patch) | |
tree | e08ac0ee0d5f87f72fbc43e863ce71c6d8354472 | |
parent | c38d49cac0dc21bd89ddd08beddb84ca4ba3d60d (diff) | |
download | chromium_src-6a1c98e047b636a346481b306ccdb9e59f11f0dd.zip chromium_src-6a1c98e047b636a346481b306ccdb9e59f11f0dd.tar.gz chromium_src-6a1c98e047b636a346481b306ccdb9e59f11f0dd.tar.bz2 |
Remove BrowserThread dependency from PrefMember.
TBR=ben@chromium.org
BUG=155525
Review URL: https://chromiumcodereview.appspot.com/11189130
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163914 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/api/prefs/pref_member.cc | 27 | ||||
-rw-r--r-- | chrome/browser/api/prefs/pref_member.h | 13 | ||||
-rw-r--r-- | chrome/browser/api/prefs/pref_member_unittest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/browser_process_impl.cc | 3 | ||||
-rw-r--r-- | chrome/browser/chromeos/drive/drive_file_system_util.cc | 1 | ||||
-rw-r--r-- | chrome/browser/file_select_helper.cc | 1 | ||||
-rw-r--r-- | chrome/browser/media/media_stream_devices_controller.cc | 1 | ||||
-rw-r--r-- | chrome/browser/net/chrome_network_delegate.cc | 6 | ||||
-rw-r--r-- | chrome/browser/profiles/avatar_menu_model.cc | 1 | ||||
-rw-r--r-- | chrome/browser/profiles/off_the_record_profile_io_data.cc | 3 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl_io_data.cc | 6 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_io_data.cc | 6 | ||||
-rw-r--r-- | chrome/browser/renderer_host/plugin_info_message_filter.cc | 8 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.mm | 1 | ||||
-rw-r--r-- | chrome/browser/ui/webui/help/help_handler.cc | 1 | ||||
-rw-r--r-- | chrome/browser/ui/webui/set_as_default_browser_ui.cc | 1 |
16 files changed, 52 insertions, 30 deletions
diff --git a/chrome/browser/api/prefs/pref_member.cc b/chrome/browser/api/prefs/pref_member.cc index 35914c0..46f2aa6 100644 --- a/chrome/browser/api/prefs/pref_member.cc +++ b/chrome/browser/api/prefs/pref_member.cc @@ -5,11 +5,12 @@ #include "chrome/browser/api/prefs/pref_member.h" #include "base/bind.h" +#include "base/location.h" #include "base/prefs/public/pref_service_base.h" #include "base/value_conversions.h" #include "chrome/common/chrome_notification_types.h" -using content::BrowserThread; +using base::MessageLoopProxy; namespace subtle { @@ -47,12 +48,13 @@ void PrefMemberBase::Destroy() { } } -void PrefMemberBase::MoveToThread(BrowserThread::ID thread_id) { +void PrefMemberBase::MoveToThread( + const scoped_refptr<MessageLoopProxy>& message_loop) { VerifyValuePrefName(); // Load the value from preferences if it hasn't been loaded so far. if (!internal()) UpdateValueFromPref(); - internal()->MoveToThread(thread_id); + internal()->MoveToThread(message_loop); } void PrefMemberBase::Observe(int type, @@ -84,16 +86,14 @@ void PrefMemberBase::VerifyPref() const { } PrefMemberBase::Internal::Internal() - : thread_id_(BrowserThread::UI), + : thread_loop_(MessageLoopProxy::current()), is_managed_(false) { } PrefMemberBase::Internal::~Internal() { } bool PrefMemberBase::Internal::IsOnCorrectThread() const { - // In unit tests, there may not be a UI thread. - return (BrowserThread::CurrentlyOn(thread_id_) || - (thread_id_ == BrowserThread::UI && - !BrowserThread::IsMessageLoopValid(BrowserThread::UI))); + // In unit tests, there may not be a message loop. + return thread_loop_ == NULL || thread_loop_->BelongsToCurrentThread(); } void PrefMemberBase::Internal::UpdateValue(Value* v, @@ -106,17 +106,18 @@ void PrefMemberBase::Internal::UpdateValue(Value* v, is_managed_ = is_managed; is_user_modifiable_ = is_user_modifiable; } else { - bool rv = BrowserThread::PostTask( - thread_id_, FROM_HERE, + bool may_run = thread_loop_->PostTask( + FROM_HERE, base::Bind(&PrefMemberBase::Internal::UpdateValue, this, value.release(), is_managed, is_user_modifiable)); - DCHECK(rv); + DCHECK(may_run); } } -void PrefMemberBase::Internal::MoveToThread(BrowserThread::ID thread_id) { +void PrefMemberBase::Internal::MoveToThread( + const scoped_refptr<MessageLoopProxy>& message_loop) { CheckOnCorrectThread(); - thread_id_ = thread_id; + thread_loop_ = message_loop; } bool PrefMemberVectorStringUpdate(const Value& value, diff --git a/chrome/browser/api/prefs/pref_member.h b/chrome/browser/api/prefs/pref_member.h index 204fbcd..f7618f9 100644 --- a/chrome/browser/api/prefs/pref_member.h +++ b/chrome/browser/api/prefs/pref_member.h @@ -31,8 +31,8 @@ #include "base/file_path.h" #include "base/logging.h" #include "base/memory/ref_counted.h" +#include "base/message_loop_proxy.h" #include "base/values.h" -#include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_observer.h" class PrefServiceBase; @@ -52,7 +52,8 @@ class PrefMemberBase : public content::NotificationObserver { bool is_managed, bool is_user_modifiable) const; - void MoveToThread(content::BrowserThread::ID thread_id); + void MoveToThread( + const scoped_refptr<base::MessageLoopProxy>& message_loop); // See PrefMember<> for description. bool IsManaged() const { @@ -78,7 +79,7 @@ class PrefMemberBase : public content::NotificationObserver { bool IsOnCorrectThread() const; - content::BrowserThread::ID thread_id_; + scoped_refptr<base::MessageLoopProxy> thread_loop_; mutable bool is_managed_; mutable bool is_user_modifiable_; @@ -97,7 +98,7 @@ class PrefMemberBase : public content::NotificationObserver { // See PrefMember<> for description. void Destroy(); - void MoveToThread(content::BrowserThread::ID thread_id); + void MoveToThread(const scoped_refptr<base::MessageLoopProxy>& message_loop); // content::NotificationObserver virtual void Observe(int type, @@ -168,8 +169,8 @@ class PrefMember : public subtle::PrefMemberBase { // via PostTask. // This method should only be used from the thread the PrefMember is currently // on, which is the UI thread by default. - void MoveToThread(content::BrowserThread::ID thread_id) { - subtle::PrefMemberBase::MoveToThread(thread_id); + void MoveToThread(const scoped_refptr<base::MessageLoopProxy>& message_loop) { + subtle::PrefMemberBase::MoveToThread(message_loop); } // Check whether the pref is managed, i.e. controlled externally through diff --git a/chrome/browser/api/prefs/pref_member_unittest.cc b/chrome/browser/api/prefs/pref_member_unittest.cc index 157b5b8..a24e5e4 100644 --- a/chrome/browser/api/prefs/pref_member_unittest.cc +++ b/chrome/browser/api/prefs/pref_member_unittest.cc @@ -43,7 +43,8 @@ class GetPrefValueCallback void Init(const char* pref_name, PrefService* prefs) { pref_.Init(pref_name, prefs, NULL); - pref_.MoveToThread(BrowserThread::IO); + pref_.MoveToThread( + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); } bool FetchValue() { diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index c42592d..d28013b 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -733,7 +733,8 @@ void BrowserProcessImpl::CreateLocalState() { plugin_finder_disabled_pref_.reset(new BooleanPrefMember); plugin_finder_disabled_pref_->Init(prefs::kDisablePluginFinder, local_state_.get(), NULL); - plugin_finder_disabled_pref_->MoveToThread(BrowserThread::IO); + plugin_finder_disabled_pref_->MoveToThread( + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); // Another policy that needs to be defined before the net subsystem is // initialized is MaxConnectionsPerProxy so we do it here. diff --git a/chrome/browser/chromeos/drive/drive_file_system_util.cc b/chrome/browser/chromeos/drive/drive_file_system_util.cc index 3864d7b..bb4d6db 100644 --- a/chrome/browser/chromeos/drive/drive_file_system_util.cc +++ b/chrome/browser/chromeos/drive/drive_file_system_util.cc @@ -29,6 +29,7 @@ #include "chrome/common/chrome_version_info.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" +#include "content/public/browser/browser_thread.h" #include "net/base/escape.h" #include "net/base/network_change_notifier.h" diff --git a/chrome/browser/file_select_helper.cc b/chrome/browser/file_select_helper.cc index ee1f3d3..8b66e52 100644 --- a/chrome/browser/file_select_helper.cc +++ b/chrome/browser/file_select_helper.cc @@ -17,6 +17,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/chrome_select_file_policy.h" +#include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" diff --git a/chrome/browser/media/media_stream_devices_controller.cc b/chrome/browser/media/media_stream_devices_controller.cc index 5e793bb0..078d103 100644 --- a/chrome/browser/media/media_stream_devices_controller.cc +++ b/chrome/browser/media/media_stream_devices_controller.cc @@ -12,6 +12,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/common/content_settings.h" #include "chrome/common/pref_names.h" +#include "content/public/browser/browser_thread.h" #include "content/public/common/media_stream_request.h" using content::BrowserThread; diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc index fa084a2..0c406d3 100644 --- a/chrome/browser/net/chrome_network_delegate.cc +++ b/chrome/browser/net/chrome_network_delegate.cc @@ -176,10 +176,12 @@ void ChromeNetworkDelegate::InitializePrefsOnUIThread( PrefService* pref_service) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); enable_referrers->Init(prefs::kEnableReferrers, pref_service, NULL); - enable_referrers->MoveToThread(BrowserThread::IO); + enable_referrers->MoveToThread( + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); if (enable_do_not_track) { enable_do_not_track->Init(prefs::kEnableDoNotTrack, pref_service, NULL); - enable_do_not_track->MoveToThread(BrowserThread::IO); + enable_do_not_track->MoveToThread( + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); } } diff --git a/chrome/browser/profiles/avatar_menu_model.cc b/chrome/browser/profiles/avatar_menu_model.cc index fdec4a3..570cd05 100644 --- a/chrome/browser/profiles/avatar_menu_model.cc +++ b/chrome/browser/profiles/avatar_menu_model.cc @@ -22,6 +22,7 @@ #include "chrome/browser/ui/startup/startup_browser_creator.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/url_constants.h" +#include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.cc b/chrome/browser/profiles/off_the_record_profile_io_data.cc index 6cadb70..10bf3dc 100644 --- a/chrome/browser/profiles/off_the_record_profile_io_data.cc +++ b/chrome/browser/profiles/off_the_record_profile_io_data.cc @@ -150,7 +150,8 @@ void OffTheRecordProfileIOData::Handle::LazyInitialize() const { #if defined(ENABLE_SAFE_BROWSING) io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, profile_->GetPrefs(), NULL); - io_data_->safe_browsing_enabled()->MoveToThread(BrowserThread::IO); + io_data_->safe_browsing_enabled()->MoveToThread( + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); #endif io_data_->InitializeOnUIThread(profile_); } diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc index faba353..cb53409 100644 --- a/chrome/browser/profiles/profile_impl_io_data.cc +++ b/chrome/browser/profiles/profile_impl_io_data.cc @@ -282,11 +282,13 @@ void ProfileImplIOData::Handle::LazyInitialize() const { new chrome_browser_net::HttpServerPropertiesManager(pref_service)); io_data_->session_startup_pref()->Init( prefs::kRestoreOnStartup, pref_service, NULL); - io_data_->session_startup_pref()->MoveToThread(BrowserThread::IO); + io_data_->session_startup_pref()->MoveToThread( + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); #if defined(ENABLE_SAFE_BROWSING) io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, pref_service, NULL); - io_data_->safe_browsing_enabled()->MoveToThread(BrowserThread::IO); + io_data_->safe_browsing_enabled()->MoveToThread( + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); #endif io_data_->InitializeOnUIThread(profile_); } diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index 78153f5..ec6336f 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -200,7 +200,8 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) { #if defined(ENABLE_PRINTING) printing_enabled_.Init(prefs::kPrintingEnabled, pref_service, NULL); - printing_enabled_.MoveToThread(BrowserThread::IO); + printing_enabled_.MoveToThread( + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); #endif // The URLBlacklistManager has to be created on the UI thread to register @@ -433,7 +434,8 @@ void ProfileIOData::InitializeMetricsEnabledStateOnUIThread() { enable_metrics_.Init(prefs::kMetricsReportingEnabled, g_browser_process->local_state(), NULL); - enable_metrics_.MoveToThread(BrowserThread::IO); + enable_metrics_.MoveToThread( + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); #endif // defined(OS_CHROMEOS) } diff --git a/chrome/browser/renderer_host/plugin_info_message_filter.cc b/chrome/browser/renderer_host/plugin_info_message_filter.cc index 3054e49..5467a06 100644 --- a/chrome/browser/renderer_host/plugin_info_message_filter.cc +++ b/chrome/browser/renderer_host/plugin_info_message_filter.cc @@ -34,10 +34,14 @@ PluginInfoMessageFilter::Context::Context(int render_process_id, host_content_settings_map_(profile->GetHostContentSettingsMap()) { allow_outdated_plugins_.Init(prefs::kPluginsAllowOutdated, profile->GetPrefs(), NULL); - allow_outdated_plugins_.MoveToThread(content::BrowserThread::IO); + allow_outdated_plugins_.MoveToThread( + content::BrowserThread::GetMessageLoopProxyForThread( + content::BrowserThread::IO)); always_authorize_plugins_.Init(prefs::kPluginsAlwaysAuthorize, profile->GetPrefs(), NULL); - always_authorize_plugins_.MoveToThread(content::BrowserThread::IO); + always_authorize_plugins_.MoveToThread( + content::BrowserThread::GetMessageLoopProxyForThread( + content::BrowserThread::IO)); } PluginInfoMessageFilter::Context::Context() diff --git a/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.mm b/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.mm index 86df346..4da6d27 100644 --- a/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.mm +++ b/chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.mm @@ -4,6 +4,7 @@ #import "chrome/browser/ui/cocoa/extensions/extension_install_dialog_controller.h" +#include "base/bind.h" #include "base/message_loop.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" diff --git a/chrome/browser/ui/webui/help/help_handler.cc b/chrome/browser/ui/webui/help/help_handler.cc index 0d24f59..f120545 100644 --- a/chrome/browser/ui/webui/help/help_handler.cc +++ b/chrome/browser/ui/webui/help/help_handler.cc @@ -23,6 +23,7 @@ #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_version_info.h" #include "chrome/common/url_constants.h" +#include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/web_ui.h" #include "content/public/common/content_client.h" diff --git a/chrome/browser/ui/webui/set_as_default_browser_ui.cc b/chrome/browser/ui/webui/set_as_default_browser_ui.cc index 6e45921..0222cca 100644 --- a/chrome/browser/ui/webui/set_as_default_browser_ui.cc +++ b/chrome/browser/ui/webui/set_as_default_browser_ui.cc @@ -27,6 +27,7 @@ #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "chrome/installer/util/install_util.h" +#include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/web_contents_view.h" |