summaryrefslogtreecommitdiffstats
path: root/chromium/base/message_loop
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/base/message_loop')
-rw-r--r--chromium/base/message_loop/message_loop.cc41
-rw-r--r--chromium/base/message_loop/message_loop.h57
-rw-r--r--chromium/base/message_loop/message_loop_unittest.cc25
-rw-r--r--chromium/base/message_loop/message_pump_io_ios_unittest.cc1
-rw-r--r--chromium/base/message_loop/message_pump_mac_unittest.mm14
-rw-r--r--chromium/base/message_loop/message_pump_perftest.cc9
6 files changed, 13 insertions, 134 deletions
diff --git a/chromium/base/message_loop/message_loop.cc b/chromium/base/message_loop/message_loop.cc
index a8a66308a1c..7e0b9c5520d 100644
--- a/chromium/base/message_loop/message_loop.cc
+++ b/chromium/base/message_loop/message_loop.cc
@@ -161,45 +161,4 @@ void MessageLoop::SetTaskRunner(
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
diff --git a/chromium/base/message_loop/message_loop.h b/chromium/base/message_loop/message_loop.h
index cc760ffab17..fa5f214c588 100644
--- a/chromium/base/message_loop/message_loop.h
+++ b/chromium/base/message_loop/message_loop.h
@@ -23,10 +23,6 @@
namespace base {
-namespace internal {
-class MessageLoopThreadDelegate;
-} // namespace internal
-
class MessageLoopImpl;
class MessagePump;
class TaskObserver;
@@ -160,7 +156,6 @@ class BASE_EXPORT MessageLoop {
friend class MessageLoopTypedTest;
friend class ScheduleWorkTest;
friend class Thread;
- friend class internal::MessageLoopThreadDelegate;
friend class sequence_manager::internal::SequenceManagerImpl;
FRIEND_TEST_ALL_PREFIXES(MessageLoopTest, DeleteUnboundLoop);
@@ -202,58 +197,6 @@ class BASE_EXPORT 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
// MessageLoop instantiated with TYPE_IO.
diff --git a/chromium/base/message_loop/message_loop_unittest.cc b/chromium/base/message_loop/message_loop_unittest.cc
index 9d5e92d50bb..02cb94b5b47 100644
--- a/chromium/base/message_loop/message_loop_unittest.cc
+++ b/chromium/base/message_loop/message_loop_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/message_loop/message_loop.h"
+
#include <stddef.h>
#include <stdint.h>
@@ -1507,29 +1509,6 @@ TEST_F(MessageLoopTest, WmQuitIsIgnored) {
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) {
MessageLoop message_loop(MessagePumpType::UI);
diff --git a/chromium/base/message_loop/message_pump_io_ios_unittest.cc b/chromium/base/message_loop/message_pump_io_ios_unittest.cc
index 4d15d44db32..aec10012a7c 100644
--- a/chromium/base/message_loop/message_pump_io_ios_unittest.cc
+++ b/chromium/base/message_loop/message_pump_io_ios_unittest.cc
@@ -7,6 +7,7 @@
#include <unistd.h>
#include "base/macros.h"
+#include "base/message_loop/message_pump_for_io.h"
#include "base/posix/eintr_wrapper.h"
#include "base/test/gtest_util.h"
#include "base/threading/thread.h"
diff --git a/chromium/base/message_loop/message_pump_mac_unittest.mm b/chromium/base/message_loop/message_pump_mac_unittest.mm
index d5ff5c9fd59..85f4779868a 100644
--- a/chromium/base/message_loop/message_pump_mac_unittest.mm
+++ b/chromium/base/message_loop/message_pump_mac_unittest.mm
@@ -9,9 +9,9 @@
#include "base/mac/scoped_cftyperef.h"
#import "base/mac/scoped_nsobject.h"
#include "base/macros.h"
-#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/test/bind_test_util.h"
+#include "base/test/task_environment.h"
#include "base/threading/thread_task_runner_handle.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -145,7 +145,8 @@ void RunTaskInMode(CFRunLoopMode mode, OnceClosure task) {
// Tests the correct behavior of ScopedPumpMessagesInPrivateModes.
TEST(MessagePumpMacTest, ScopedPumpMessagesInPrivateModes) {
- MessageLoopForUI message_loop;
+ test::SingleThreadTaskEnvironment task_environment(
+ test::SingleThreadTaskEnvironment::MainThreadType::UI);
CFRunLoopMode kRegular = kCFRunLoopDefaultMode;
CFRunLoopMode kPrivate = CFSTR("NSUnhighlightMenuRunLoopMode");
@@ -193,7 +194,8 @@ TEST(MessagePumpMacTest, ScopedPumpMessagesInPrivateModes) {
// Tests that private message loop modes are not pumped while a modal dialog is
// present.
TEST(MessagePumpMacTest, ScopedPumpMessagesAttemptWithModalDialog) {
- MessageLoopForUI message_loop;
+ test::SingleThreadTaskEnvironment task_environment(
+ test::SingleThreadTaskEnvironment::MainThreadType::UI);
{
base::ScopedPumpMessagesInPrivateModes allow_private;
@@ -239,7 +241,8 @@ TEST(MessagePumpMacTest, ScopedPumpMessagesAttemptWithModalDialog) {
// terminal such as SSH (as opposed to Chromoting) to investigate the issue.
//
TEST(MessagePumpMacTest, DontInvalidateTimerInNativeRunLoop) {
- MessageLoopForUI message_loop;
+ test::SingleThreadTaskEnvironment task_environment(
+ test::SingleThreadTaskEnvironment::MainThreadType::UI);
NSWindow* window =
[[[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100)
styleMask:NSBorderlessWindowMask
@@ -291,7 +294,8 @@ TEST(MessagePumpMacTest, DontInvalidateTimerInNativeRunLoop) {
}
TEST(MessagePumpMacTest, QuitWithModalWindow) {
- MessageLoopForUI message_loop;
+ test::SingleThreadTaskEnvironment task_environment(
+ test::SingleThreadTaskEnvironment::MainThreadType::UI);
NSWindow* window =
[[[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100)
styleMask:NSBorderlessWindowMask
diff --git a/chromium/base/message_loop/message_pump_perftest.cc b/chromium/base/message_loop/message_pump_perftest.cc
index 1af026f7cd2..7c7cdd4decd 100644
--- a/chromium/base/message_loop/message_pump_perftest.cc
+++ b/chromium/base/message_loop/message_pump_perftest.cc
@@ -9,7 +9,6 @@
#include "base/bind_helpers.h"
#include "base/format_macros.h"
#include "base/memory/ptr_util.h"
-#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h"
#include "base/message_loop/message_pump_type.h"
#include "base/single_thread_task_runner.h"
@@ -98,12 +97,7 @@ class ScheduleWorkTest : public testing::Test {
target_.reset(new Thread("test"));
Thread::Options options(target_type, 0u);
-
- std::unique_ptr<MessageLoop> message_loop =
- MessageLoop::CreateUnbound(target_type);
- message_loop_ = message_loop.get();
- options.delegate =
- new internal::MessageLoopThreadDelegate(std::move(message_loop));
+ options.message_pump_type = target_type;
target_->StartWithOptions(options);
// Without this, it's possible for the scheduling threads to start and run
@@ -203,7 +197,6 @@ class ScheduleWorkTest : public testing::Test {
private:
std::unique_ptr<Thread> target_;
- MessageLoop* message_loop_;
#if defined(OS_ANDROID)
std::unique_ptr<JavaHandlerThreadForTest> java_thread_;
#endif