diff options
Diffstat (limited to 'chromium/mojo/public/cpp/bindings/lib/sync_handle_registry.h')
-rw-r--r-- | chromium/mojo/public/cpp/bindings/lib/sync_handle_registry.h | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/chromium/mojo/public/cpp/bindings/lib/sync_handle_registry.h b/chromium/mojo/public/cpp/bindings/lib/sync_handle_registry.h index df927dbb543..d6b8c38e0ce 100644 --- a/chromium/mojo/public/cpp/bindings/lib/sync_handle_registry.h +++ b/chromium/mojo/public/cpp/bindings/lib/sync_handle_registry.h @@ -9,7 +9,7 @@ #include "base/callback.h" #include "base/macros.h" -#include "base/message_loop/message_loop.h" +#include "base/memory/ref_counted.h" #include "base/threading/thread_checker.h" #include "mojo/public/cpp/system/core.h" @@ -20,10 +20,10 @@ namespace internal { // be watched together. // // This class is not thread safe. -class SyncHandleRegistry : public base::MessageLoop::DestructionObserver { +class SyncHandleRegistry : public base::RefCounted<SyncHandleRegistry> { public: // Returns a thread-local object. - static SyncHandleRegistry* current(); + static scoped_refptr<SyncHandleRegistry> current(); using HandleCallback = base::Callback<void(MojoResult)>; bool RegisterHandle(const Handle& handle, @@ -40,6 +40,8 @@ class SyncHandleRegistry : public base::MessageLoop::DestructionObserver { bool WatchAllHandles(const bool* should_stop[], size_t count); private: + friend class base::RefCounted<SyncHandleRegistry>; + struct HandleHasher { size_t operator()(const Handle& handle) const { return std::hash<uint32_t>()(static_cast<uint32_t>(handle.value())); @@ -48,17 +50,12 @@ class SyncHandleRegistry : public base::MessageLoop::DestructionObserver { using HandleMap = std::unordered_map<Handle, HandleCallback, HandleHasher>; SyncHandleRegistry(); - ~SyncHandleRegistry() override; - - // base::MessageLoop::DestructionObserver implementation: - void WillDestroyCurrentMessageLoop() override; + ~SyncHandleRegistry(); HandleMap handles_; ScopedHandle wait_set_handle_; - scoped_refptr<base::RefCountedData<bool>> destroyed_; - base::ThreadChecker thread_checker_; DISALLOW_COPY_AND_ASSIGN(SyncHandleRegistry); |