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

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

Issue 1832193002: Mojo C++ bindings: refactor SyncHandleWatcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/router.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_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_
« no previous file with comments | « mojo/public/cpp/bindings/lib/router.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