Index: mojo/public/cpp/bindings/lib/sync_handle_registry.h |
diff --git a/mojo/public/cpp/bindings/lib/sync_handle_watcher.h b/mojo/public/cpp/bindings/lib/sync_handle_registry.h |
similarity index 64% |
copy from mojo/public/cpp/bindings/lib/sync_handle_watcher.h |
copy to mojo/public/cpp/bindings/lib/sync_handle_registry.h |
index 65657fe4bbb78679ef551a00d9f5f9c25b8dfbe1..df927dbb543d6c8038b00472c3cb9004f7da5838 100644 |
--- a/mojo/public/cpp/bindings/lib/sync_handle_watcher.h |
+++ b/mojo/public/cpp/bindings/lib/sync_handle_registry.h |
@@ -2,8 +2,8 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_SYNC_HANDLE_WATCHER_H_ |
-#define MOJO_PUBLIC_CPP_BINDINGS_LIB_SYNC_HANDLE_WATCHER_H_ |
+#ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_SYNC_HANDLE_REGISTRY_H_ |
+#define MOJO_PUBLIC_CPP_BINDINGS_LIB_SYNC_HANDLE_REGISTRY_H_ |
#include <unordered_map> |
@@ -16,18 +16,14 @@ |
namespace mojo { |
namespace internal { |
-// SyncHandleWatcher is used to support sync methods. While a sync call is |
-// waiting for response, we would like incoming sync method requests on the same |
-// thread to be able to reenter. We also would like master endpoints to continue |
-// dispatching messages for associated endpoints on different threads. |
-// Therefore, SyncHandleWatcher is used as thread-local storage to register all |
-// handles that need to be watched while waiting for sync call responses. |
+// SyncHandleRegistry is a thread-local storage to register handles that want to |
+// be watched together. |
// |
// This class is not thread safe. |
-class SyncHandleWatcher : public base::MessageLoop::DestructionObserver { |
+class SyncHandleRegistry : public base::MessageLoop::DestructionObserver { |
public: |
// Returns a thread-local object. |
- static SyncHandleWatcher* current(); |
+ static SyncHandleRegistry* current(); |
using HandleCallback = base::Callback<void(MojoResult)>; |
bool RegisterHandle(const Handle& handle, |
@@ -51,8 +47,8 @@ class SyncHandleWatcher : public base::MessageLoop::DestructionObserver { |
}; |
using HandleMap = std::unordered_map<Handle, HandleCallback, HandleHasher>; |
- SyncHandleWatcher(); |
- ~SyncHandleWatcher() override; |
+ SyncHandleRegistry(); |
+ ~SyncHandleRegistry() override; |
// base::MessageLoop::DestructionObserver implementation: |
void WillDestroyCurrentMessageLoop() override; |
@@ -61,12 +57,14 @@ class SyncHandleWatcher : public base::MessageLoop::DestructionObserver { |
ScopedHandle wait_set_handle_; |
+ scoped_refptr<base::RefCountedData<bool>> destroyed_; |
+ |
base::ThreadChecker thread_checker_; |
- DISALLOW_COPY_AND_ASSIGN(SyncHandleWatcher); |
+ DISALLOW_COPY_AND_ASSIGN(SyncHandleRegistry); |
}; |
} // namespace internal |
} // namespace mojo |
-#endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SYNC_HANDLE_WATCHER_H_ |
+#endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SYNC_HANDLE_REGISTRY_H_ |