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

Unified Diff: mojo/public/cpp/bindings/interface_endpoint_client.h

Issue 2358693002: Mojo C++ bindings: make InterfaceEndpointClient observe message loop destruction. (Closed)
Patch Set: . Created 4 years, 3 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 | « no previous file | mojo/public/cpp/bindings/lib/interface_endpoint_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/interface_endpoint_client.h
diff --git a/mojo/public/cpp/bindings/interface_endpoint_client.h b/mojo/public/cpp/bindings/interface_endpoint_client.h
index 4a24a31f8b18f802564bb103ba8f7a2f9ace4dfc..4cdb97f1c14965dee137cb23934899a7536e0419 100644
--- a/mojo/public/cpp/bindings/interface_endpoint_client.h
+++ b/mojo/public/cpp/bindings/interface_endpoint_client.h
@@ -15,6 +15,7 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
+#include "base/message_loop/message_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_checker.h"
#include "mojo/public/cpp/bindings/connection_error_callback.h"
@@ -33,7 +34,8 @@ class InterfaceEndpointController;
// InterfaceEndpointClient handles message sending and receiving of an interface
// endpoint, either the implementation side or the client side.
// It should only be accessed and destructed on the creating thread.
-class InterfaceEndpointClient : public MessageReceiverWithResponder {
+class InterfaceEndpointClient : public MessageReceiverWithResponder,
+ public base::MessageLoop::DestructionObserver {
public:
// |receiver| is okay to be null. If it is not null, it must outlive this
// object.
@@ -144,6 +146,10 @@ class InterfaceEndpointClient : public MessageReceiverWithResponder {
};
bool HandleValidatedMessage(Message* message);
+ void StopObservingIfNecessary();
+
+ // base::MessageLoop::DestructionObserver:
+ void WillDestroyCurrentMessageLoop() override;
ScopedInterfaceEndpointHandle handle_;
std::unique_ptr<AssociatedGroup> associated_group_;
@@ -167,6 +173,8 @@ class InterfaceEndpointClient : public MessageReceiverWithResponder {
internal::ControlMessageProxy control_message_proxy_;
internal::ControlMessageHandler control_message_handler_;
+ bool observing_message_loop_destruction_ = true;
+
base::ThreadChecker thread_checker_;
base::WeakPtrFactory<InterfaceEndpointClient> weak_ptr_factory_;
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/lib/interface_endpoint_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698