Commit 84dbdd78 authored by Alex Clarke's avatar Alex Clarke Committed by Commit Bot

Remove IsBoundToCurrentThread from MessageLoop public API

A small step towards deleting MessageLoop.

TBR=fdoray@chromium.org

Bug: 891670
Change-Id: I6ca110d71acc5c6385e62f12885c799cf5f01f40
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1635253Reviewed-by: default avatarAlex Clarke <alexclarke@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Commit-Queue: Alex Clarke <alexclarke@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664311}
parent d674463d
...@@ -168,9 +168,6 @@ class BASE_EXPORT MessageLoop { ...@@ -168,9 +168,6 @@ class BASE_EXPORT MessageLoop {
void AddTaskObserver(TaskObserver* task_observer); void AddTaskObserver(TaskObserver* task_observer);
void RemoveTaskObserver(TaskObserver* task_observer); void RemoveTaskObserver(TaskObserver* task_observer);
// Returns true if this is the active MessageLoop for the current thread.
bool IsBoundToCurrentThread() const;
// Returns true if the message loop is idle (ignoring delayed tasks). This is // Returns true if the message loop is idle (ignoring delayed tasks). This is
// the same condition which triggers DoWork() to return false: i.e. // the same condition which triggers DoWork() to return false: i.e.
// out of tasks which can be processed at the current run-level -- there might // out of tasks which can be processed at the current run-level -- there might
...@@ -181,6 +178,9 @@ class BASE_EXPORT MessageLoop { ...@@ -181,6 +178,9 @@ class BASE_EXPORT MessageLoop {
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
protected: protected:
// Returns true if this is the active MessageLoop for the current thread.
bool IsBoundToCurrentThread() const;
using MessagePumpFactoryCallback = using MessagePumpFactoryCallback =
OnceCallback<std::unique_ptr<MessagePump>()>; OnceCallback<std::unique_ptr<MessagePump>()>;
......
...@@ -2234,7 +2234,7 @@ TEST_F(MessageLoopTest, DeleteUnboundLoop) { ...@@ -2234,7 +2234,7 @@ TEST_F(MessageLoopTest, DeleteUnboundLoop) {
std::unique_ptr<MessageLoop> unbound_loop( std::unique_ptr<MessageLoop> unbound_loop(
MessageLoop::CreateUnbound(MessageLoop::TYPE_DEFAULT)); MessageLoop::CreateUnbound(MessageLoop::TYPE_DEFAULT));
unbound_loop.reset(); unbound_loop.reset();
EXPECT_TRUE(loop.IsBoundToCurrentThread()); EXPECT_TRUE(loop.task_runner()->RunsTasksInCurrentSequence());
EXPECT_EQ(loop.task_runner(), ThreadTaskRunnerHandle::Get()); EXPECT_EQ(loop.task_runner(), ThreadTaskRunnerHandle::Get());
} }
......
...@@ -80,7 +80,7 @@ void NativeInit() { ...@@ -80,7 +80,7 @@ void NativeInit() {
bool OnInitThread() { bool OnInitThread() {
DCHECK(g_init_message_loop); DCHECK(g_init_message_loop);
return g_init_message_loop->IsBoundToCurrentThread(); return g_init_message_loop->task_runner()->RunsTasksInCurrentSequence();
} }
// In integrated mode, Cronet native library is built and loaded together with // In integrated mode, Cronet native library is built and loaded together with
......
...@@ -98,7 +98,7 @@ void JNI_CronetTestUtil_PrepareNetworkThread( ...@@ -98,7 +98,7 @@ void JNI_CronetTestUtil_PrepareNetworkThread(
static void CleanupNetworkThreadOnNetworkThread() { static void CleanupNetworkThreadOnNetworkThread() {
DCHECK(g_message_loop); DCHECK(g_message_loop);
DCHECK(g_message_loop->IsBoundToCurrentThread()); DCHECK(g_message_loop->task_runner()->RunsTasksInCurrentSequence());
delete g_message_loop; delete g_message_loop;
g_message_loop = nullptr; g_message_loop = nullptr;
} }
......
...@@ -406,7 +406,8 @@ size_t DiscardableSharedMemoryManager::GetBytesAllocated() { ...@@ -406,7 +406,8 @@ size_t DiscardableSharedMemoryManager::GetBytesAllocated() {
void DiscardableSharedMemoryManager::WillDestroyCurrentMessageLoop() { void DiscardableSharedMemoryManager::WillDestroyCurrentMessageLoop() {
// The mojo thead is going to be destroyed. We should invalidate all related // The mojo thead is going to be destroyed. We should invalidate all related
// weak ptrs and remove the destrunction observer. // weak ptrs and remove the destrunction observer.
DCHECK(mojo_thread_message_loop_->IsBoundToCurrentThread()); DCHECK(
mojo_thread_message_loop_->task_runner()->RunsTasksInCurrentSequence());
DLOG_IF(WARNING, mojo_thread_weak_ptr_factory_.HasWeakPtrs()) DLOG_IF(WARNING, mojo_thread_weak_ptr_factory_.HasWeakPtrs())
<< "Some MojoDiscardableSharedMemoryManagerImpls are still alive. They " << "Some MojoDiscardableSharedMemoryManagerImpls are still alive. They "
"will be leaked."; "will be leaked.";
...@@ -616,7 +617,8 @@ void DiscardableSharedMemoryManager::ScheduleEnforceMemoryPolicy() { ...@@ -616,7 +617,8 @@ void DiscardableSharedMemoryManager::ScheduleEnforceMemoryPolicy() {
void DiscardableSharedMemoryManager::InvalidateMojoThreadWeakPtrs( void DiscardableSharedMemoryManager::InvalidateMojoThreadWeakPtrs(
base::WaitableEvent* event) { base::WaitableEvent* event) {
DCHECK(mojo_thread_message_loop_->IsBoundToCurrentThread()); DCHECK(
mojo_thread_message_loop_->task_runner()->RunsTasksInCurrentSequence());
mojo_thread_weak_ptr_factory_.InvalidateWeakPtrs(); mojo_thread_weak_ptr_factory_.InvalidateWeakPtrs();
mojo_thread_message_loop_->RemoveDestructionObserver(this); mojo_thread_message_loop_->RemoveDestructionObserver(this);
mojo_thread_message_loop_ = base::MessageLoopCurrent::GetNull(); mojo_thread_message_loop_ = base::MessageLoopCurrent::GetNull();
......
...@@ -292,7 +292,7 @@ class GeolocationNetworkProviderTest : public testing::Test { ...@@ -292,7 +292,7 @@ class GeolocationNetworkProviderTest : public testing::Test {
// Tests that fixture members were SetUp correctly. // Tests that fixture members were SetUp correctly.
TEST_F(GeolocationNetworkProviderTest, CreateDestroy) { TEST_F(GeolocationNetworkProviderTest, CreateDestroy) {
EXPECT_TRUE(main_message_loop_.IsBoundToCurrentThread()); EXPECT_TRUE(main_message_loop_.task_runner()->RunsTasksInCurrentSequence());
std::unique_ptr<LocationProvider> provider(CreateProvider(true)); std::unique_ptr<LocationProvider> provider(CreateProvider(true));
EXPECT_TRUE(provider); EXPECT_TRUE(provider);
provider.reset(); provider.reset();
......
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