Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(512)

Unified Diff: mojo/public/cpp/bindings/lib/connector.cc

Issue 2818533003: Make nesting/running states a RunLoop rather than a MessageLoop concept. (Closed)
Patch Set: disable more checks Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/lib/connector.cc
diff --git a/mojo/public/cpp/bindings/lib/connector.cc b/mojo/public/cpp/bindings/lib/connector.cc
index d93e45ed938cd9455222aed5855af75998408ab7..c877200662df96500723240b7aab9c9800cd363b 100644
--- a/mojo/public/cpp/bindings/lib/connector.cc
+++ b/mojo/public/cpp/bindings/lib/connector.cc
@@ -14,6 +14,7 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread_local.h"
#include "mojo/public/cpp/bindings/lib/may_auto_lock.h"
@@ -27,9 +28,8 @@ namespace {
// The NestingObserver for each thread. Note that this is always a
// Connector::MessageLoopNestingObserver; we use the base type here because that
// subclass is private to Connector.
-base::LazyInstance<
- base::ThreadLocalPointer<base::MessageLoop::NestingObserver>>::Leaky
- g_tls_nesting_observer = LAZY_INSTANCE_INITIALIZER;
+base::LazyInstance<base::ThreadLocalPointer<base::RunLoop::NestingObserver>>::
+ Leaky g_tls_nesting_observer = LAZY_INSTANCE_INITIALIZER;
} // namespace
@@ -54,25 +54,25 @@ class Connector::ActiveDispatchTracker {
// Watches the MessageLoop on the current thread. Notifies the current chain of
// ActiveDispatchTrackers when a nested message loop is started.
class Connector::MessageLoopNestingObserver
- : public base::MessageLoop::NestingObserver,
+ : public base::RunLoop::NestingObserver,
public base::MessageLoop::DestructionObserver {
public:
MessageLoopNestingObserver() {
- base::MessageLoop::current()->AddNestingObserver(this);
+ base::RunLoop::AddNestingObserverOnCurrentThread(this);
base::MessageLoop::current()->AddDestructionObserver(this);
}
~MessageLoopNestingObserver() override {}
- // base::MessageLoop::NestingObserver:
- void OnBeginNestedMessageLoop() override {
+ // base::RunLoop::NestingObserver:
+ void OnBeginNestedRunLoop() override {
if (top_tracker_)
top_tracker_->NotifyBeginNesting();
}
// base::MessageLoop::DestructionObserver:
void WillDestroyCurrentMessageLoop() override {
- base::MessageLoop::current()->RemoveNestingObserver(this);
+ base::RunLoop::RemoveNestingObserverOnCurrentThread(this);
base::MessageLoop::current()->RemoveDestructionObserver(this);
DCHECK_EQ(this, g_tls_nesting_observer.Get().Get());
g_tls_nesting_observer.Get().Set(nullptr);
@@ -80,8 +80,7 @@ class Connector::MessageLoopNestingObserver
}
static MessageLoopNestingObserver* GetForThread() {
- if (!base::MessageLoop::current() ||
- !base::MessageLoop::current()->nesting_allowed())
+ if (!base::RunLoop::IsNestingAllowedOnCurrentThread())
return nullptr;
auto* observer = static_cast<MessageLoopNestingObserver*>(
g_tls_nesting_observer.Get().Get());

Powered by Google App Engine
This is Rietveld 408576698