summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/chrome_dll_main.cc3
-rw-r--r--chrome/browser/autocomplete/autocomplete_unittest.cc1
-rw-r--r--chrome/browser/autocomplete/history_contents_provider_unittest.cc2
-rw-r--r--chrome/browser/autocomplete/history_url_provider_unittest.cc1
-rw-r--r--chrome/browser/back_forward_menu_model_unittest.cc1
-rw-r--r--chrome/browser/bookmark_bar_context_menu_controller_test.cc4
-rw-r--r--chrome/browser/bookmark_bar_model_unittest.cc2
-rw-r--r--chrome/browser/bookmark_storage.h4
-rw-r--r--chrome/browser/browser_main.cc6
-rw-r--r--chrome/browser/browser_process.h10
-rw-r--r--chrome/browser/browser_process_impl.cc13
-rw-r--r--chrome/browser/browser_process_impl.h12
-rw-r--r--chrome/browser/browsing_data_remover.cc2
-rw-r--r--chrome/browser/cache_manager_host_unittest.cc5
-rw-r--r--chrome/browser/chrome_plugin_host.cc9
-rw-r--r--chrome/browser/chrome_thread.h2
-rw-r--r--chrome/browser/download_file.cc2
-rw-r--r--chrome/browser/download_manager.cc4
-rw-r--r--chrome/browser/download_manager.h4
-rw-r--r--chrome/browser/first_run.cc2
-rw-r--r--chrome/browser/history/expire_history_backend_unittest.cc7
-rw-r--r--chrome/browser/history/history_backend_unittest.cc1
-rw-r--r--chrome/browser/history/history_querying_unittest.cc2
-rw-r--r--chrome/browser/history/history_unittest.cc2
-rw-r--r--chrome/browser/history/text_database_manager_unittest.cc3
-rw-r--r--chrome/browser/importer_unittest.cc1
-rw-r--r--chrome/browser/jankometer.cc11
-rw-r--r--chrome/browser/navigation_controller_unittest.cc3
-rw-r--r--chrome/browser/network_status_view.cc2
-rw-r--r--chrome/browser/printing/print_job_worker.h2
-rw-r--r--chrome/browser/printing/printer_query.h3
-rw-r--r--chrome/browser/printing/printing_layout_uitest.cc6
-rw-r--r--chrome/browser/profile.cc2
-rw-r--r--chrome/browser/profile_manager_unittest.cc3
-rw-r--r--chrome/browser/render_process_host.cc38
-rw-r--r--chrome/browser/render_process_host.h5
-rw-r--r--chrome/browser/resource_dispatcher_host_unittest.cc1
-rw-r--r--chrome/browser/resource_message_filter.cc2
-rw-r--r--chrome/browser/rlz/rlz.cc2
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_blocking_page.cc2
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service.cc2
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service.h2
-rw-r--r--chrome/browser/save_file_manager.cc2
-rw-r--r--chrome/browser/save_package.h5
-rw-r--r--chrome/browser/session_service.h7
-rw-r--r--chrome/browser/site_instance_unittest.cc27
-rw-r--r--chrome/browser/spellchecker.cc4
-rw-r--r--chrome/browser/tabs/dragged_tab_controller.cc4
-rw-r--r--chrome/browser/tabs/dragged_tab_controller.h2
-rw-r--r--chrome/browser/tabs/tab_strip.cc4
-rw-r--r--chrome/browser/tabs/tab_strip.h2
-rw-r--r--chrome/browser/tabs/tab_strip_model_unittest.cc1
-rw-r--r--chrome/browser/task_manager.cc4
-rw-r--r--chrome/browser/template_url_model_unittest.cc1
-rw-r--r--chrome/browser/url_fetcher_unittest.cc25
-rw-r--r--chrome/browser/user_data_dir_dialog.cc2
-rw-r--r--chrome/browser/user_data_dir_dialog.h2
-rw-r--r--chrome/browser/views/bookmark_editor_view_unittest.cc1
-rw-r--r--chrome/browser/views/keyword_editor_view_unittest.cc1
-rw-r--r--chrome/browser/views/options/advanced_contents_view.cc2
-rw-r--r--chrome/browser/views/shell_dialogs.cc12
-rw-r--r--chrome/browser/visitedlink_master.cc6
-rw-r--r--chrome/browser/visitedlink_master.h6
-rw-r--r--chrome/browser/visitedlink_unittest.cc2
-rw-r--r--chrome/browser/web_contents_unittest.cc3
-rw-r--r--chrome/browser/webdata/web_data_service.cc2
-rw-r--r--chrome/browser/webdata/web_data_service.h4
-rw-r--r--chrome/browser/xp_frame.cc2
-rw-r--r--chrome/common/animation_unittest.cc6
-rw-r--r--chrome/common/chrome_plugin_unittest.cc2
-rw-r--r--chrome/common/chrome_plugin_util.cc12
-rw-r--r--chrome/common/chrome_plugin_util.h8
-rw-r--r--chrome/common/ipc_channel.cc28
-rw-r--r--chrome/common/ipc_channel.h2
-rw-r--r--chrome/common/ipc_sync_channel_unittest.cc27
-rw-r--r--chrome/common/ipc_tests.cc8
-rw-r--r--chrome/common/pref_service.cc4
-rw-r--r--chrome/common/pref_service.h7
-rw-r--r--chrome/common/process_watcher.cc16
-rw-r--r--chrome/plugin/plugin_main.cc4
-rw-r--r--chrome/plugin/plugin_thread.cc5
-rw-r--r--chrome/plugin/plugin_thread.h2
-rw-r--r--chrome/renderer/render_thread.cc8
-rw-r--r--chrome/renderer/render_thread.h2
-rw-r--r--chrome/renderer/renderer_main.cc5
-rw-r--r--chrome/test/automation/automation_proxy.cc7
-rw-r--r--chrome/test/automation/automation_proxy.h2
-rw-r--r--chrome/test/testing_browser_process.h6
-rw-r--r--chrome/test/ui/run_all_unittests.cc4
-rw-r--r--chrome/test/ui/ui_test.h2
-rw-r--r--chrome/test/ui/ui_test_suite.h23
-rw-r--r--chrome/test/ui/view_event_test_base.cc2
-rw-r--r--chrome/test/ui/view_event_test_base.h2
-rw-r--r--chrome/test/unit/chrome_test_suite.h26
-rw-r--r--chrome/test/unit/run_all_unittests.cc5
-rw-r--r--chrome/views/accelerator_handler.h2
-rw-r--r--chrome/views/chrome_menu.cc12
-rw-r--r--chrome/views/chrome_menu.h2
-rw-r--r--chrome/views/focus_manager_unittest.cc1
-rw-r--r--chrome/views/hwnd_view_container.cc4
-rw-r--r--chrome/views/hwnd_view_container.h2
-rw-r--r--chrome/views/native_scroll_bar.cc2
-rw-r--r--chrome/views/view_unittest.cc3
103 files changed, 341 insertions, 236 deletions
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc
index dd2a08b..01d68c0 100644
--- a/chrome/app/chrome_dll_main.cc
+++ b/chrome/app/chrome_dll_main.cc
@@ -200,9 +200,6 @@ DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance,
_Module.Init(NULL, instance);
- // Allocate a message loop for this thread
- MessageLoop main_message_loop;
-
// Notice a user data directory override if any
const std::wstring user_data_dir =
parsed_command_line.GetSwitchValue(switches::kUserDataDir);
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_)
diff --git a/chrome/common/animation_unittest.cc b/chrome/common/animation_unittest.cc
index e4429cd..3f9da3c 100644
--- a/chrome/common/animation_unittest.cc
+++ b/chrome/common/animation_unittest.cc
@@ -11,6 +11,8 @@ using namespace std;
namespace {
class AnimationTest: public testing::Test {
+ private:
+ MessageLoopForUI message_loop_;
};
};
@@ -81,7 +83,7 @@ class TestAnimationDelegate : public AnimationDelegate {
bool canceled_;
};
-TEST(AnimationTest, RunCase) {
+TEST_F(AnimationTest, RunCase) {
TestAnimationDelegate ad;
RunAnimation a1(150, &ad);
a1.SetDuration(2000);
@@ -92,7 +94,7 @@ TEST(AnimationTest, RunCase) {
EXPECT_FALSE(ad.canceled());
}
-TEST(AnimationTest, CancelCase) {
+TEST_F(AnimationTest, CancelCase) {
TestAnimationDelegate ad;
CancelAnimation a2(2000, 150, &ad);
a2.Start();
diff --git a/chrome/common/chrome_plugin_unittest.cc b/chrome/common/chrome_plugin_unittest.cc
index 139bcf4..f998755 100644
--- a/chrome/common/chrome_plugin_unittest.cc
+++ b/chrome/common/chrome_plugin_unittest.cc
@@ -62,6 +62,8 @@ class ChromePluginTest : public testing::Test, public URLRequest::Delegate {
Profile::set_default_request_context(NULL);
}
protected:
+ MessageLoopForIO message_loop_;
+
// Note: we use URLRequest (instead of URLFetcher) because this allows the
// request to be intercepted.
scoped_ptr<URLRequest> request_;
diff --git a/chrome/common/chrome_plugin_util.cc b/chrome/common/chrome_plugin_util.cc
index 1a33990..56b1f54 100644
--- a/chrome/common/chrome_plugin_util.cc
+++ b/chrome/common/chrome_plugin_util.cc
@@ -46,18 +46,14 @@ void PluginHelper::DestroyAllHelpersForPlugin(ChromePluginLib* plugin) {
}
PluginHelper::PluginHelper(ChromePluginLib* plugin) : plugin_(plugin) {
-#ifndef NDEBUG
- message_loop_ = MessageLoop::current();
-#endif
+ DCHECK(CalledOnValidThread());
NotificationService::current()->AddObserver(
this, NOTIFY_CHROME_PLUGIN_UNLOADED,
Source<ChromePluginLib>(plugin_));
}
PluginHelper::~PluginHelper() {
-#ifndef NDEBUG
- DCHECK(MessageLoop::current() == message_loop_);
-#endif
+ DCHECK(CalledOnValidThread());
NotificationService::current()->RemoveObserver(
this, NOTIFY_CHROME_PLUGIN_UNLOADED,
Source<ChromePluginLib>(plugin_));
@@ -66,9 +62,7 @@ PluginHelper::~PluginHelper() {
void PluginHelper::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
-#ifndef NDEBUG
- DCHECK(MessageLoop::current() == message_loop_);
-#endif
+ DCHECK(CalledOnValidThread());
DCHECK(type == NOTIFY_CHROME_PLUGIN_UNLOADED);
DCHECK(plugin_ == Source<ChromePluginLib>(source).ptr());
diff --git a/chrome/common/chrome_plugin_util.h b/chrome/common/chrome_plugin_util.h
index 847e096..5ca17fc 100644
--- a/chrome/common/chrome_plugin_util.h
+++ b/chrome/common/chrome_plugin_util.h
@@ -6,6 +6,7 @@
#define CHROME_COMMON_CHROME_PLUGIN_UTIL_H__
#include "base/basictypes.h"
+#include "base/non_thread_safe.h"
#include "base/ref_counted.h"
#include "chrome/common/chrome_plugin_api.h"
#include "chrome/common/notification_service.h"
@@ -35,7 +36,7 @@ struct ScopableCPRequest : public CPRequest {
// This is a base class for plugin-related objects that need to go away when
// the plugin unloads. This object also verifies that it is created and
// destroyed on the same thread.
-class PluginHelper : public NotificationObserver {
+class PluginHelper : public NotificationObserver, public NonThreadSafe {
public:
static void DestroyAllHelpersForPlugin(ChromePluginLib* plugin);
@@ -49,11 +50,6 @@ class PluginHelper : public NotificationObserver {
protected:
scoped_refptr<ChromePluginLib> plugin_;
-#ifndef NDEBUG
- // We keep track of the message loop of the thread we were created on, so
- // we can verify that all other methods are called on the same thread.
- MessageLoop* message_loop_;
-#endif
DISALLOW_EVIL_CONSTRUCTORS(PluginHelper);
};
diff --git a/chrome/common/ipc_channel.cc b/chrome/common/ipc_channel.cc
index 40a101b..c87d75f 100644
--- a/chrome/common/ipc_channel.cc
+++ b/chrome/common/ipc_channel.cc
@@ -49,8 +49,9 @@ Channel::Channel(const wstring& channel_id, Mode mode, Listener* listener)
void Channel::Close() {
// make sure we are no longer watching the pipe events
- MessageLoop::current()->WatchObject(input_state_.overlapped.hEvent, NULL);
- MessageLoop::current()->WatchObject(output_state_.overlapped.hEvent, NULL);
+ MessageLoopForIO* loop = MessageLoopForIO::current();
+ loop->WatchObject(input_state_.overlapped.hEvent, NULL);
+ loop->WatchObject(output_state_.overlapped.hEvent, NULL);
if (pipe_ != INVALID_HANDLE_VALUE) {
CloseHandle(pipe_);
@@ -168,7 +169,8 @@ bool Channel::Connect() {
// to OnObjectSignaled that this is the special initialization signal.
SetEvent(input_state_.overlapped.hEvent);
- MessageLoop::current()->WatchObject(input_state_.overlapped.hEvent, this);
+ MessageLoopForIO::current()->WatchObject(
+ input_state_.overlapped.hEvent, this);
}
if (!waiting_connect_)
@@ -178,7 +180,8 @@ bool Channel::Connect() {
bool Channel::ProcessConnection() {
input_state_.is_pending = false;
- MessageLoop::current()->WatchObject(input_state_.overlapped.hEvent, NULL);
+ MessageLoopForIO::current()->WatchObject(
+ input_state_.overlapped.hEvent, NULL);
// Do we have a client connected to our pipe?
DCHECK(pipe_ != INVALID_HANDLE_VALUE);
@@ -195,7 +198,8 @@ bool Channel::ProcessConnection() {
switch (err) {
case ERROR_IO_PENDING:
input_state_.is_pending = true;
- MessageLoop::current()->WatchObject(input_state_.overlapped.hEvent, this);
+ MessageLoopForIO::current()->WatchObject(
+ input_state_.overlapped.hEvent, this);
break;
case ERROR_PIPE_CONNECTED:
waiting_connect_ = false;
@@ -211,7 +215,8 @@ bool Channel::ProcessConnection() {
bool Channel::ProcessIncomingMessages() {
DWORD bytes_read = 0;
- MessageLoop::current()->WatchObject(input_state_.overlapped.hEvent, NULL);
+ MessageLoopForIO::current()->WatchObject(
+ input_state_.overlapped.hEvent, NULL);
if (input_state_.is_pending) {
input_state_.is_pending = false;
@@ -243,8 +248,8 @@ bool Channel::ProcessIncomingMessages() {
if (!ok) {
DWORD err = GetLastError();
if (err == ERROR_IO_PENDING) {
- MessageLoop::current()->WatchObject(input_state_.overlapped.hEvent,
- this);
+ MessageLoopForIO::current()->WatchObject(
+ input_state_.overlapped.hEvent, this);
input_state_.is_pending = true;
return true;
}
@@ -307,7 +312,8 @@ bool Channel::ProcessOutgoingMessages() {
DWORD bytes_written;
if (output_state_.is_pending) {
- MessageLoop::current()->WatchObject(output_state_.overlapped.hEvent, NULL);
+ MessageLoopForIO::current()->WatchObject(
+ output_state_.overlapped.hEvent, NULL);
output_state_.is_pending = false;
BOOL ok = GetOverlappedResult(pipe_,
&output_state_.overlapped,
@@ -336,8 +342,8 @@ bool Channel::ProcessOutgoingMessages() {
if (!ok) {
DWORD err = GetLastError();
if (err == ERROR_IO_PENDING) {
- MessageLoop::current()->WatchObject(output_state_.overlapped.hEvent,
- this);
+ MessageLoopForIO::current()->WatchObject(
+ output_state_.overlapped.hEvent, this);
output_state_.is_pending = true;
#ifdef IPC_MESSAGE_DEBUG_EXTRA
diff --git a/chrome/common/ipc_channel.h b/chrome/common/ipc_channel.h
index 549e9cb..94d41a3 100644
--- a/chrome/common/ipc_channel.h
+++ b/chrome/common/ipc_channel.h
@@ -14,7 +14,7 @@ namespace IPC {
//------------------------------------------------------------------------------
-class Channel : public MessageLoop::Watcher,
+class Channel : public MessageLoopForIO::Watcher,
public Message::Sender {
// Security tests need access to the pipe handle.
friend class ChannelTest;
diff --git a/chrome/common/ipc_sync_channel_unittest.cc b/chrome/common/ipc_sync_channel_unittest.cc
index f930790..3899204 100644
--- a/chrome/common/ipc_sync_channel_unittest.cc
+++ b/chrome/common/ipc_sync_channel_unittest.cc
@@ -97,12 +97,13 @@ class Worker : public Channel::Listener, public Message::Sender {
void WaitForChannelCreation() { channel_created_.Wait(); }
void CloseChannel() { channel_.reset(); }
void Start() {
- listener_thread_.Start();
- Thread* thread = overrided_thread_ ? overrided_thread_ : &listener_thread_;
+ StartThread(&listener_thread_);
+ base::Thread* thread =
+ overrided_thread_ ? overrided_thread_ : &listener_thread_;
thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
this, &Worker::OnStart));
}
- void OverrideThread(Thread* overrided_thread) {
+ void OverrideThread(base::Thread* overrided_thread) {
DCHECK(overrided_thread_ == NULL);
overrided_thread_ = overrided_thread;
}
@@ -133,8 +134,8 @@ class Worker : public Channel::Listener, public Message::Sender {
private:
// Called on the listener thread to create the sync channel.
void OnStart() {
- ipc_thread_.Start();
// Link ipc_thread_, listener_thread_ and channel_ altogether.
+ StartThread(&ipc_thread_);
channel_.reset(new SyncChannel(
channel_name_, mode_, this, NULL, ipc_thread_.message_loop(), true,
TestProcess::GetShutDownEvent()));
@@ -150,14 +151,20 @@ class Worker : public Channel::Listener, public Message::Sender {
IPC_END_MESSAGE_MAP()
}
+ void StartThread(base::Thread* thread) {
+ base::Thread::Options options;
+ options.message_loop_type = MessageLoop::TYPE_IO;
+ thread->StartWithOptions(options);
+ }
+
Event done_;
Event channel_created_;
std::wstring channel_name_;
Channel::Mode mode_;
scoped_ptr<SyncChannel> channel_;
- Thread ipc_thread_;
- Thread listener_thread_;
- Thread* overrided_thread_;
+ base::Thread ipc_thread_;
+ base::Thread listener_thread_;
+ base::Thread* overrided_thread_;
DISALLOW_EVIL_CONSTRUCTORS(Worker);
};
@@ -191,6 +198,8 @@ void RunTest(std::vector<Worker*> workers) {
int count = static_cast<int>(done_handles.size());
WaitForMultipleObjects(count, &done_handles.front(), TRUE, INFINITE);
STLDeleteContainerPointers(workers.begin(), workers.end());
+
+ TestProcess::GlobalCleanup();
}
@@ -403,7 +412,7 @@ TEST(IPCSyncChannelTest, Multiple) {
std::vector<Worker*> workers;
// A shared worker thread so that server1 and server2 run on one thread.
- Thread worker_thread("Multiple");
+ base::Thread worker_thread("Multiple");
worker_thread.Start();
// Server1 sends a sync msg to client1, which blocks the reply until
@@ -510,7 +519,7 @@ TEST(IPCSyncChannelTest, QueuedReply) {
std::vector<Worker*> workers;
// A shared worker thread so that server1 and server2 run on one thread.
- Thread worker_thread("QueuedReply");
+ base::Thread worker_thread("QueuedReply");
worker_thread.Start();
Event client1_msg_received, server2_can_reply;
diff --git a/chrome/common/ipc_tests.cc b/chrome/common/ipc_tests.cc
index 316c397..67d7140 100644
--- a/chrome/common/ipc_tests.cc
+++ b/chrome/common/ipc_tests.cc
@@ -133,8 +133,10 @@ TEST(IPCChannelTest, ChannelTest) {
TEST(IPCChannelTest, ChannelProxyTest) {
// The thread needs to out-live the ChannelProxy.
- Thread thread("ChannelProxyTestServer");
- thread.Start();
+ base::Thread thread("ChannelProxyTestServer");
+ base::Thread::Options options;
+ options.message_loop_type = MessageLoop::TYPE_IO;
+ thread.StartWithOptions(options);
{
// setup IPC channel proxy
IPC::ChannelProxy chan(kTestClientChannel, IPC::Channel::MODE_SERVER,
@@ -380,7 +382,7 @@ int main(int argc, char** argv) {
// the AtExitManager or else we will leak objects.
base::AtExitManager at_exit_manager;
- MessageLoop main_message_loop;
+ MessageLoopForIO main_message_loop;
// suppress standard crash dialogs and such unless a debugger is present.
if (!IsDebuggerPresent()) {
diff --git a/chrome/common/pref_service.cc b/chrome/common/pref_service.cc
index dd55bdc..60ac6f2 100644
--- a/chrome/common/pref_service.cc
+++ b/chrome/common/pref_service.cc
@@ -178,7 +178,7 @@ void PrefService::ReloadPersistentPrefs() {
}
}
-bool PrefService::SavePersistentPrefs(Thread* thread) const {
+bool PrefService::SavePersistentPrefs(base::Thread* thread) const {
DCHECK(!pref_filename_.empty());
DCHECK(CalledOnValidThread());
@@ -202,7 +202,7 @@ bool PrefService::SavePersistentPrefs(Thread* thread) const {
return true;
}
-void PrefService::ScheduleSavePersistentPrefs(Thread* thread) {
+void PrefService::ScheduleSavePersistentPrefs(base::Thread* thread) {
if (!save_preferences_factory_.empty())
return;
diff --git a/chrome/common/pref_service.h b/chrome/common/pref_service.h
index 9b552f2..32c012f 100644
--- a/chrome/common/pref_service.h
+++ b/chrome/common/pref_service.h
@@ -28,7 +28,10 @@
class NotificationObserver;
class Preference;
+
+namespace base {
class Thread;
+}
class PrefService : public NonThreadSafe {
public:
@@ -88,12 +91,12 @@ class PrefService : public NonThreadSafe {
// (since it's on a different thread). This should only be used if we need
// to save immediately (basically, during shutdown). Otherwise, you should
// use ScheduleSavePersistentPrefs.
- bool SavePersistentPrefs(Thread* thread) const;
+ bool SavePersistentPrefs(base::Thread* thread) const;
// Starts a timer that ends up saving the preferences. This helps to batch
// together save requests that happen in a close time frame so we don't write
// to disk too frequently.
- void ScheduleSavePersistentPrefs(Thread* thread);
+ void ScheduleSavePersistentPrefs(base::Thread* thread);
DictionaryValue* transient() { return transient_.get(); }
diff --git a/chrome/common/process_watcher.cc b/chrome/common/process_watcher.cc
index 8a9fadc..b8d78bd2 100644
--- a/chrome/common/process_watcher.cc
+++ b/chrome/common/process_watcher.cc
@@ -5,6 +5,7 @@
#include "chrome/common/process_watcher.h"
#include "base/message_loop.h"
+#include "base/object_watcher.h"
#include "chrome/app/result_codes.h"
#include "chrome/common/env_util.h"
#include "chrome/common/env_vars.h"
@@ -14,10 +15,10 @@ static const int kWaitInterval = 2000;
namespace {
-class TimerExpiredTask : public Task, public MessageLoop::Watcher {
+class TimerExpiredTask : public Task, public base::ObjectWatcher::Delegate {
public:
explicit TimerExpiredTask(ProcessHandle process) : process_(process) {
- MessageLoop::current()->WatchObject(process_, this);
+ watcher_.StartWatching(process_, this);
}
virtual ~TimerExpiredTask() {
@@ -37,12 +38,9 @@ class TimerExpiredTask : public Task, public MessageLoop::Watcher {
// MessageLoop::Watcher -----------------------------------------------------
virtual void OnObjectSignaled(HANDLE object) {
- if (MessageLoop::current()) {
- // When we're called from our destructor, the message loop is in the
- // process of being torn down. Only touch the message loop if it is
- // still running.
- MessageLoop::current()->WatchObject(process_, NULL); // Stop watching.
- }
+ // When we're called from KillProcess, the ObjectWatcher may still be
+ // watching. the process handle, so make sure it has stopped.
+ watcher_.StopWatching();
CloseHandle(process_);
process_ = NULL;
@@ -72,6 +70,8 @@ class TimerExpiredTask : public Task, public MessageLoop::Watcher {
// The process that we are watching.
ProcessHandle process_;
+ base::ObjectWatcher watcher_;
+
DISALLOW_EVIL_CONSTRUCTORS(TimerExpiredTask);
};
diff --git a/chrome/plugin/plugin_main.cc b/chrome/plugin/plugin_main.cc
index 25e8968..df2dbc1 100644
--- a/chrome/plugin/plugin_main.cc
+++ b/chrome/plugin/plugin_main.cc
@@ -15,6 +15,10 @@
// mainline routine for running as the plugin process
int PluginMain(CommandLine &parsed_command_line, int show_command,
sandbox::TargetServices* target_services) {
+ // The main thread of the plugin services IO.
+ MessageLoopForIO main_message_loop;
+ PlatformThread::SetName("Chrome_PluginMain");
+
CoInitialize(NULL);
DLOG(INFO) << "Started plugin with " <<
parsed_command_line.command_line_string();
diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc
index 2b39ef5..25bd06d 100644
--- a/chrome/plugin/plugin_thread.cc
+++ b/chrome/plugin/plugin_thread.cc
@@ -31,7 +31,10 @@ PluginThread::PluginThread(PluginProcess* process,
DCHECK(!plugin_thread_);
plugin_thread_ = this;
- Start();
+ // We need to run a UI message loop to support plugin execution.
+ base::Thread::Options options;
+ options.message_loop_type = MessageLoop::TYPE_UI;
+ StartWithOptions(options);
}
PluginThread::~PluginThread() {
diff --git a/chrome/plugin/plugin_thread.h b/chrome/plugin/plugin_thread.h
index f2bfb85..df4b67a 100644
--- a/chrome/plugin/plugin_thread.h
+++ b/chrome/plugin/plugin_thread.h
@@ -19,7 +19,7 @@ class NotificationService;
// process and WebPluginDelegateStub in this thread through IPC messages.
class PluginThread : public IPC::Channel::Listener,
public IPC::Message::Sender,
- public Thread {
+ public base::Thread {
public:
PluginThread(PluginProcess *process, const std::wstring& channel_name);
~PluginThread();
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index 6b34176..fb70dd4 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -37,7 +37,13 @@ RenderThread::RenderThread(const std::wstring& channel_name)
render_dns_master_(NULL),
in_send_(0) {
DCHECK(owner_loop_);
- StartWithStackSize(kStackSize);
+ base::Thread::Options options;
+ options.stack_size = kStackSize;
+ // When we run plugins in process, we actually run them on the render thread,
+ // which means that we need to make the render thread pump UI events.
+ if (RenderProcess::ShouldLoadPluginsInProcess())
+ options.message_loop_type = MessageLoop::TYPE_UI;
+ StartWithOptions(options);
}
RenderThread::~RenderThread() {
diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h
index 6a7d019..89b203f 100644
--- a/chrome/renderer/render_thread.h
+++ b/chrome/renderer/render_thread.h
@@ -32,7 +32,7 @@ class NotificationService;
class RenderThread : public IPC::Channel::Listener,
public IPC::Message::Sender,
- public Thread {
+ public base::Thread {
public:
RenderThread(const std::wstring& channel_name);
~RenderThread();
diff --git a/chrome/renderer/renderer_main.cc b/chrome/renderer/renderer_main.cc
index 59c4003..7a3e898 100644
--- a/chrome/renderer/renderer_main.cc
+++ b/chrome/renderer/renderer_main.cc
@@ -43,11 +43,12 @@ static void HandleRendererErrorTestParameters(const CommandLine& command_line) {
// mainline routine for running as the Rendererer process
int RendererMain(CommandLine &parsed_command_line, int show_command,
- sandbox::TargetServices* target_services)
-{
+ sandbox::TargetServices* target_services) {
StatsScope<StatsCounterTimer>
startup_timer(chrome::Counters::renderer_main());
+ // The main thread of the renderer services IO.
+ MessageLoopForIO main_message_loop;
PlatformThread::SetName("Chrome_RendererMain");
CoInitialize(NULL);
diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc
index 965d47c..1724f95 100644
--- a/chrome/test/automation/automation_proxy.cc
+++ b/chrome/test/automation/automation_proxy.cc
@@ -182,8 +182,11 @@ void AutomationProxy::InitializeChannelID() {
}
void AutomationProxy::InitializeThread() {
- scoped_ptr<Thread> thread(new Thread("AutomationProxy_BackgroundThread"));
- bool thread_result = thread->Start();
+ scoped_ptr<base::Thread> thread(
+ new base::Thread("AutomationProxy_BackgroundThread"));
+ base::Thread::Options options;
+ options.message_loop_type = MessageLoop::TYPE_IO;
+ bool thread_result = thread->StartWithOptions(options);
DCHECK(thread_result);
thread_.swap(thread);
}
diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h
index 39a0f1c..8491832 100644
--- a/chrome/test/automation/automation_proxy.h
+++ b/chrome/test/automation/automation_proxy.h
@@ -201,7 +201,7 @@ class AutomationProxy : public IPC::Channel::Listener,
void InitializeHandleTracker();
std::wstring channel_id_;
- scoped_ptr<Thread> thread_;
+ scoped_ptr<base::Thread> thread_;
scoped_ptr<IPC::ChannelProxy> channel_;
scoped_ptr<AutomationHandleTracker> tracker_;
diff --git a/chrome/test/testing_browser_process.h b/chrome/test/testing_browser_process.h
index 57c076b..b7255d0 100644
--- a/chrome/test/testing_browser_process.h
+++ b/chrome/test/testing_browser_process.h
@@ -37,15 +37,15 @@ class TestingBrowserProcess : public BrowserProcess {
return NULL;
}
- virtual Thread* io_thread() {
+ virtual base::Thread* io_thread() {
return NULL;
}
- virtual Thread* file_thread() {
+ virtual base::Thread* file_thread() {
return NULL;
}
- virtual Thread* db_thread() {
+ virtual base::Thread* db_thread() {
return NULL;
}
diff --git a/chrome/test/ui/run_all_unittests.cc b/chrome/test/ui/run_all_unittests.cc
index f4c0116..9b7ec72 100644
--- a/chrome/test/ui/run_all_unittests.cc
+++ b/chrome/test/ui/run_all_unittests.cc
@@ -7,10 +7,6 @@
#include "chrome/test/ui/ui_test_suite.h"
int main(int argc, char **argv) {
- // Some tests may use base::Singleton<>, thus we need to instanciate
- // the AtExitManager or else we will leak objects.
- base::AtExitManager at_exit_manager;
-
PlatformThread::SetName("Tests_Main");
return UITestSuite(argc, argv).Run();
}
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index 847fb20..f7f9257 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -330,6 +330,8 @@ class UITest : public testing::Test {
static int timeout_ms_; // Timeout in milliseconds to wait
// for an test to finish.
::scoped_ptr<AutomationProxy> server_;
+
+ MessageLoop message_loop_; // Enables PostTask to main thread.
};
// These exist only to support the gTest assertion macros, and
diff --git a/chrome/test/ui/ui_test_suite.h b/chrome/test/ui/ui_test_suite.h
index c60eedb..d15db81 100644
--- a/chrome/test/ui/ui_test_suite.h
+++ b/chrome/test/ui/ui_test_suite.h
@@ -18,28 +18,29 @@ class UITestSuite : public ChromeTestSuite {
virtual void Initialize() {
ChromeTestSuite::Initialize();
+ CommandLine parsed_command_line;
UITest::set_in_process_renderer(
- parsed_command_line_.HasSwitch(switches::kSingleProcess));
+ parsed_command_line.HasSwitch(switches::kSingleProcess));
UITest::set_in_process_plugins(
- parsed_command_line_.HasSwitch(switches::kInProcessPlugins));
+ parsed_command_line.HasSwitch(switches::kInProcessPlugins));
UITest::set_no_sandbox(
- parsed_command_line_.HasSwitch(switches::kNoSandbox));
+ parsed_command_line.HasSwitch(switches::kNoSandbox));
UITest::set_full_memory_dump(
- parsed_command_line_.HasSwitch(switches::kFullMemoryCrashReport));
+ parsed_command_line.HasSwitch(switches::kFullMemoryCrashReport));
UITest::set_safe_plugins(
- parsed_command_line_.HasSwitch(switches::kSafePlugins));
+ parsed_command_line.HasSwitch(switches::kSafePlugins));
UITest::set_use_existing_browser(
- parsed_command_line_.HasSwitch(UITestSuite::kUseExistingBrowser));
+ parsed_command_line.HasSwitch(UITestSuite::kUseExistingBrowser));
UITest::set_dump_histograms_on_exit(
- parsed_command_line_.HasSwitch(switches::kDumpHistogramsOnExit));
+ parsed_command_line.HasSwitch(switches::kDumpHistogramsOnExit));
UITest::set_enable_dcheck(
- parsed_command_line_.HasSwitch(switches::kEnableDCHECK));
+ parsed_command_line.HasSwitch(switches::kEnableDCHECK));
UITest::set_silent_dump_on_dcheck(
- parsed_command_line_.HasSwitch(switches::kSilentDumpOnDCHECK));
+ parsed_command_line.HasSwitch(switches::kSilentDumpOnDCHECK));
UITest::set_disable_breakpad(
- parsed_command_line_.HasSwitch(switches::kDisableBreakpad));
+ parsed_command_line.HasSwitch(switches::kDisableBreakpad));
std::wstring test_timeout =
- parsed_command_line_.GetSwitchValue(UITestSuite::kTestTimeout);
+ parsed_command_line.GetSwitchValue(UITestSuite::kTestTimeout);
if (!test_timeout.empty()) {
UITest::set_test_timeout_ms(_wtoi(test_timeout.c_str()));
}
diff --git a/chrome/test/ui/view_event_test_base.cc b/chrome/test/ui/view_event_test_base.cc
index edba5dd..a702ea3 100644
--- a/chrome/test/ui/view_event_test_base.cc
+++ b/chrome/test/ui/view_event_test_base.cc
@@ -93,7 +93,7 @@ gfx::Size ViewEventTestBase::GetPreferredSize() {
void ViewEventTestBase::ScheduleMouseMoveInBackground(int x, int y) {
if (!dnd_thread_.get()) {
- dnd_thread_.reset(new Thread("mouse-move-thread"));
+ dnd_thread_.reset(new base::Thread("mouse-move-thread"));
dnd_thread_->Start();
}
dnd_thread_->message_loop()->PostDelayedTask(
diff --git a/chrome/test/ui/view_event_test_base.h b/chrome/test/ui/view_event_test_base.h
index b4829b3..e89f734 100644
--- a/chrome/test/ui/view_event_test_base.h
+++ b/chrome/test/ui/view_event_test_base.h
@@ -121,7 +121,7 @@ class ViewEventTestBase : public ChromeViews::WindowDelegate,
ChromeViews::View* content_view_;
// Thread for posting background MouseMoves.
- scoped_ptr<Thread> dnd_thread_;
+ scoped_ptr<base::Thread> dnd_thread_;
DISALLOW_COPY_AND_ASSIGN(ViewEventTestBase);
};
diff --git a/chrome/test/unit/chrome_test_suite.h b/chrome/test/unit/chrome_test_suite.h
index 5f68e77..9432a03 100644
--- a/chrome/test/unit/chrome_test_suite.h
+++ b/chrome/test/unit/chrome_test_suite.h
@@ -20,17 +20,6 @@ public:
ChromeTestSuite(int argc, char** argv) : TestSuite(argc, argv) {
}
- virtual ~ChromeTestSuite() {
- ResourceBundle::CleanupSharedInstance();
-
- delete g_browser_process;
- g_browser_process = NULL;
-
- // Tear down shared StatsTable; prevents unit_tests from leaking it.
- StatsTable::set_current(NULL);
- delete stats_table_;
- }
-
protected:
virtual void Initialize() {
@@ -44,7 +33,7 @@ protected:
// NOTE: The user data directory will be erased before each UI test that
// uses it, in order to ensure consistency.
std::wstring user_data_dir =
- parsed_command_line_.GetSwitchValue(switches::kUserDataDir);
+ CommandLine().GetSwitchValue(switches::kUserDataDir);
if (user_data_dir.empty() &&
PathService::Get(base::DIR_EXE, &user_data_dir))
file_util::AppendToPath(&user_data_dir, L"test_user_data");
@@ -59,6 +48,19 @@ protected:
StatsTable::set_current(stats_table_);
}
+ virtual void Shutdown() {
+ ResourceBundle::CleanupSharedInstance();
+
+ delete g_browser_process;
+ g_browser_process = NULL;
+
+ // Tear down shared StatsTable; prevents unit_tests from leaking it.
+ StatsTable::set_current(NULL);
+ delete stats_table_;
+
+ TestSuite::Shutdown();
+ }
+
StatsTable* stats_table_;
};
diff --git a/chrome/test/unit/run_all_unittests.cc b/chrome/test/unit/run_all_unittests.cc
index 24413d52..8a7419b 100644
--- a/chrome/test/unit/run_all_unittests.cc
+++ b/chrome/test/unit/run_all_unittests.cc
@@ -2,14 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/at_exit.h"
#include "chrome/test/unit/chrome_test_suite.h"
int main(int argc, char **argv) {
- // Some tests may use base::Singleton<>, thus we need to instanciate
- // the AtExitManager or else we will leak objects.
- base::AtExitManager at_exit_manager;
-
return ChromeTestSuite(argc, argv).Run();
}
diff --git a/chrome/views/accelerator_handler.h b/chrome/views/accelerator_handler.h
index 093fc847..9405178 100644
--- a/chrome/views/accelerator_handler.h
+++ b/chrome/views/accelerator_handler.h
@@ -15,7 +15,7 @@ namespace ChromeViews {
// holds a singleton instance of this class which can be used by other
// custom message loop dispatcher objects to implement default accelerator
// handling.
-class AcceleratorHandler : public MessageLoop::Dispatcher {
+class AcceleratorHandler : public MessageLoopForUI::Dispatcher {
public:
AcceleratorHandler();
// Dispatcher method. This returns true if an accelerator was
diff --git a/chrome/views/chrome_menu.cc b/chrome/views/chrome_menu.cc
index 6fa61db..a1f9306 100644
--- a/chrome/views/chrome_menu.cc
+++ b/chrome/views/chrome_menu.cc
@@ -1550,14 +1550,14 @@ MenuItemView* MenuController::Run(HWND parent,
DLOG(INFO) << " entering nested loop, depth=" << nested_depth;
#endif
+ MessageLoopForUI* loop = MessageLoopForUI::current();
if (MenuItemView::allow_task_nesting_during_run_) {
- bool did_allow_task_nesting =
- MessageLoop::current()->NestableTasksAllowed();
- MessageLoop::current()->SetNestableTasksAllowed(true);
- MessageLoop::current()->Run(this);
- MessageLoop::current()->SetNestableTasksAllowed(did_allow_task_nesting);
+ bool did_allow_task_nesting = loop->NestableTasksAllowed();
+ loop->SetNestableTasksAllowed(true);
+ loop->Run(this);
+ loop->SetNestableTasksAllowed(did_allow_task_nesting);
} else {
- MessageLoop::current()->Run(this);
+ loop->Run(this);
}
#ifdef DEBUG_MENU
diff --git a/chrome/views/chrome_menu.h b/chrome/views/chrome_menu.h
index a1ed4ed..1377155 100644
--- a/chrome/views/chrome_menu.h
+++ b/chrome/views/chrome_menu.h
@@ -591,7 +591,7 @@ class SubmenuView : public View {
// All relevant events are forwarded to the MenuController from SubmenuView
// and MenuHost.
-class MenuController : public MessageLoop::Dispatcher {
+class MenuController : public MessageLoopForUI::Dispatcher {
public:
friend class MenuHostRootView;
friend class MenuItemView;
diff --git a/chrome/views/focus_manager_unittest.cc b/chrome/views/focus_manager_unittest.cc
index c48879d..841f738 100644
--- a/chrome/views/focus_manager_unittest.cc
+++ b/chrome/views/focus_manager_unittest.cc
@@ -217,6 +217,7 @@ class FocusManagerTest : public testing::Test {
virtual void SetUp();
virtual void TearDown();
+ MessageLoopForUI message_loop_;
TestViewWindow* test_window_;
};
diff --git a/chrome/views/hwnd_view_container.cc b/chrome/views/hwnd_view_container.cc
index 204ba35..9c723d9 100644
--- a/chrome/views/hwnd_view_container.cc
+++ b/chrome/views/hwnd_view_container.cc
@@ -138,7 +138,7 @@ HWNDViewContainer::HWNDViewContainer()
}
HWNDViewContainer::~HWNDViewContainer() {
- MessageLoop::current()->RemoveObserver(this);
+ MessageLoopForUI::current()->RemoveObserver(this);
}
void HWNDViewContainer::Init(HWND parent,
@@ -183,7 +183,7 @@ void HWNDViewContainer::Init(HWND parent,
// Sets the RootView as a property, so the automation can introspect windows.
SetRootViewForHWND(hwnd_, root_view_.get());
- MessageLoop::current()->AddObserver(this);
+ MessageLoopForUI::current()->AddObserver(this);
// Windows special DWM window frame requires a special tooltip manager so
// that window controls in Chrome windows don't flicker when you move your
diff --git a/chrome/views/hwnd_view_container.h b/chrome/views/hwnd_view_container.h
index 6073b2d..026d6b7 100644
--- a/chrome/views/hwnd_view_container.h
+++ b/chrome/views/hwnd_view_container.h
@@ -75,7 +75,7 @@ class FillLayout : public LayoutManager {
//
///////////////////////////////////////////////////////////////////////////////
class HWNDViewContainer : public ViewContainer,
- public MessageLoop::Observer,
+ public MessageLoopForUI::Observer,
public FocusTraversable,
public AcceleratorTarget {
public:
diff --git a/chrome/views/native_scroll_bar.cc b/chrome/views/native_scroll_bar.cc
index bd81655..00e442c 100644
--- a/chrome/views/native_scroll_bar.cc
+++ b/chrome/views/native_scroll_bar.cc
@@ -190,7 +190,7 @@ class ScrollBarContainer : public CWindowImpl<ScrollBarContainer,
MSG dummy;
dummy.hwnd = NULL;
dummy.message = 0;
- MessageLoop::current()->DidProcessMessage(dummy);
+ MessageLoopForUI::current()->DidProcessMessage(dummy);
}
// note: always ignore 2nd param as it is 16 bits
diff --git a/chrome/views/view_unittest.cc b/chrome/views/view_unittest.cc
index 0034104..a658132 100644
--- a/chrome/views/view_unittest.cc
+++ b/chrome/views/view_unittest.cc
@@ -21,6 +21,9 @@ class ViewTest : public testing::Test {
~ViewTest() {
OleUninitialize();
}
+
+ private:
+ MessageLoopForUI message_loop_;
};
// Paints the RootView.