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

Unified Diff: mojo/public/cpp/bindings/lib/sync_handle_registry.h

Issue 1900953002: Mojo C++ bindings: make SyncHandleRegistry a ref-counted object. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « mojo/public/cpp/bindings/lib/connector.cc ('k') | mojo/public/cpp/bindings/lib/sync_handle_registry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/sync_handle_registry.h
diff --git a/mojo/public/cpp/bindings/lib/sync_handle_registry.h b/mojo/public/cpp/bindings/lib/sync_handle_registry.h
index df927dbb543d6c8038b00472c3cb9004f7da5838..d6b8c38e0ce2843b3cb57561660273a11c8bc616 100644
--- a/mojo/public/cpp/bindings/lib/sync_handle_registry.h
+++ b/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);
« no previous file with comments | « mojo/public/cpp/bindings/lib/connector.cc ('k') | mojo/public/cpp/bindings/lib/sync_handle_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698