Commit 2eb080bd authored by Carlos Caballero's avatar Carlos Caballero Committed by Commit Bot

Remove MessageLoopForUI

Bug: 891670
Change-Id: I6c30caccbf040366505a46ffe9619fc6adf15105
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1778053Reviewed-by: default avatarTommi <tommi@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Commit-Queue: Carlos Caballero <carlscab@google.com>
Cr-Commit-Position: refs/heads/master@{#696011}
parent 30d2f3ff
...@@ -161,45 +161,4 @@ void MessageLoop::SetTaskRunner( ...@@ -161,45 +161,4 @@ void MessageLoop::SetTaskRunner(
sequence_manager_->SetTaskRunner(task_runner); sequence_manager_->SetTaskRunner(task_runner);
} }
#if !defined(OS_NACL)
//------------------------------------------------------------------------------
// MessageLoopForUI
MessageLoopForUI::MessageLoopForUI(MessagePumpType type) : MessageLoop(type) {
#if defined(OS_ANDROID)
DCHECK(type == MessagePumpType::UI || type == MessagePumpType::JAVA);
#else
DCHECK_EQ(type, MessagePumpType::UI);
#endif
}
#if defined(OS_IOS)
void MessageLoopForUI::Attach() {
sequence_manager_->AttachToMessagePump();
}
#endif // defined(OS_IOS)
#if defined(OS_ANDROID)
void MessageLoopForUI::Abort() {
static_cast<MessagePumpForUI*>(pump_)->Abort();
}
bool MessageLoopForUI::IsAborted() {
return static_cast<MessagePumpForUI*>(pump_)->IsAborted();
}
void MessageLoopForUI::QuitWhenIdle(base::OnceClosure callback) {
static_cast<MessagePumpForUI*>(pump_)->QuitWhenIdle(std::move(callback));
}
#endif // defined(OS_ANDROID)
#if defined(OS_WIN)
void MessageLoopForUI::EnableWmQuit() {
static_cast<MessagePumpForUI*>(pump_)->EnableWmQuit();
}
#endif // defined(OS_WIN)
#endif // !defined(OS_NACL)
} // namespace base } // namespace base
...@@ -202,58 +202,6 @@ class BASE_EXPORT MessageLoop { ...@@ -202,58 +202,6 @@ class BASE_EXPORT MessageLoop {
DISALLOW_COPY_AND_ASSIGN(MessageLoop); DISALLOW_COPY_AND_ASSIGN(MessageLoop);
}; };
#if !defined(OS_NACL)
//-----------------------------------------------------------------------------
// MessageLoopForUI extends MessageLoop with methods that are particular to a
// MessageLoop instantiated with TYPE_UI.
//
// By instantiating a MessageLoopForUI on the current thread, the owner enables
// native UI message pumping.
//
// MessageLoopCurrentForUI is exposed statically on its thread via
// MessageLoopCurrentForUI::Get() to provide additional functionality.
//
class BASE_EXPORT MessageLoopForUI : public MessageLoop {
public:
explicit MessageLoopForUI(MessagePumpType type = MessagePumpType::UI);
#if defined(OS_IOS)
// On iOS, the main message loop cannot be Run(). Instead call Attach(),
// which connects this MessageLoop to the UI thread's CFRunLoop and allows
// PostTask() to work.
void Attach();
#endif
#if defined(OS_ANDROID)
// On Android there are cases where we want to abort immediately without
// calling Quit(), in these cases we call Abort().
void Abort();
// True if this message pump has been aborted.
bool IsAborted();
// Since Run() is never called on Android, and the message loop is run by the
// java Looper, quitting the RunLoop won't join the thread, so we need a
// callback to run when the RunLoop goes idle to let the Java thread know when
// it can safely quit.
void QuitWhenIdle(base::OnceClosure callback);
#endif
#if defined(OS_WIN)
// See method of the same name in the Windows MessagePumpForUI implementation.
void EnableWmQuit();
#endif
};
// Do not add any member variables to MessageLoopForUI! This is important b/c
// MessageLoopForUI is often allocated via MessageLoop(TYPE_UI). Any extra
// data that you need should be stored on the MessageLoop's pump_ instance.
static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForUI),
"MessageLoopForUI should not have extra member variables");
#endif // !defined(OS_NACL)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// MessageLoopForIO extends MessageLoop with methods that are particular to a // MessageLoopForIO extends MessageLoop with methods that are particular to a
// MessageLoop instantiated with TYPE_IO. // MessageLoop instantiated with TYPE_IO.
......
...@@ -1507,29 +1507,6 @@ TEST_F(MessageLoopTest, WmQuitIsIgnored) { ...@@ -1507,29 +1507,6 @@ TEST_F(MessageLoopTest, WmQuitIsIgnored) {
EXPECT_TRUE(task_was_run); EXPECT_TRUE(task_was_run);
} }
TEST_F(MessageLoopTest, WmQuitIsNotIgnoredWithEnableWmQuit) {
MessageLoop loop(MessagePumpType::UI);
static_cast<MessageLoopForUI*>(&loop)->EnableWmQuit();
// Post a WM_QUIT message to the current thread.
::PostQuitMessage(0);
// Post a task to the current thread, with a small delay to make it less
// likely that we process the posted task before looking for WM_* messages.
RunLoop run_loop;
loop.task_runner()->PostDelayedTask(FROM_HERE,
BindOnce(
[](OnceClosure closure) {
ADD_FAILURE();
std::move(closure).Run();
},
run_loop.QuitClosure()),
TestTimeouts::tiny_timeout());
// Run the loop. It should not result in ADD_FAILURE() getting called.
run_loop.Run();
}
TEST_F(MessageLoopTest, PostDelayedTask_SharedTimer_SubPump) { TEST_F(MessageLoopTest, PostDelayedTask_SharedTimer_SubPump) {
MessageLoop message_loop(MessagePumpType::UI); MessageLoop message_loop(MessagePumpType::UI);
......
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
#include "base/mac/scoped_cftyperef.h" #include "base/mac/scoped_cftyperef.h"
#import "base/mac/scoped_nsobject.h" #import "base/mac/scoped_nsobject.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h" #include "base/message_loop/message_loop_current.h"
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "base/test/task_environment.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -145,7 +145,8 @@ void RunTaskInMode(CFRunLoopMode mode, OnceClosure task) { ...@@ -145,7 +145,8 @@ void RunTaskInMode(CFRunLoopMode mode, OnceClosure task) {
// Tests the correct behavior of ScopedPumpMessagesInPrivateModes. // Tests the correct behavior of ScopedPumpMessagesInPrivateModes.
TEST(MessagePumpMacTest, ScopedPumpMessagesInPrivateModes) { TEST(MessagePumpMacTest, ScopedPumpMessagesInPrivateModes) {
MessageLoopForUI message_loop; test::SingleThreadTaskEnvironment task_environment(
test::SingleThreadTaskEnvironment::MainThreadType::UI);
CFRunLoopMode kRegular = kCFRunLoopDefaultMode; CFRunLoopMode kRegular = kCFRunLoopDefaultMode;
CFRunLoopMode kPrivate = CFSTR("NSUnhighlightMenuRunLoopMode"); CFRunLoopMode kPrivate = CFSTR("NSUnhighlightMenuRunLoopMode");
...@@ -193,7 +194,8 @@ TEST(MessagePumpMacTest, ScopedPumpMessagesInPrivateModes) { ...@@ -193,7 +194,8 @@ TEST(MessagePumpMacTest, ScopedPumpMessagesInPrivateModes) {
// Tests that private message loop modes are not pumped while a modal dialog is // Tests that private message loop modes are not pumped while a modal dialog is
// present. // present.
TEST(MessagePumpMacTest, ScopedPumpMessagesAttemptWithModalDialog) { TEST(MessagePumpMacTest, ScopedPumpMessagesAttemptWithModalDialog) {
MessageLoopForUI message_loop; test::SingleThreadTaskEnvironment task_environment(
test::SingleThreadTaskEnvironment::MainThreadType::UI);
{ {
base::ScopedPumpMessagesInPrivateModes allow_private; base::ScopedPumpMessagesInPrivateModes allow_private;
...@@ -239,7 +241,8 @@ TEST(MessagePumpMacTest, ScopedPumpMessagesAttemptWithModalDialog) { ...@@ -239,7 +241,8 @@ TEST(MessagePumpMacTest, ScopedPumpMessagesAttemptWithModalDialog) {
// terminal such as SSH (as opposed to Chromoting) to investigate the issue. // terminal such as SSH (as opposed to Chromoting) to investigate the issue.
// //
TEST(MessagePumpMacTest, DontInvalidateTimerInNativeRunLoop) { TEST(MessagePumpMacTest, DontInvalidateTimerInNativeRunLoop) {
MessageLoopForUI message_loop; test::SingleThreadTaskEnvironment task_environment(
test::SingleThreadTaskEnvironment::MainThreadType::UI);
NSWindow* window = NSWindow* window =
[[[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100) [[[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100)
styleMask:NSBorderlessWindowMask styleMask:NSBorderlessWindowMask
...@@ -291,7 +294,8 @@ TEST(MessagePumpMacTest, DontInvalidateTimerInNativeRunLoop) { ...@@ -291,7 +294,8 @@ TEST(MessagePumpMacTest, DontInvalidateTimerInNativeRunLoop) {
} }
TEST(MessagePumpMacTest, QuitWithModalWindow) { TEST(MessagePumpMacTest, QuitWithModalWindow) {
MessageLoopForUI message_loop; test::SingleThreadTaskEnvironment task_environment(
test::SingleThreadTaskEnvironment::MainThreadType::UI);
NSWindow* window = NSWindow* window =
[[[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100) [[[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100)
styleMask:NSBorderlessWindowMask styleMask:NSBorderlessWindowMask
......
...@@ -146,7 +146,8 @@ class WinSystemMemoryPressureEvaluatorTest : public testing::Test { ...@@ -146,7 +146,8 @@ class WinSystemMemoryPressureEvaluatorTest : public testing::Test {
evaluator->CalculateCurrentPressureLevel()); evaluator->CalculateCurrentPressureLevel());
} }
base::MessageLoopForUI message_loop_; base::test::SingleThreadTaskEnvironment task_environment_{
base::test::SingleThreadTaskEnvironment::MainThreadType::UI};
}; };
// Tests the fundamental direct calculation of memory pressure with automatic // Tests the fundamental direct calculation of memory pressure with automatic
......
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event.h"
#include "base/test/task_environment.h"
#include "base/test/test_timeouts.h" #include "base/test/test_timeouts.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h" #include "base/time/time.h"
...@@ -416,7 +416,8 @@ class FullDuplexAudioSinkSource ...@@ -416,7 +416,8 @@ class FullDuplexAudioSinkSource
class AudioAndroidOutputTest : public testing::Test { class AudioAndroidOutputTest : public testing::Test {
public: public:
AudioAndroidOutputTest() AudioAndroidOutputTest()
: loop_(new base::MessageLoopForUI()), : task_environment_(
base::test::SingleThreadTaskEnvironment::MainThreadType::UI),
audio_manager_(AudioManager::CreateForTesting( audio_manager_(AudioManager::CreateForTesting(
std::make_unique<TestAudioThread>())), std::make_unique<TestAudioThread>())),
audio_manager_device_info_(audio_manager_.get()), audio_manager_device_info_(audio_manager_.get()),
...@@ -574,7 +575,7 @@ class AudioAndroidOutputTest : public testing::Test { ...@@ -574,7 +575,7 @@ class AudioAndroidOutputTest : public testing::Test {
audio_output_stream_ = NULL; audio_output_stream_ = NULL;
} }
std::unique_ptr<base::MessageLoopForUI> loop_; base::test::SingleThreadTaskEnvironment task_environment_;
std::unique_ptr<AudioManager> audio_manager_; std::unique_ptr<AudioManager> audio_manager_;
AudioDeviceInfoAccessorForTests audio_manager_device_info_; AudioDeviceInfoAccessorForTests audio_manager_device_info_;
AudioParameters audio_output_parameters_; AudioParameters audio_output_parameters_;
......
...@@ -4,21 +4,22 @@ ...@@ -4,21 +4,22 @@
#include "media/audio/win/audio_low_latency_output_win.h" #include "media/audio/win/audio_low_latency_output_win.h"
#include <windows.h>
#include <mmsystem.h> #include <mmsystem.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <windows.h>
#include <memory> #include <memory>
#include "base/environment.h" #include "base/environment.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/test/task_environment.h"
#include "base/test/test_timeouts.h" #include "base/test/test_timeouts.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/win/scoped_com_initializer.h" #include "base/win/scoped_com_initializer.h"
#include "media/audio/audio_device_description.h" #include "media/audio/audio_device_description.h"
...@@ -36,6 +37,7 @@ ...@@ -36,6 +37,7 @@
#include "testing/gmock_mutant.h" #include "testing/gmock_mutant.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using ::base::ThreadTaskRunnerHandle;
using ::testing::_; using ::testing::_;
using ::testing::AnyNumber; using ::testing::AnyNumber;
using ::testing::AtLeast; using ::testing::AtLeast;
...@@ -72,10 +74,10 @@ ACTION_P(QuitLoop, task_runner) { ...@@ -72,10 +74,10 @@ ACTION_P(QuitLoop, task_runner) {
class ReadFromFileAudioSource : public AudioOutputStream::AudioSourceCallback { class ReadFromFileAudioSource : public AudioOutputStream::AudioSourceCallback {
public: public:
explicit ReadFromFileAudioSource(const std::string& name) explicit ReadFromFileAudioSource(const std::string& name)
: pos_(0), : pos_(0),
previous_call_time_(base::TimeTicks::Now()), previous_call_time_(base::TimeTicks::Now()),
text_file_(NULL), text_file_(NULL),
elements_to_write_(0) { elements_to_write_(0) {
// Reads a test file from media/test/data directory. // Reads a test file from media/test/data directory.
file_ = ReadTestDataFile(name); file_ = ReadTestDataFile(name);
...@@ -183,9 +185,7 @@ class AudioOutputStreamWrapper { ...@@ -183,9 +185,7 @@ class AudioOutputStreamWrapper {
~AudioOutputStreamWrapper() {} ~AudioOutputStreamWrapper() {}
// Creates AudioOutputStream object using default parameters. // Creates AudioOutputStream object using default parameters.
AudioOutputStream* Create() { AudioOutputStream* Create() { return CreateOutputStream(); }
return CreateOutputStream();
}
// Creates AudioOutputStream object using non-default parameters where the // Creates AudioOutputStream object using non-default parameters where the
// frame size is modified. // frame size is modified.
...@@ -247,7 +247,8 @@ class WASAPIAudioOutputStreamTest : public ::testing::Test { ...@@ -247,7 +247,8 @@ class WASAPIAudioOutputStreamTest : public ::testing::Test {
~WASAPIAudioOutputStreamTest() override { audio_manager_->Shutdown(); } ~WASAPIAudioOutputStreamTest() override { audio_manager_->Shutdown(); }
protected: protected:
base::MessageLoopForUI message_loop_; base::test::SingleThreadTaskEnvironment task_environment_{
base::test::SingleThreadTaskEnvironment::MainThreadType::UI};
std::unique_ptr<AudioManager> audio_manager_; std::unique_ptr<AudioManager> audio_manager_;
}; };
...@@ -381,12 +382,12 @@ TEST_F(WASAPIAudioOutputStreamTest, ValidPacketSize) { ...@@ -381,12 +382,12 @@ TEST_F(WASAPIAudioOutputStreamTest, ValidPacketSize) {
// subsequent callbacks that might arrive. // subsequent callbacks that might arrive.
EXPECT_CALL(source, EXPECT_CALL(source,
OnMoreData(HasValidDelay(packet_duration), _, 0, NotNull())) OnMoreData(HasValidDelay(packet_duration), _, 0, NotNull()))
.WillOnce(DoAll(QuitLoop(message_loop_.task_runner()), .WillOnce(DoAll(QuitLoop(ThreadTaskRunnerHandle::Get()),
Return(aosw.samples_per_packet()))) Return(aosw.samples_per_packet())))
.WillRepeatedly(Return(0)); .WillRepeatedly(Return(0));
aos->Start(&source); aos->Start(&source);
message_loop_.task_runner()->PostDelayedTask( ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(), FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
TestTimeouts::action_timeout()); TestTimeouts::action_timeout());
base::RunLoop().Run(); base::RunLoop().Run();
...@@ -521,12 +522,12 @@ TEST_F(WASAPIAudioOutputStreamTest, ...@@ -521,12 +522,12 @@ TEST_F(WASAPIAudioOutputStreamTest,
// Wait for the first callback and verify its parameters. // Wait for the first callback and verify its parameters.
EXPECT_CALL(source, EXPECT_CALL(source,
OnMoreData(HasValidDelay(packet_duration), _, 0, NotNull())) OnMoreData(HasValidDelay(packet_duration), _, 0, NotNull()))
.WillOnce(DoAll(QuitLoop(message_loop_.task_runner()), .WillOnce(DoAll(QuitLoop(ThreadTaskRunnerHandle::Get()),
Return(aosw.samples_per_packet()))) Return(aosw.samples_per_packet())))
.WillRepeatedly(Return(aosw.samples_per_packet())); .WillRepeatedly(Return(aosw.samples_per_packet()));
aos->Start(&source); aos->Start(&source);
message_loop_.task_runner()->PostDelayedTask( ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(), FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
TestTimeouts::action_timeout()); TestTimeouts::action_timeout());
base::RunLoop().Run(); base::RunLoop().Run();
...@@ -555,12 +556,12 @@ TEST_F(WASAPIAudioOutputStreamTest, ...@@ -555,12 +556,12 @@ TEST_F(WASAPIAudioOutputStreamTest,
// Wait for the first callback and verify its parameters. // Wait for the first callback and verify its parameters.
EXPECT_CALL(source, EXPECT_CALL(source,
OnMoreData(HasValidDelay(packet_duration), _, 0, NotNull())) OnMoreData(HasValidDelay(packet_duration), _, 0, NotNull()))
.WillOnce(DoAll(QuitLoop(message_loop_.task_runner()), .WillOnce(DoAll(QuitLoop(ThreadTaskRunnerHandle::Get()),
Return(aosw.samples_per_packet()))) Return(aosw.samples_per_packet())))
.WillRepeatedly(Return(aosw.samples_per_packet())); .WillRepeatedly(Return(aosw.samples_per_packet()));
aos->Start(&source); aos->Start(&source);
message_loop_.task_runner()->PostDelayedTask( ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(), FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
TestTimeouts::action_timeout()); TestTimeouts::action_timeout());
base::RunLoop().Run(); base::RunLoop().Run();
......
...@@ -15,7 +15,6 @@ fun:*LifecycleNotifier*addObserver* ...@@ -15,7 +15,6 @@ fun:*LifecycleNotifier*addObserver*
fun:*LifecycleNotifier*removeObserver* fun:*LifecycleNotifier*removeObserver*
fun:*toWebInputElement* fun:*toWebInputElement*
type:*base*MessageLoopForIO* type:*base*MessageLoopForIO*
type:*base*MessageLoopForUI*
type:*BlockRefType* type:*BlockRefType*
type:*SkAutoTUnref* type:*SkAutoTUnref*
type:*WDResult* type:*WDResult*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment