Commit 6893e151 authored by Han Leon's avatar Han Leon Committed by Commit Bot

[Mojo] Make ThreadSafeInterfacePtr always delete responder of mojo call on caller thread.

ThreadSafeInterfacePtr wraps a non-thread-safe InterfacePtr, it may be
created/used to make mojo function call on another thread other than the
binding thread of the InterfacePtr it wraps.

Currently async calls are posted to the sequence that the InteracePtr is
bound to, and the responses are posted back, but when the InterfacePtr
encounters error or destroyes, it is destroying the response callbacks
directly on the binding thread.

Because the response callbacks are providerd from the caller thread, it
should be better to destroy them also on the caller thread to avoid some
thread hostile issues possibly. This CL aims to do this.

BUG=775395

Change-Id: Ifd289e0c07ec52fd22674c8d049724d102598a8c
Reviewed-on: https://chromium-review.googlesource.com/722719Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarYuzhu Shen <yzshen@chromium.org>
Commit-Queue: Han Leon <leon.han@intel.com>
Cr-Commit-Position: refs/heads/master@{#509656}
parent 7acf34ac
...@@ -217,9 +217,12 @@ class ThreadSafeForwarder : public MessageReceiverWithResponder { ...@@ -217,9 +217,12 @@ class ThreadSafeForwarder : public MessageReceiverWithResponder {
explicit ForwardToCallingThread(std::unique_ptr<MessageReceiver> responder) explicit ForwardToCallingThread(std::unique_ptr<MessageReceiver> responder)
: responder_(std::move(responder)), : responder_(std::move(responder)),
caller_task_runner_(base::SequencedTaskRunnerHandle::Get()) {} caller_task_runner_(base::SequencedTaskRunnerHandle::Get()) {}
~ForwardToCallingThread() override {
caller_task_runner_->DeleteSoon(FROM_HERE, std::move(responder_));
}
private: private:
bool Accept(Message* message) { bool Accept(Message* message) override {
// The current instance will be deleted when this method returns, so we // The current instance will be deleted when this method returns, so we
// have to relinquish the responder's ownership so it does not get // have to relinquish the responder's ownership so it does not get
// deleted. // deleted.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment