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

Unified Diff: mojo/public/cpp/system/watcher.h

Issue 2480153004: Revert of Remove MessageLoop destruction observer from mojo::Watcher. (Closed)
Patch Set: Created 4 years, 1 month 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/system/tests/watcher_unittest.cc ('k') | mojo/public/cpp/system/watcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/system/watcher.h
diff --git a/mojo/public/cpp/system/watcher.h b/mojo/public/cpp/system/watcher.h
index 815b73b3b50b1d7dc71bbb465587862a2aeb2301..3284154b2d886d97b9ecbde4e23e2255ce121077 100644
--- a/mojo/public/cpp/system/watcher.h
+++ b/mojo/public/cpp/system/watcher.h
@@ -4,6 +4,8 @@
#ifndef MOJO_PUBLIC_CPP_SYSTEM_WATCHER_H_
#define MOJO_PUBLIC_CPP_SYSTEM_WATCHER_H_
+
+#include <memory>
#include "base/callback.h"
#include "base/macros.h"
@@ -34,6 +36,11 @@
//
// |MOJO_RESULT_CANCELLED|: The handle has been closed and the watch has
// been cancelled implicitly.
+ //
+ // |MOJO_RESULT_ABORTED|: Notifications can no longer be delivered for this
+ // watcher for some unspecified reason, e.g., the watching thread may
+ // be shutting down soon. Note that it is still necessary to explicitly
+ // Cancel() the watch in this case.
using ReadyCallback = base::Callback<void(MojoResult result)>;
explicit Watcher(scoped_refptr<base::SingleThreadTaskRunner> runner =
@@ -75,6 +82,9 @@
ReadyCallback ready_callback() const { return callback_; }
private:
+ class MessageLoopObserver;
+ friend class MessageLoopObserver;
+
void OnHandleReady(MojoResult result);
static void CallOnHandleReady(uintptr_t context,
@@ -90,6 +100,8 @@
// Whether |task_runner_| is the same as base::ThreadTaskRunnerHandle::Get()
// for the thread.
const bool is_default_task_runner_;
+
+ std::unique_ptr<MessageLoopObserver> message_loop_observer_;
// A persistent weak reference to this Watcher which can be passed to the
// Dispatcher any time this object should be signalled. Safe to access (but
« no previous file with comments | « mojo/public/cpp/system/tests/watcher_unittest.cc ('k') | mojo/public/cpp/system/watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698