diff options
author | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-26 05:55:10 +0000 |
---|---|---|
committer | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-26 05:55:10 +0000 |
commit | ab820df141e6ab45fd8a095d2f57f91df44e6c9c (patch) | |
tree | 20ae83601c4a484cd74c908b62bc9d702ef27996 /chrome/browser | |
parent | 4d9bdfafcd1393385860bc9fe947e0c07719c0f4 (diff) | |
download | chromium_src-ab820df141e6ab45fd8a095d2f57f91df44e6c9c.zip chromium_src-ab820df141e6ab45fd8a095d2f57f91df44e6c9c.tar.gz chromium_src-ab820df141e6ab45fd8a095d2f57f91df44e6c9c.tar.bz2 |
Chrome changes corresponding to my message_loop_type CL.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1363 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
67 files changed, 199 insertions, 122 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_unittest.cc b/chrome/browser/autocomplete/autocomplete_unittest.cc index 22f6399..cadda8d 100644 --- a/chrome/browser/autocomplete/autocomplete_unittest.cc +++ b/chrome/browser/autocomplete/autocomplete_unittest.cc @@ -110,6 +110,7 @@ class AutocompleteProviderTest : public testing::Test, AutocompleteResult result_; private: + MessageLoopForUI message_loop_; scoped_ptr<AutocompleteController> controller_; }; diff --git a/chrome/browser/autocomplete/history_contents_provider_unittest.cc b/chrome/browser/autocomplete/history_contents_provider_unittest.cc index 5ef13b6..ba7985a 100644 --- a/chrome/browser/autocomplete/history_contents_provider_unittest.cc +++ b/chrome/browser/autocomplete/history_contents_provider_unittest.cc @@ -97,6 +97,8 @@ class HistoryContentsProviderTest : public testing::Test, MessageLoop::current()->Quit(); } + MessageLoopForUI message_loop_; + std::wstring history_dir_; scoped_refptr<HistoryContentsProvider> provider_; diff --git a/chrome/browser/autocomplete/history_url_provider_unittest.cc b/chrome/browser/autocomplete/history_url_provider_unittest.cc index 9ef0172..05a696d 100644 --- a/chrome/browser/autocomplete/history_url_provider_unittest.cc +++ b/chrome/browser/autocomplete/history_url_provider_unittest.cc @@ -98,6 +98,7 @@ class HistoryURLProviderTest : public testing::Test, const std::wstring* expected_urls, int num_results); + MessageLoopForUI message_loop_; ACMatches matches_; scoped_ptr<TestingProfile> profile_; HistoryService* history_service_; diff --git a/chrome/browser/back_forward_menu_model_unittest.cc b/chrome/browser/back_forward_menu_model_unittest.cc index 2b57e21..d13e12d 100644 --- a/chrome/browser/back_forward_menu_model_unittest.cc +++ b/chrome/browser/back_forward_menu_model_unittest.cc @@ -121,6 +121,7 @@ class BackFwdMenuModelTest : public testing::Test { } private: + MessageLoopForUI message_loop_; std::wstring test_dir_; std::wstring profile_path_; ProfileManager pm_; diff --git a/chrome/browser/bookmark_bar_context_menu_controller_test.cc b/chrome/browser/bookmark_bar_context_menu_controller_test.cc index 5914e87..4c2cfa4 100644 --- a/chrome/browser/bookmark_bar_context_menu_controller_test.cc +++ b/chrome/browser/bookmark_bar_context_menu_controller_test.cc @@ -30,7 +30,8 @@ class TestingPageNavigator : public PageNavigator { class BookmarkBarContextMenuControllerTest : public testing::Test { public: - BookmarkBarContextMenuControllerTest() : bb_view_(NULL), model_(NULL) { + BookmarkBarContextMenuControllerTest() + : bb_view_(NULL), model_(NULL) { } virtual void SetUp() { @@ -53,6 +54,7 @@ class BookmarkBarContextMenuControllerTest : public testing::Test { } protected: + MessageLoopForUI message_loop_; scoped_ptr<TestingProfile> profile_; BookmarkBarModel* model_; scoped_ptr<BookmarkBarView> bb_view_; diff --git a/chrome/browser/bookmark_bar_model_unittest.cc b/chrome/browser/bookmark_bar_model_unittest.cc index 4e2a78a..809084e 100644 --- a/chrome/browser/bookmark_bar_model_unittest.cc +++ b/chrome/browser/bookmark_bar_model_unittest.cc @@ -525,6 +525,8 @@ class BookmarkBarModelTestWithProfile : public testing::Test, BookmarkBarNode* node) {} virtual void BookmarkNodeFavIconLoaded(BookmarkBarModel* model, BookmarkBarNode* node) {} + + MessageLoopForUI message_loop_; }; // Creates a set of nodes in the bookmark bar model, then recreates the diff --git a/chrome/browser/bookmark_storage.h b/chrome/browser/bookmark_storage.h index 969fa0a..137ccb4 100644 --- a/chrome/browser/bookmark_storage.h +++ b/chrome/browser/bookmark_storage.h @@ -49,7 +49,7 @@ class BookmarkStorage : public base::RefCountedThreadSafe<BookmarkStorage> { void SaveNow();
// Returns the thread the backend is run on.
- Thread* backend_thread() const { return backend_thread_; }
+ base::Thread* backend_thread() const { return backend_thread_; }
// The model. The model is NULL once BookmarkModelDeleted has been invoked.
BookmarkBarModel* model_;
@@ -62,7 +62,7 @@ class BookmarkStorage : public base::RefCountedThreadSafe<BookmarkStorage> { // Thread read/writing is run on. This comes from the profile, and is null
// during testing.
- Thread* backend_thread_;
+ base::Thread* backend_thread_;
DISALLOW_COPY_AND_ASSIGN(BookmarkStorage);
};
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index b3357f0..8555784 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -245,9 +245,11 @@ int BrowserMain(CommandLine &parsed_command_line, int show_command, // TODO(beng, brettw): someday, break this out into sub functions with well // defined roles (e.g. pre/post-profile startup, etc). + MessageLoop main_message_loop(MessageLoop::TYPE_UI); + const char* main_thread_name = "Chrome_BrowserMain"; PlatformThread::SetName(main_thread_name); - MessageLoop::current()->set_thread_name(main_thread_name); + main_message_loop.set_thread_name(main_thread_name); bool already_running = CreateUniqueChromeEvent(); // Make the selection of network stacks early on before any consumers try to @@ -480,7 +482,7 @@ int BrowserMain(CommandLine &parsed_command_line, int show_command, if (BrowserInit::ProcessCommandLine(parsed_command_line, L"", local_state, show_command, true, profile, &result_code)) { - MessageLoop::current()->Run(browser_process->accelerator_handler()); + MessageLoopForUI::current()->Run(browser_process->accelerator_handler()); } if (metrics) diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h index fb3348d..908af1a 100644 --- a/chrome/browser/browser_process.h +++ b/chrome/browser/browser_process.h @@ -26,11 +26,13 @@ class ProfileManager; class RenderProcessHost; class ResourceDispatcherHost; class DebuggerWrapper; -class Thread; class WebAppInstallerService; class SharedEvent; class SuspendController; +namespace base { +class Thread; +} namespace sandbox { class BrokerServices; } @@ -81,16 +83,16 @@ class BrowserProcess { // Returns the thread that we perform I/O coordination on (network requests, // communication with renderers, etc. // NOTE: need to check the return value for NULL. - virtual Thread* io_thread() = 0; + virtual base::Thread* io_thread() = 0; // Returns the thread that we perform random file operations on. For code // that wants to do I/O operations (not network requests or even file: URL // requests), this is the thread to use to avoid blocking the UI thread. // It might be nicer to have a thread pool for this kind of thing. - virtual Thread* file_thread() = 0; + virtual base::Thread* file_thread() = 0; // Returns the thread that is used for database operations such as history. - virtual Thread* db_thread() = 0; + virtual base::Thread* db_thread() = 0; virtual sandbox::BrokerServices* broker_services() = 0; diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index 57c0d71..5c218ca 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -269,8 +269,11 @@ void BrowserProcessImpl::CreateIOThread() { // invoke the io_thread() accessor. PluginService::GetInstance(); - scoped_ptr<Thread> thread(new BrowserProcessSubThread(ChromeThread::IO)); - if (!thread->Start()) + scoped_ptr<base::Thread> thread( + new BrowserProcessSubThread(ChromeThread::IO)); + base::Thread::Options options; + options.message_loop_type = MessageLoop::TYPE_IO; + if (!thread->StartWithOptions(options)) return; io_thread_.swap(thread); } @@ -279,7 +282,8 @@ void BrowserProcessImpl::CreateFileThread() { DCHECK(!created_file_thread_ && file_thread_.get() == NULL); created_file_thread_ = true; - scoped_ptr<Thread> thread(new BrowserProcessSubThread(ChromeThread::FILE)); + scoped_ptr<base::Thread> thread( + new BrowserProcessSubThread(ChromeThread::FILE)); if (!thread->Start()) return; file_thread_.swap(thread); @@ -289,7 +293,8 @@ void BrowserProcessImpl::CreateDBThread() { DCHECK(!created_db_thread_ && db_thread_.get() == NULL); created_db_thread_ = true; - scoped_ptr<Thread> thread(new BrowserProcessSubThread(ChromeThread::DB)); + scoped_ptr<base::Thread> thread( + new BrowserProcessSubThread(ChromeThread::DB)); if (!thread->Start()) return; db_thread_.swap(thread); diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h index 78bbbaa..82f275f 100644 --- a/chrome/browser/browser_process_impl.h +++ b/chrome/browser/browser_process_impl.h @@ -48,21 +48,21 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe { return metrics_service_.get(); } - virtual Thread* io_thread() { + virtual base::Thread* io_thread() { DCHECK(CalledOnValidThread()); if (!created_io_thread_) CreateIOThread(); return io_thread_.get(); } - virtual Thread* file_thread() { + virtual base::Thread* file_thread() { DCHECK(CalledOnValidThread()); if (!created_file_thread_) CreateFileThread(); return file_thread_.get(); } - virtual Thread* db_thread() { + virtual base::Thread* db_thread() { DCHECK(CalledOnValidThread()); if (!created_db_thread_) CreateDBThread(); @@ -212,13 +212,13 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe { scoped_ptr<MetricsService> metrics_service_; bool created_io_thread_; - scoped_ptr<Thread> io_thread_; + scoped_ptr<base::Thread> io_thread_; bool created_file_thread_; - scoped_ptr<Thread> file_thread_; + scoped_ptr<base::Thread> file_thread_; bool created_db_thread_; - scoped_ptr<Thread> db_thread_; + scoped_ptr<base::Thread> db_thread_; bool created_profile_manager_; scoped_ptr<ProfileManager> profile_manager_; diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc index 78bb3b2..25891c9 100644 --- a/chrome/browser/browsing_data_remover.cc +++ b/chrome/browser/browsing_data_remover.cc @@ -107,7 +107,7 @@ void BrowsingDataRemover::Remove(int remove_mask) { if (remove_mask & REMOVE_CACHE) { // Invoke ClearBrowsingDataView::ClearCache on the IO thread. - Thread* thread = g_browser_process->io_thread(); + base::Thread* thread = g_browser_process->io_thread(); if (thread) { waiting_for_clear_cache_ = true; UserMetrics::RecordAction(L"ClearBrowsingData_Cache", profile_); diff --git a/chrome/browser/cache_manager_host_unittest.cc b/chrome/browser/cache_manager_host_unittest.cc index dda5108..e90d3c0 100644 --- a/chrome/browser/cache_manager_host_unittest.cc +++ b/chrome/browser/cache_manager_host_unittest.cc @@ -4,8 +4,8 @@ #include <string> +#include "base/message_loop.h" #include "chrome/browser/cache_manager_host.h" -#include "base/basictypes.h" #include "testing/gtest/include/gtest/gtest.h" #include "webkit/glue/cache_manager.h" @@ -78,6 +78,9 @@ class CacheManagerHostTest : public testing::Test { KEEP_LIVE_WITH_HEADROOM = CacheManagerHost::KEEP_LIVE_WITH_HEADROOM, KEEP_LIVE = CacheManagerHost::KEEP_LIVE, }; + + private: + MessageLoop message_loop_; }; // static diff --git a/chrome/browser/chrome_plugin_host.cc b/chrome/browser/chrome_plugin_host.cc index 634cd5c..f9a54ea 100644 --- a/chrome/browser/chrome_plugin_host.cc +++ b/chrome/browser/chrome_plugin_host.cc @@ -73,9 +73,8 @@ class PluginRequestInterceptor } void RegisterProtocol(const std::string& scheme) { -#ifndef NDEBUG - DCHECK(MessageLoop::current() == message_loop_); -#endif + DCHECK(CalledOnValidThread()); + std::string lower_scheme = StringToLowerASCII(scheme); handled_protocols_.insert(lower_scheme); @@ -90,9 +89,7 @@ class PluginRequestInterceptor // URLRequest::Interceptor virtual URLRequestJob* MaybeIntercept(URLRequest* request) { -#ifndef NDEBUG - DCHECK(MessageLoop::current() == message_loop_); -#endif + DCHECK(CalledOnValidThread()); if (!IsHandledProtocol(request->url().scheme())) return NULL; diff --git a/chrome/browser/chrome_thread.h b/chrome/browser/chrome_thread.h index a8855ea..9a9cd45 100644 --- a/chrome/browser/chrome_thread.h +++ b/chrome/browser/chrome_thread.h @@ -26,7 +26,7 @@ // handling pointers to threads because many of the well-known threads are owned // by the UI thread and can be deallocated without notice. // -class ChromeThread : public Thread { +class ChromeThread : public base::Thread { public: // An enumeration of the well-known threads. enum ID { diff --git a/chrome/browser/download_file.cc b/chrome/browser/download_file.cc index d025377..a7f796e 100644 --- a/chrome/browser/download_file.cc +++ b/chrome/browser/download_file.cc @@ -415,7 +415,7 @@ void DownloadFileManager::DownloadUrl(const GURL& url, int render_view_id, URLRequestContext* request_context) { DCHECK(MessageLoop::current() == ui_loop_); - Thread* thread = g_browser_process->io_thread(); + base::Thread* thread = g_browser_process->io_thread(); if (thread) { thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(this, diff --git a/chrome/browser/download_manager.cc b/chrome/browser/download_manager.cc index 94a9db0..aef9b14 100644 --- a/chrome/browser/download_manager.cc +++ b/chrome/browser/download_manager.cc @@ -668,7 +668,7 @@ void DownloadManager::DownloadFinished(int32 download_id, int64 size) { void DownloadManager::CancelDownloadRequest(int render_process_id, int request_id) { ResourceDispatcherHost* rdh = g_browser_process->resource_dispatcher_host(); - Thread* io_thread = g_browser_process->io_thread(); + base::Thread* io_thread = g_browser_process->io_thread(); if (!io_thread || !rdh) return; io_thread->message_loop()->PostTask(FROM_HERE, @@ -717,7 +717,7 @@ void DownloadManager::PauseDownload(int32 download_id, bool pause) { return; // Inform the ResourceDispatcherHost of the new pause state. - Thread* io_thread = g_browser_process->io_thread(); + base::Thread* io_thread = g_browser_process->io_thread(); ResourceDispatcherHost* rdh = g_browser_process->resource_dispatcher_host(); if (!io_thread || !rdh) return; diff --git a/chrome/browser/download_manager.h b/chrome/browser/download_manager.h index b05b26d..89773fe 100644 --- a/chrome/browser/download_manager.h +++ b/chrome/browser/download_manager.h @@ -60,11 +60,13 @@ class PrefService; class Profile; class ResourceDispatcherHost; class Task; -class Thread; class Timer; class URLRequestContext; class WebContents; +namespace base { +class Thread; +} // DownloadItem ---------------------------------------------------------------- diff --git a/chrome/browser/first_run.cc b/chrome/browser/first_run.cc index d06d365..097ec77 100644 --- a/chrome/browser/first_run.cc +++ b/chrome/browser/first_run.cc @@ -164,7 +164,7 @@ void OpenFirstRunDialog(Profile* profile) { // is closed) so that the window can receive messages and we block the // browser window from showing up. We pass the accelerator handler here so // that keyboard accelerators (Enter, Esc, etc) work in the dialog box. - MessageLoop::current()->Run(g_browser_process->accelerator_handler()); + MessageLoopForUI::current()->Run(g_browser_process->accelerator_handler()); } namespace { diff --git a/chrome/browser/history/expire_history_backend_unittest.cc b/chrome/browser/history/expire_history_backend_unittest.cc index 1a892d6..fba70eb 100644 --- a/chrome/browser/history/expire_history_backend_unittest.cc +++ b/chrome/browser/history/expire_history_backend_unittest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/basictypes.h" +#include "base/compiler_specific.h" #include "base/file_util.h" #include "base/path_service.h" #include "base/scoped_ptr.h" @@ -27,8 +28,8 @@ namespace history { class ExpireHistoryTest : public testing::Test, public BroadcastNotificationDelegate { public: -#pragma warning(suppress: 4355) // OK to pass "this" here. - ExpireHistoryTest() : expirer_(this), now_(Time::Now()) { + ExpireHistoryTest() + : ALLOW_THIS_IN_INITIALIZER_LIST(expirer_(this)), now_(Time::Now()) { } protected: @@ -56,6 +57,8 @@ class ExpireHistoryTest : public testing::Test, static bool IsStringInFile(std::wstring& filename, const char* str); + MessageLoop message_loop_; + ExpireHistoryBackend expirer_; scoped_ptr<HistoryDatabase> main_db_; diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc index b664f9b..baf5f0e 100644 --- a/chrome/browser/history/history_backend_unittest.cc +++ b/chrome/browser/history/history_backend_unittest.cc @@ -98,6 +98,7 @@ class HistoryBackendTest : public testing::Test { delete details; } + MessageLoop message_loop_; std::wstring test_dir_; }; diff --git a/chrome/browser/history/history_querying_unittest.cc b/chrome/browser/history/history_querying_unittest.cc index 6189044..c62fc40 100644 --- a/chrome/browser/history/history_querying_unittest.cc +++ b/chrome/browser/history/history_querying_unittest.cc @@ -124,6 +124,8 @@ class HistoryQueryTest : public testing::Test { MessageLoop::current()->Quit(); // Will return out to QueryHistory. } + MessageLoop message_loop_; + std::wstring history_dir_; CancelableRequestConsumer consumer_; diff --git a/chrome/browser/history/history_unittest.cc b/chrome/browser/history/history_unittest.cc index e589f11..29f674e 100644 --- a/chrome/browser/history/history_unittest.cc +++ b/chrome/browser/history/history_unittest.cc @@ -240,6 +240,8 @@ class HistoryTest : public testing::Test { saved_redirects_.clear(); MessageLoop::current()->Quit(); } + + MessageLoopForUI message_loop_; // PageUsageData vector to test segments. ScopedVector<PageUsageData> page_usage_data_; diff --git a/chrome/browser/history/text_database_manager_unittest.cc b/chrome/browser/history/text_database_manager_unittest.cc index 5ad7cdf..8b7c6b9 100644 --- a/chrome/browser/history/text_database_manager_unittest.cc +++ b/chrome/browser/history/text_database_manager_unittest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/file_util.h" +#include "base/message_loop.h" #include "chrome/browser/history/text_database_manager.h" #include "testing/gtest/include/gtest/gtest.h" @@ -44,6 +45,8 @@ class TextDatabaseManagerTest : public testing::Test { void TearDown() { file_util::Delete(dir_, true); } + + MessageLoop message_loop_; // Directory containing the databases. std::wstring dir_; diff --git a/chrome/browser/importer_unittest.cc b/chrome/browser/importer_unittest.cc index 2470513..5dde26c 100644 --- a/chrome/browser/importer_unittest.cc +++ b/chrome/browser/importer_unittest.cc @@ -45,6 +45,7 @@ class ImporterTest : public testing::Test { ASSERT_FALSE(file_util::PathExists(test_path_)); } + MessageLoopForUI message_loop_; std::wstring test_path_; std::wstring profile_path_; std::wstring app_path_; diff --git a/chrome/browser/jankometer.cc b/chrome/browser/jankometer.cc index 8ee411e..495b849 100644 --- a/chrome/browser/jankometer.cc +++ b/chrome/browser/jankometer.cc @@ -73,7 +73,7 @@ class JankWatchdog : public Watchdog { //------------------------------------------------------------------------------ class JankObserver : public base::RefCountedThreadSafe<JankObserver>, - public MessageLoop::Observer { + public MessageLoopForUI::Observer { public: JankObserver(const wchar_t* thread_name, const TimeDelta& excessive_duration, @@ -95,12 +95,15 @@ class JankObserver : public base::RefCountedThreadSafe<JankObserver>, // attach to the current thread, so this function can be invoked on another // thread to attach it. void AttachToCurrentThread() { - MessageLoop::current()->AddObserver(this); + // TODO(darin): support monitoring jankiness on non-UI threads! + if (MessageLoop::current()->type() == MessageLoop::TYPE_UI) + MessageLoopForUI::current()->AddObserver(this); } // Detaches the observer to the current thread's message loop. void DetachFromCurrentThread() { - MessageLoop::current()->RemoveObserver(this); + if (MessageLoop::current()->type() == MessageLoop::TYPE_UI) + MessageLoopForUI::current()->RemoveObserver(this); } void WillProcessMessage(const MSG& msg) { @@ -200,7 +203,7 @@ void InstallJankometer(const CommandLine &parsed_command_line) { TimeDelta::FromMilliseconds(kMaxIOMessageDelayMs), io_watchdog_enabled); io_observer->AddRef(); - Thread* io_thread = g_browser_process->io_thread(); + base::Thread* io_thread = g_browser_process->io_thread(); if (io_thread) { io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(io_observer, diff --git a/chrome/browser/navigation_controller_unittest.cc b/chrome/browser/navigation_controller_unittest.cc index 72d2e5c..fa5e3e4 100644 --- a/chrome/browser/navigation_controller_unittest.cc +++ b/chrome/browser/navigation_controller_unittest.cc @@ -164,6 +164,9 @@ class NavigationControllerTest : public testing::Test, TestContents* contents; Profile* profile; + + private: + MessageLoopForUI message_loop_; }; // NavigationControllerHistoryTest --------------------------------------------- diff --git a/chrome/browser/network_status_view.cc b/chrome/browser/network_status_view.cc index 296d46e..4a0e57c 100644 --- a/chrome/browser/network_status_view.cc +++ b/chrome/browser/network_status_view.cc @@ -156,7 +156,7 @@ NetworkStatusView::JobTracker::JobTracker(NetworkStatusView* view) // main thread: void NetworkStatusView::JobTracker::InvokeOnIOThread(void (JobTracker::*m)()) { - Thread* thread = g_browser_process->io_thread(); + base::Thread* thread = g_browser_process->io_thread(); if (!thread) return; thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(this, m)); diff --git a/chrome/browser/printing/print_job_worker.h b/chrome/browser/printing/print_job_worker.h index 0509a0f..3e25ec5 100644 --- a/chrome/browser/printing/print_job_worker.h +++ b/chrome/browser/printing/print_job_worker.h @@ -23,7 +23,7 @@ class PrintJobWorkerOwner; // NOTIFY_PRINT_JOB_EVENT notifications, but they are generated through a // NotificationTask task to be executed from the right thread, the UI thread. // PrintJob always outlives its worker instance. -class PrintJobWorker : public Thread { +class PrintJobWorker : public base::Thread { public: PrintJobWorker(PrintJobWorkerOwner* owner); ~PrintJobWorker(); diff --git a/chrome/browser/printing/printer_query.h b/chrome/browser/printing/printer_query.h index 0cbffbf..d79ac73 100644 --- a/chrome/browser/printing/printer_query.h +++ b/chrome/browser/printing/printer_query.h @@ -11,7 +11,10 @@ class CancelableTask; class MessageLoop; + +namespace base { class Thread; +} namespace printing { diff --git a/chrome/browser/printing/printing_layout_uitest.cc b/chrome/browser/printing/printing_layout_uitest.cc index 2151824..30e1c75 100644 --- a/chrome/browser/printing/printing_layout_uitest.cc +++ b/chrome/browser/printing/printing_layout_uitest.cc @@ -559,7 +559,8 @@ TEST_F(PrintingLayoutTest, DISABLED_Delayed) { tab_proxy->NavigateToURL(url)); - scoped_ptr<Thread> worker(new Thread("PrintingLayoutTest_worker")); + scoped_ptr<base::Thread> worker( + new base::Thread("PrintingLayoutTest_worker")); DismissTheWindow dismiss_task(process_util::GetProcId(process())); // We need to start the thread to be able to set the timer. worker->Start(); @@ -597,7 +598,8 @@ TEST_F(PrintingLayoutTest, DISABLED_IFrame) { EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab_proxy->NavigateToURL(url)); - scoped_ptr<Thread> worker(new Thread("PrintingLayoutTest_worker")); + scoped_ptr<base::Thread> worker( + new base::Thread("PrintingLayoutTest_worker")); DismissTheWindow dismiss_task(process_util::GetProcId(process())); // We need to start the thread to be able to set the timer. worker->Start(); diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc index 857dd21..e974e2a 100644 --- a/chrome/browser/profile.cc +++ b/chrome/browser/profile.cc @@ -598,7 +598,7 @@ ProfileImpl::~ProfileImpl() { history_service_->Cleanup(); // The I/O thread may be NULL during testing. - Thread* io_thread = g_browser_process->io_thread(); + base::Thread* io_thread = g_browser_process->io_thread(); if (spellchecker_) { // The spellchecker must be deleted on the I/O thread. During testing, we diff --git a/chrome/browser/profile_manager_unittest.cc b/chrome/browser/profile_manager_unittest.cc index bcc844e..8a7ed05 100644 --- a/chrome/browser/profile_manager_unittest.cc +++ b/chrome/browser/profile_manager_unittest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/file_util.h" +#include "base/message_loop.h" #include "base/path_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/profile_manager.h" @@ -29,6 +30,8 @@ protected: ASSERT_TRUE(file_util::Delete(test_dir_, true)); ASSERT_FALSE(file_util::PathExists(test_dir_)); } + + MessageLoopForUI message_loop_; // the path to temporary directory used to contain the test operations std::wstring test_dir_; diff --git a/chrome/browser/render_process_host.cc b/chrome/browser/render_process_host.cc index 0973fec..c18b4f3 100644 --- a/chrome/browser/render_process_host.cc +++ b/chrome/browser/render_process_host.cc @@ -85,10 +85,10 @@ unsigned int GetMaxRendererProcessCount() { // ---------------------------------------------------------------------------- -class RendererMainThread : public Thread { +class RendererMainThread : public base::Thread { public: explicit RendererMainThread(const std::wstring& channel_id) - : Thread("Chrome_InProcRendererThread"), + : base::Thread("Chrome_InProcRendererThread"), channel_id_(channel_id) { } @@ -103,7 +103,7 @@ class RendererMainThread : public Thread { // this thread, so just force the flag manually. // If we want to avoid this, we could create the InProcRendererThread // directly with _beginthreadex() rather than using the Thread class. - Thread::SetThreadWasQuitProperly(true); + base::Thread::SetThreadWasQuitProperly(true); } virtual void CleanUp() { @@ -201,7 +201,7 @@ bool RenderProcessHost::Init() { return true; // run the IPC channel on the shared IO thread. - Thread* io_thread = g_browser_process->io_thread(); + base::Thread* io_thread = g_browser_process->io_thread(); scoped_refptr<ResourceMessageFilter> resource_message_filter = new ResourceMessageFilter(g_browser_process->resource_dispatcher_host(), @@ -306,22 +306,22 @@ bool RenderProcessHost::Init() { bool run_in_process = RenderProcessHost::run_renderer_in_process(); if (run_in_process) { - // Crank up a thread and run the initialization there. With the - // way that messages flow between the browser and renderer, this - // thread is required to prevent a deadlock in single-process mode. - // When using multiple processes, the primordial thread in the - // renderer process has a message loop which is used for sending - // messages asynchronously to the io thread in the browser process. - // If we don't create this thread, then the RenderThread is both - // responsible for rendering and also for communicating IO. - // This can lead to deadlocks where the RenderThread is waiting - // for the IO to complete, while the browsermain is trying to - // pass an event to the RenderThread. + // Crank up a thread and run the initialization there. With the way that + // messages flow between the browser and renderer, this thread is required + // to prevent a deadlock in single-process mode. When using multiple + // processes, the primordial thread in the renderer process has a message + // loop which is used for sending messages asynchronously to the io thread + // in the browser process. If we don't create this thread, then the + // RenderThread is both responsible for rendering and also for + // communicating IO. This can lead to deadlocks where the RenderThread is + // waiting for the IO to complete, while the browsermain is trying to pass + // an event to the RenderThread. // - // TODO: We should consider how to better cleanup threads on - // exit. - Thread *renderThread = new RendererMainThread(channel_id); - renderThread->Start(); + // TODO: We should consider how to better cleanup threads on exit. + base::Thread *render_thread = new RendererMainThread(channel_id); + base::Thread::Options options; + options.message_loop_type = MessageLoop::TYPE_IO; + render_thread->StartWithOptions(options); } else { if (g_browser_process->local_state() && g_browser_process->local_state()->GetBoolean( diff --git a/chrome/browser/render_process_host.h b/chrome/browser/render_process_host.h index 76bdb10..f725544 100644 --- a/chrome/browser/render_process_host.h +++ b/chrome/browser/render_process_host.h @@ -23,9 +23,12 @@ class PrefService; class Profile; class RenderWidgetHelper; -class Thread; class WebContents; +namespace base { +class Thread; +} + // Represents the browser side of the browser <--> renderer communication // channel. There will be one RenderProcessHost per renderer process. // diff --git a/chrome/browser/resource_dispatcher_host_unittest.cc b/chrome/browser/resource_dispatcher_host_unittest.cc index 3291cea..101e9f7 100644 --- a/chrome/browser/resource_dispatcher_host_unittest.cc +++ b/chrome/browser/resource_dispatcher_host_unittest.cc @@ -115,6 +115,7 @@ class ResourceDispatcherHostTest : public testing::Test, } } + MessageLoopForIO message_loop_; ResourceDispatcherHost host_; ResourceIPCAccumulator accum_; }; diff --git a/chrome/browser/resource_message_filter.cc b/chrome/browser/resource_message_filter.cc index 073741c..d349839 100644 --- a/chrome/browser/resource_message_filter.cc +++ b/chrome/browser/resource_message_filter.cc @@ -654,7 +654,7 @@ class SpellCheckTask : public Task { if (checker) checker->SpellCheckWord(word_.c_str(), static_cast<int>(word_.length()), &misspell_location, &misspell_length, NULL); - Thread* io_thread = g_browser_process->io_thread(); + base::Thread* io_thread = g_browser_process->io_thread(); if (io_thread) { io_thread->message_loop()->PostTask(FROM_HERE, new SpellCheckReplyTask(filter_, reply_msg_, diff --git a/chrome/browser/rlz/rlz.cc b/chrome/browser/rlz/rlz.cc index 6cc8d70..b319626 100644 --- a/chrome/browser/rlz/rlz.cc +++ b/chrome/browser/rlz/rlz.cc @@ -168,7 +168,7 @@ class DelayedInitTask : public Task { } } // Schedule the daily RLZ ping. - Thread* thread = g_browser_process->file_thread(); + base::Thread* thread = g_browser_process->file_thread(); if (thread) thread->message_loop()->PostTask(FROM_HERE, new DailyPingTask()); } diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc index a4068fa..eacbf86 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc @@ -325,7 +325,7 @@ void SafeBrowsingBlockingPage::NotifyDone() { tab_->AsWebContents()->set_interstitial_delegate(NULL); } - Thread* io_thread = g_browser_process->io_thread(); + base::Thread* io_thread = g_browser_process->io_thread(); if (!io_thread) return; diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc index a9e526b..11cfad0 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.cc +++ b/chrome/browser/safe_browsing/safe_browsing_service.cc @@ -50,7 +50,7 @@ void SafeBrowsingService::Initialize(MessageLoop* io_loop) { // the user checks the "Enable SafeBrowsing" option in the Advanced options UI. void SafeBrowsingService::Start() { DCHECK(!db_thread_.get()); - db_thread_.reset(new Thread("Chrome_SafeBrowsingThread")); + db_thread_.reset(new base::Thread("Chrome_SafeBrowsingThread")); if (!db_thread_->Start()) return; diff --git a/chrome/browser/safe_browsing/safe_browsing_service.h b/chrome/browser/safe_browsing/safe_browsing_service.h index 1f373e5..fe7d0e7 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.h +++ b/chrome/browser/safe_browsing/safe_browsing_service.h @@ -243,7 +243,7 @@ class SafeBrowsingService bool enabled_; // The SafeBrowsing thread that runs database operations. - scoped_ptr<Thread> db_thread_; + scoped_ptr<base::Thread> db_thread_; // Indicates if we are in the process of resetting the database. bool resetting_; diff --git a/chrome/browser/save_file_manager.cc b/chrome/browser/save_file_manager.cc index 6fb2524..e8537a7 100644 --- a/chrome/browser/save_file_manager.cc +++ b/chrome/browser/save_file_manager.cc @@ -39,7 +39,7 @@ SaveFileManager::SaveFileManager(MessageLoop* ui_loop, // on a non-UI thread can cause crashes during shutdown. DCHECK(ui_loop_ == MessageLoop::current()); // Cache the message loop of file thread. - Thread* thread = g_browser_process->file_thread(); + base::Thread* thread = g_browser_process->file_thread(); if (thread) file_loop_ = thread->message_loop(); else diff --git a/chrome/browser/save_package.h b/chrome/browser/save_package.h index 6ab00fb..29a22b9 100644 --- a/chrome/browser/save_package.h +++ b/chrome/browser/save_package.h @@ -40,11 +40,14 @@ class MessageLoop; class PrefService; class Profile; class WebContents; -class Thread; class URLRequestContext; class WebContents; class Time; +namespace base { +class Thread; +} + // save package: manages all save item. class SavePackage : public base::RefCountedThreadSafe<SavePackage> { public: diff --git a/chrome/browser/session_service.h b/chrome/browser/session_service.h index d1b6e36..3f7548f 100644 --- a/chrome/browser/session_service.h +++ b/chrome/browser/session_service.h @@ -24,11 +24,14 @@ class NavigationController; class NavigationEntry; class Profile; class TabContents; -class Thread; class Timer; class SessionBackend; class SessionCommand; +namespace base { +class Thread; +} + // TabNavigation ------------------------------------------------------------ // TabNavigation corresponds to a NavigationEntry. @@ -551,7 +554,7 @@ class SessionService : public CancelableRequestProvider, // Thread backend tasks are run on. This comes from the profile, and is // null during testing. - Thread* backend_thread_; + base::Thread* backend_thread_; // Are there any open open tabbed browsers? bool has_open_tabbed_browsers_; diff --git a/chrome/browser/site_instance_unittest.cc b/chrome/browser/site_instance_unittest.cc index 12eb0dc..4059fb4 100644 --- a/chrome/browser/site_instance_unittest.cc +++ b/chrome/browser/site_instance_unittest.cc @@ -9,7 +9,12 @@ #include "chrome/test/testing_profile.h" #include "testing/gtest/include/gtest/gtest.h" -typedef testing::Test SiteInstanceTest; +namespace { + +class SiteInstanceTest : public testing::Test { + private: + MessageLoopForUI message_loop_; +}; class TestBrowsingInstance : public BrowsingInstance { public: @@ -55,8 +60,10 @@ class TestSiteInstance : public SiteInstance { int* deleteCounter_; }; +} // namespace + // Test to ensure no memory leaks for SiteInstance objects. -TEST(SiteInstanceTest, SiteInstanceDestructor) { +TEST_F(SiteInstanceTest, SiteInstanceDestructor) { int siteDeleteCounter = 0; int browsingDeleteCounter = 0; const GURL url("test:foo"); @@ -114,7 +121,7 @@ TEST(SiteInstanceTest, SiteInstanceDestructor) { // Test that NavigationEntries with SiteInstances can be cloned, but that their // SiteInstances can be changed afterwards. Also tests that the ref counts are // updated properly after the change. -TEST(SiteInstanceTest, CloneNavigationEntry) { +TEST_F(SiteInstanceTest, CloneNavigationEntry) { int siteDeleteCounter1 = 0; int siteDeleteCounter2 = 0; int browsingDeleteCounter = 0; @@ -153,7 +160,7 @@ TEST(SiteInstanceTest, CloneNavigationEntry) { } // Test to ensure UpdateMaxPageID is working properly. -TEST(SiteInstanceTest, UpdateMaxPageID) { +TEST_F(SiteInstanceTest, UpdateMaxPageID) { scoped_refptr<SiteInstance> instance(SiteInstance::CreateSiteInstance(NULL)); EXPECT_EQ(-1, instance.get()->max_page_id()); @@ -164,7 +171,7 @@ TEST(SiteInstanceTest, UpdateMaxPageID) { } // Test to ensure GetProcess returns and creates processes correctly. -TEST(SiteInstanceTest, GetProcess) { +TEST_F(SiteInstanceTest, GetProcess) { // Ensure that GetProcess returns the process based on its host id. scoped_ptr<TestingProfile> profile(new TestingProfile()); scoped_ptr<RenderProcessHost> host1(new RenderProcessHost(profile.get())); @@ -181,7 +188,7 @@ TEST(SiteInstanceTest, GetProcess) { } // Test to ensure SetSite and site() work properly. -TEST(SiteInstanceTest, SetSite) { +TEST_F(SiteInstanceTest, SetSite) { scoped_refptr<SiteInstance> instance(SiteInstance::CreateSiteInstance(NULL)); EXPECT_FALSE(instance->has_site()); EXPECT_TRUE(instance.get()->site().is_empty()); @@ -193,7 +200,7 @@ TEST(SiteInstanceTest, SetSite) { } // Test to ensure GetSiteForURL properly returns sites for URLs. -TEST(SiteInstanceTest, GetSiteForURL) { +TEST_F(SiteInstanceTest, GetSiteForURL) { GURL test_url = GURL("http://www.google.com/index.html"); EXPECT_EQ(GURL("http://google.com"), SiteInstance::GetSiteForURL(test_url)); @@ -220,7 +227,7 @@ TEST(SiteInstanceTest, GetSiteForURL) { // Test of distinguishing URLs from different sites. Most of this logic is // tested in RegistryControlledDomainTest. This test focuses on URLs with // different schemes or ports. -TEST(SiteInstanceTest, IsSameWebSite) { +TEST_F(SiteInstanceTest, IsSameWebSite) { GURL url_foo = GURL("http://foo/a.html"); GURL url_foo2 = GURL("http://foo/b.html"); GURL url_foo_https = GURL("https://foo/a.html"); @@ -247,7 +254,7 @@ TEST(SiteInstanceTest, IsSameWebSite) { // Test to ensure that there is only one SiteInstance per site in a given // BrowsingInstance, when process-per-site is not in use. -TEST(SiteInstanceTest, OneSiteInstancePerSite) { +TEST_F(SiteInstanceTest, OneSiteInstancePerSite) { int deleteCounter = 0; TestBrowsingInstance* browsing_instance = new TestBrowsingInstance(NULL, &deleteCounter); @@ -305,7 +312,7 @@ TEST(SiteInstanceTest, OneSiteInstancePerSite) { // Test to ensure that there is only one SiteInstance per site for an entire // Profile, if process-per-site is in use. -TEST(SiteInstanceTest, OneSiteInstancePerSiteInProfile) { +TEST_F(SiteInstanceTest, OneSiteInstancePerSiteInProfile) { int deleteCounter = 0; TestBrowsingInstance* browsing_instance = new TestBrowsingInstance(NULL, &deleteCounter); diff --git a/chrome/browser/spellchecker.cc b/chrome/browser/spellchecker.cc index 25109b4..331b342 100644 --- a/chrome/browser/spellchecker.cc +++ b/chrome/browser/spellchecker.cc @@ -164,7 +164,7 @@ class UIProxyForIOTask : public Task { private: void Run() { // This has been invoked in the UI thread. - Thread* io_thread = g_browser_process->io_thread(); + base::Thread* io_thread = g_browser_process->io_thread(); if (io_thread) { // io_thread has not been torn down yet. MessageLoop* io_loop = io_thread->message_loop(); if (io_loop) { @@ -214,7 +214,7 @@ SpellChecker::SpellChecker(const std::wstring& dict_dir, ui_loop_ = MessageLoop::current(); // Get File Loop - hunspell gets initialized here. - Thread* file_thread = g_browser_process->file_thread(); + base::Thread* file_thread = g_browser_process->file_thread(); if (file_thread) file_loop_ = file_thread->message_loop(); diff --git a/chrome/browser/tabs/dragged_tab_controller.cc b/chrome/browser/tabs/dragged_tab_controller.cc index eff01a4..80cbe65 100644 --- a/chrome/browser/tabs/dragged_tab_controller.cc +++ b/chrome/browser/tabs/dragged_tab_controller.cc @@ -96,13 +96,13 @@ DraggedTabController::DraggedTabController(Tab* source_tab, ChangeDraggedContents( source_tabstrip_->model()->GetTabContentsAt(source_model_index_)); // Listen for Esc key presses. - MessageLoop::current()->AddObserver(this); + MessageLoopForUI::current()->AddObserver(this); } DraggedTabController::~DraggedTabController() { in_destructor_ = true; CleanUpSourceTab(); - MessageLoop::current()->RemoveObserver(this); + MessageLoopForUI::current()->RemoveObserver(this); ChangeDraggedContents(NULL); // This removes our observer. } diff --git a/chrome/browser/tabs/dragged_tab_controller.h b/chrome/browser/tabs/dragged_tab_controller.h index 2485cf5..031a6ed 100644 --- a/chrome/browser/tabs/dragged_tab_controller.h +++ b/chrome/browser/tabs/dragged_tab_controller.h @@ -35,7 +35,7 @@ class TabStripModel; /////////////////////////////////////////////////////////////////////////////// class DraggedTabController : public TabContentsDelegate, public NotificationObserver, - public MessageLoop::Observer{ + public MessageLoopForUI::Observer{ public: DraggedTabController(Tab* source_tab, TabStrip* source_tabstrip); virtual ~DraggedTabController(); diff --git a/chrome/browser/tabs/tab_strip.cc b/chrome/browser/tabs/tab_strip.cc index aed87a1..b012443 100644 --- a/chrome/browser/tabs/tab_strip.cc +++ b/chrome/browser/tabs/tab_strip.cc @@ -1195,14 +1195,14 @@ bool TabStrip::IsCursorInTabStripZone() { void TabStrip::AddMessageLoopObserver() { if (!added_as_message_loop_observer_) { - MessageLoop::current()->AddObserver(this); + MessageLoopForUI::current()->AddObserver(this); added_as_message_loop_observer_ = true; } } void TabStrip::RemoveMessageLoopObserver() { if (added_as_message_loop_observer_) { - MessageLoop::current()->RemoveObserver(this); + MessageLoopForUI::current()->RemoveObserver(this); added_as_message_loop_observer_ = false; } } diff --git a/chrome/browser/tabs/tab_strip.h b/chrome/browser/tabs/tab_strip.h index ad14213..930b60b 100644 --- a/chrome/browser/tabs/tab_strip.h +++ b/chrome/browser/tabs/tab_strip.h @@ -41,7 +41,7 @@ class TabStrip : public ChromeViews::View, public Tab::TabDelegate, public ChromeViews::Button::ButtonListener, public Task, - public MessageLoop::Observer { + public MessageLoopForUI::Observer { public: TabStrip(TabStripModel* model); virtual ~TabStrip(); diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc index e572835..9565f67 100644 --- a/chrome/browser/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/tabs/tab_strip_model_unittest.cc @@ -139,6 +139,7 @@ class TabStripModelTest : public testing::Test { Profile* profile_; private: + MessageLoopForUI message_loop_; std::wstring test_dir_; std::wstring profile_path_; ProfileManager pm_; diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc index 6e240e0..b2e9798 100644 --- a/chrome/browser/task_manager.cc +++ b/chrome/browser/task_manager.cc @@ -234,7 +234,7 @@ void TaskManagerTableModel::StartUpdating() { // Register jobs notifications so we can compute network usage (it must be // done from the IO thread). - Thread* thread = g_browser_process->io_thread(); + base::Thread* thread = g_browser_process->io_thread(); if (thread) thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( this, &TaskManagerTableModel::RegisterForJobDoneNotifications)); @@ -260,7 +260,7 @@ void TaskManagerTableModel::StopUpdating() { } // Unregister jobs notification (must be done from the IO thread). - Thread* thread = g_browser_process->io_thread(); + base::Thread* thread = g_browser_process->io_thread(); if (thread) thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( this, &TaskManagerTableModel::UnregisterForJobDoneNotifications)); diff --git a/chrome/browser/template_url_model_unittest.cc b/chrome/browser/template_url_model_unittest.cc index 7491523..d0239df 100644 --- a/chrome/browser/template_url_model_unittest.cc +++ b/chrome/browser/template_url_model_unittest.cc @@ -191,6 +191,7 @@ class TemplateURLModelTest : public testing::Test, TemplateURLRef::google_base_url_ = new std::wstring(base_url); } + MessageLoopForUI message_loop_; scoped_ptr<TemplateURLModelTestingProfile> profile_; scoped_ptr<TestingTemplateURLModel> model_; int changed_count_; diff --git a/chrome/browser/url_fetcher_unittest.cc b/chrome/browser/url_fetcher_unittest.cc index aa6cb54..5ffe231 100644 --- a/chrome/browser/url_fetcher_unittest.cc +++ b/chrome/browser/url_fetcher_unittest.cc @@ -16,7 +16,7 @@ namespace { class URLFetcherTest : public testing::Test, public URLFetcher::Delegate { public: - URLFetcherTest() : main_loop_(MessageLoop::current()), fetcher_(NULL) { } + URLFetcherTest() : fetcher_(NULL) { } // Creates a URLFetcher, using the program's main thread to do IO. virtual void CreateFetcher(const GURL& url); @@ -30,7 +30,12 @@ namespace { const std::string& data); protected: - MessageLoop* main_loop_; + // URLFetcher is designed to run on the main UI thread, but in our tests + // we assume that the current thread is the IO thread where the URLFetcher + // dispatches its requests to. When we wish to simulate being used from + // a UI thread, we dispatch a worker thread to do so. + MessageLoopForIO io_loop_; + URLFetcher* fetcher_; }; @@ -114,7 +119,7 @@ namespace { void URLFetcherTest::CreateFetcher(const GURL& url) { fetcher_ = new URLFetcher(url, URLFetcher::GET, this); fetcher_->set_request_context(new TestURLRequestContext()); - fetcher_->set_io_loop(main_loop_); + fetcher_->set_io_loop(&io_loop_); fetcher_->Start(); } @@ -132,8 +137,8 @@ namespace { // because the destructor won't necessarily run on the // same thread that CreateFetcher() did. - main_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask()); - // If MessageLoop::current() != main_loop_, it will be shut down when the + io_loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask()); + // If MessageLoop::current() != io_loop_, it will be shut down when the // main loop returns and this thread subsequently goes out of scope. } @@ -145,7 +150,7 @@ namespace { void URLFetcherPostTest::CreateFetcher(const GURL& url) { fetcher_ = new URLFetcher(url, URLFetcher::POST, this); fetcher_->set_request_context(new TestURLRequestContext()); - fetcher_->set_io_loop(main_loop_); + fetcher_->set_io_loop(&io_loop_); fetcher_->set_upload_data("application/x-www-form-urlencoded", "bobsyeruncle"); fetcher_->Start(); @@ -180,7 +185,7 @@ namespace { void URLFetcherProtectTest::CreateFetcher(const GURL& url) { fetcher_ = new URLFetcher(url, URLFetcher::GET, this); fetcher_->set_request_context(new TestURLRequestContext()); - fetcher_->set_io_loop(main_loop_); + fetcher_->set_io_loop(&io_loop_); start_time_ = Time::Now(); fetcher_->Start(); } @@ -199,7 +204,7 @@ namespace { EXPECT_TRUE(status.is_success()); EXPECT_FALSE(data.empty()); delete fetcher_; - main_loop_->Quit(); + io_loop_.Quit(); } else { // Now running Overload test. static int count = 0; @@ -243,7 +248,7 @@ namespace { // The rest is the same as URLFetcherTest::OnURLFetchComplete. delete fetcher_; - main_loop_->Quit(); + io_loop_.Quit(); } std::wstring URLFetcherBadHTTPSTest::GetExpiredCertPath() { @@ -271,7 +276,7 @@ TEST_F(URLFetcherTest, DifferentThreadsTest) { // terminate the main thread's message loop; then the other thread's // message loop will be shut down automatically as the thread goes out of // scope. - Thread t("URLFetcher test thread"); + base::Thread t("URLFetcher test thread"); t.Start(); t.message_loop()->PostTask(FROM_HERE, new FetcherWrapperTask(this, GURL(server.TestServerPage("defaultresponse")))); diff --git a/chrome/browser/user_data_dir_dialog.cc b/chrome/browser/user_data_dir_dialog.cc index 5c06cca..3859a5b 100644 --- a/chrome/browser/user_data_dir_dialog.cc +++ b/chrome/browser/user_data_dir_dialog.cc @@ -15,7 +15,7 @@ std::wstring UserDataDirDialog::RunUserDataDirDialog( const std::wstring& user_data_dir) { // When the window closes, it will delete itself. UserDataDirDialog* dlg = new UserDataDirDialog(user_data_dir); - MessageLoop::current()->Run(dlg); + MessageLoopForUI::current()->Run(dlg); return dlg->user_data_dir(); } diff --git a/chrome/browser/user_data_dir_dialog.h b/chrome/browser/user_data_dir_dialog.h index dbdf55b..d9811a8 100644 --- a/chrome/browser/user_data_dir_dialog.h +++ b/chrome/browser/user_data_dir_dialog.h @@ -19,7 +19,7 @@ class Window; } class UserDataDirDialog : public ChromeViews::DialogDelegate, - public MessageLoop::Dispatcher, + public MessageLoopForUI::Dispatcher, public SelectFileDialog::Listener { public: // Creates and runs a user data directory picker dialog. The method blocks diff --git a/chrome/browser/views/bookmark_editor_view_unittest.cc b/chrome/browser/views/bookmark_editor_view_unittest.cc index e69e934..93a99bf 100644 --- a/chrome/browser/views/bookmark_editor_view_unittest.cc +++ b/chrome/browser/views/bookmark_editor_view_unittest.cc @@ -32,6 +32,7 @@ class BookmarkEditorViewTest : public testing::Test { } protected: + MessageLoopForUI message_loop_; BookmarkBarModel* model_; scoped_ptr<TestingProfile> profile_; diff --git a/chrome/browser/views/keyword_editor_view_unittest.cc b/chrome/browser/views/keyword_editor_view_unittest.cc index 84b3f0d..7afee5d 100644 --- a/chrome/browser/views/keyword_editor_view_unittest.cc +++ b/chrome/browser/views/keyword_editor_view_unittest.cc @@ -62,6 +62,7 @@ class KeywordEditorViewTest : public testing::Test, } protected: + MessageLoopForUI message_loop_; scoped_ptr<TestingProfile> profile_; scoped_ptr<KeywordEditorView> editor_; TemplateURLModel* model_; diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc index 46a4521..c70d80e 100644 --- a/chrome/browser/views/options/advanced_contents_view.cc +++ b/chrome/browser/views/options/advanced_contents_view.cc @@ -957,7 +957,7 @@ NetworkSection::NetworkSection(Profile* profile) void NetworkSection::ButtonPressed(ChromeViews::NativeButton* sender) { if (sender == change_proxies_button_) { UserMetricsRecordAction(L"Options_ChangeProxies", NULL); - Thread* thread = g_browser_process->file_thread(); + base::Thread* thread = g_browser_process->file_thread(); DCHECK(thread); thread->message_loop()->PostTask(FROM_HERE, new OpenConnectionDialogTask); } else if (sender == enable_link_doctor_checkbox_) { diff --git a/chrome/browser/views/shell_dialogs.cc b/chrome/browser/views/shell_dialogs.cc index 02b57d9..10f0399 100644 --- a/chrome/browser/views/shell_dialogs.cc +++ b/chrome/browser/views/shell_dialogs.cc @@ -20,9 +20,9 @@ #include "chrome/common/win_util.h" #include "generated_resources.h" -class ShellDialogThread : public Thread { +class ShellDialogThread : public base::Thread { public: - ShellDialogThread() : Thread("Chrome_ShellDialogThread") { } + ShellDialogThread() : base::Thread("Chrome_ShellDialogThread") { } protected: void Init() { @@ -55,7 +55,7 @@ class BaseShellDialogImpl { HWND owner; // Thread dialog is run on. - Thread* dialog_thread; + base::Thread* dialog_thread; }; // Called at the beginning of a modal dialog run. Disables the owner window @@ -93,7 +93,7 @@ class BaseShellDialogImpl { // thread otherwise in some situations where a singleton owns a single // instance of this object we can have a situation where a modal dialog in // one window blocks the appearance of a modal dialog in another. - static Thread* CreateDialogThread(); + static base::Thread* CreateDialogThread(); // Enables the window |owner_|. Can only be run from the ui thread. void EnableOwner(HWND owner); @@ -169,8 +169,8 @@ void BaseShellDialogImpl::DisableOwner(HWND owner) { } // static -Thread* BaseShellDialogImpl::CreateDialogThread() { - Thread* thread = new ShellDialogThread; +base::Thread* BaseShellDialogImpl::CreateDialogThread() { + base::Thread* thread = new ShellDialogThread; bool started = thread->Start(); DCHECK(started); return thread; diff --git a/chrome/browser/visitedlink_master.cc b/chrome/browser/visitedlink_master.cc index ea68f22..ae307ab 100644 --- a/chrome/browser/visitedlink_master.cc +++ b/chrome/browser/visitedlink_master.cc @@ -199,13 +199,13 @@ class VisitedLinkMaster::TableBuilder : public HistoryService::URLEnumerator, // VisitedLinkMaster ---------------------------------------------------------- -VisitedLinkMaster::VisitedLinkMaster(Thread* file_thread, +VisitedLinkMaster::VisitedLinkMaster(base::Thread* file_thread, PostNewTableEvent* poster, Profile* profile) { InitMembers(file_thread, poster, profile); } -VisitedLinkMaster::VisitedLinkMaster(Thread* file_thread, +VisitedLinkMaster::VisitedLinkMaster(base::Thread* file_thread, PostNewTableEvent* poster, HistoryService* history_service, bool suppress_rebuild, @@ -230,7 +230,7 @@ VisitedLinkMaster::~VisitedLinkMaster() { FreeURLTable(); } -void VisitedLinkMaster::InitMembers(Thread* file_thread, +void VisitedLinkMaster::InitMembers(base::Thread* file_thread, PostNewTableEvent* poster, Profile* profile) { if (file_thread) diff --git a/chrome/browser/visitedlink_master.h b/chrome/browser/visitedlink_master.h index 7935f69..56923a7 100644 --- a/chrome/browser/visitedlink_master.h +++ b/chrome/browser/visitedlink_master.h @@ -31,7 +31,7 @@ class VisitedLinkMaster : public VisitedLinkCommon { // The |file_thread| may be NULL, in which case write operations will be // synchronous. - VisitedLinkMaster(Thread* file_thread, + VisitedLinkMaster(base::Thread* file_thread, PostNewTableEvent* poster, Profile* profile); @@ -50,7 +50,7 @@ class VisitedLinkMaster : public VisitedLinkCommon { // When |suppress_rebuild| is set, we'll not attempt to load data from // history if the file can't be loaded. This should generally be set for // testing except when you want to test the rebuild process explicitly. - VisitedLinkMaster(Thread* file_thread, + VisitedLinkMaster(base::Thread* file_thread, PostNewTableEvent* poster, HistoryService* history_service, bool suppress_rebuild, @@ -144,7 +144,7 @@ class VisitedLinkMaster : public VisitedLinkCommon { static const int32 kBigDeleteThreshold; // Backend for the constructors initializing the members. - void InitMembers(Thread* file_thread, + void InitMembers(base::Thread* file_thread, PostNewTableEvent* poster, Profile* profile); diff --git a/chrome/browser/visitedlink_unittest.cc b/chrome/browser/visitedlink_unittest.cc index 7f864b0..afad81c 100644 --- a/chrome/browser/visitedlink_unittest.cc +++ b/chrome/browser/visitedlink_unittest.cc @@ -144,6 +144,8 @@ class VisitedLinkTest : public testing::Test { ClearDB(); file_util::Delete(history_dir_, true); } + + MessageLoop message_loop_; // Filenames for the services; std::wstring history_dir_; diff --git a/chrome/browser/web_contents_unittest.cc b/chrome/browser/web_contents_unittest.cc index 1929550..032e8eb 100644 --- a/chrome/browser/web_contents_unittest.cc +++ b/chrome/browser/web_contents_unittest.cc @@ -296,6 +296,9 @@ class WebContentsTest : public testing::Test { scoped_ptr<WebContentsTestingProfile> profile; TestWebContents* contents; + + private: + MessageLoopForUI message_loop_; }; // Test to make sure that title updates get stripped of whitespace diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc index c3cbfb1..48eebd8 100644 --- a/chrome/browser/webdata/web_data_service.cc +++ b/chrome/browser/webdata/web_data_service.cc @@ -39,7 +39,7 @@ bool WebDataService::Init(const std::wstring& profile_path) { } bool WebDataService::InitWithPath(const std::wstring& path) { - thread_ = new Thread("Chrome_WebDataThread"); + thread_ = new base::Thread("Chrome_WebDataThread"); if (!thread_->Start()) { delete thread_; diff --git a/chrome/browser/webdata/web_data_service.h b/chrome/browser/webdata/web_data_service.h index 5fbe5a6..d7e428d 100644 --- a/chrome/browser/webdata/web_data_service.h +++ b/chrome/browser/webdata/web_data_service.h @@ -427,7 +427,7 @@ class WebDataService : public base::RefCountedThreadSafe<WebDataService> { void GetWebAppImagesImpl(GenericRequest<GURL>* request); - Thread* thread() { return thread_; } + base::Thread* thread() { return thread_; } private: @@ -441,7 +441,7 @@ class WebDataService : public base::RefCountedThreadSafe<WebDataService> { int GetNextRequestHandle(); // Our worker thread. All requests are processed from that thread. - Thread* thread_; + base::Thread* thread_; // Our database. WebDatabase* db_; diff --git a/chrome/browser/xp_frame.cc b/chrome/browser/xp_frame.cc index 5454b1a..fbe65ed 100644 --- a/chrome/browser/xp_frame.cc +++ b/chrome/browser/xp_frame.cc @@ -1021,7 +1021,7 @@ void XPFrame::OnSize(UINT param, const CSize& size) { RedrawWindow(root_view_.GetScheduledPaintRect(), NULL, RDW_UPDATENOW | RDW_INVALIDATE | RDW_ALLCHILDREN); - MessageLoop::current()->PumpOutPendingPaintMessages(); + MessageLoopForUI::current()->PumpOutPendingPaintMessages(); } if (!saved_window_placement_ && should_save_window_placement_) |