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

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

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/sync_handle_watcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/sync_handle_watcher.cc
diff --git a/mojo/public/cpp/bindings/lib/sync_handle_watcher.cc b/mojo/public/cpp/bindings/lib/sync_handle_watcher.cc
index e259578634b591ede6c622fea8d8a2105df59c4c..44092038e78c0b8328f5a1b3754cba925cf196c2 100644
--- a/mojo/public/cpp/bindings/lib/sync_handle_watcher.cc
+++ b/mojo/public/cpp/bindings/lib/sync_handle_watcher.cc
@@ -18,12 +18,13 @@ SyncHandleWatcher::SyncHandleWatcher(
callback_(callback),
registered_(false),
register_request_count_(0),
+ registry_(SyncHandleRegistry::current()),
destroyed_(new base::RefCountedData<bool>(false)) {}
SyncHandleWatcher::~SyncHandleWatcher() {
DCHECK(thread_checker_.CalledOnValidThread());
if (registered_)
- SyncHandleRegistry::current()->UnregisterHandle(handle_);
+ registry_->UnregisterHandle(handle_);
destroyed_->data = true;
}
@@ -45,8 +46,7 @@ bool SyncHandleWatcher::SyncWatch(const bool* should_stop) {
// to preserve the boolean that WatchAllHandles uses.
auto destroyed = destroyed_;
const bool* should_stop_array[] = {should_stop, &destroyed->data};
- bool result =
- SyncHandleRegistry::current()->WatchAllHandles(should_stop_array, 2);
+ bool result = registry_->WatchAllHandles(should_stop_array, 2);
// This object has been destroyed.
if (destroyed->data)
@@ -59,8 +59,8 @@ bool SyncHandleWatcher::SyncWatch(const bool* should_stop) {
void SyncHandleWatcher::IncrementRegisterCount() {
register_request_count_++;
if (!registered_) {
- registered_ = SyncHandleRegistry::current()->RegisterHandle(
- handle_, handle_signals_, callback_);
+ registered_ =
+ registry_->RegisterHandle(handle_, handle_signals_, callback_);
}
}
@@ -69,7 +69,7 @@ void SyncHandleWatcher::DecrementRegisterCount() {
register_request_count_--;
if (register_request_count_ == 0 && registered_) {
- SyncHandleRegistry::current()->UnregisterHandle(handle_);
+ registry_->UnregisterHandle(handle_);
registered_ = false;
}
}
« no previous file with comments | « mojo/public/cpp/bindings/lib/sync_handle_watcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698