| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "mojo/public/cpp/bindings/interface_endpoint_client.h" | 5 #include "mojo/public/cpp/bindings/interface_endpoint_client.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 class ResponderThunk : public MessageReceiverWithStatus { | 39 class ResponderThunk : public MessageReceiverWithStatus { |
| 40 public: | 40 public: |
| 41 explicit ResponderThunk( | 41 explicit ResponderThunk( |
| 42 const base::WeakPtr<InterfaceEndpointClient>& endpoint_client, | 42 const base::WeakPtr<InterfaceEndpointClient>& endpoint_client, |
| 43 scoped_refptr<base::SingleThreadTaskRunner> runner) | 43 scoped_refptr<base::SingleThreadTaskRunner> runner) |
| 44 : endpoint_client_(endpoint_client), | 44 : endpoint_client_(endpoint_client), |
| 45 accept_was_invoked_(false), | 45 accept_was_invoked_(false), |
| 46 task_runner_(std::move(runner)) {} | 46 task_runner_(std::move(runner)) {} |
| 47 ~ResponderThunk() override { | 47 ~ResponderThunk() override { |
| 48 if (!accept_was_invoked_) { | 48 if (!accept_was_invoked_) { |
| 49 // The Mojo application handled a message that was expecting a response | 49 // The Service handled a message that was expecting a response |
| 50 // but did not send a response. | 50 // but did not send a response. |
| 51 // We raise an error to signal the calling application that an error | 51 // We raise an error to signal the calling application that an error |
| 52 // condition occurred. Without this the calling application would have no | 52 // condition occurred. Without this the calling application would have no |
| 53 // way of knowing it should stop waiting for a response. | 53 // way of knowing it should stop waiting for a response. |
| 54 if (task_runner_->RunsTasksOnCurrentThread()) { | 54 if (task_runner_->RunsTasksOnCurrentThread()) { |
| 55 // Please note that even if this code is run from a different task | 55 // Please note that even if this code is run from a different task |
| 56 // runner on the same thread as |task_runner_|, it is okay to directly | 56 // runner on the same thread as |task_runner_|, it is okay to directly |
| 57 // call InterfaceEndpointClient::RaiseError(), because it will raise | 57 // call InterfaceEndpointClient::RaiseError(), because it will raise |
| 58 // error from the correct task runner asynchronously. | 58 // error from the correct task runner asynchronously. |
| 59 if (endpoint_client_) { | 59 if (endpoint_client_) { |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 observing_message_loop_destruction_ = false; | 347 observing_message_loop_destruction_ = false; |
| 348 base::MessageLoop::current()->RemoveDestructionObserver(this); | 348 base::MessageLoop::current()->RemoveDestructionObserver(this); |
| 349 } | 349 } |
| 350 | 350 |
| 351 void InterfaceEndpointClient::WillDestroyCurrentMessageLoop() { | 351 void InterfaceEndpointClient::WillDestroyCurrentMessageLoop() { |
| 352 StopObservingIfNecessary(); | 352 StopObservingIfNecessary(); |
| 353 NotifyError(); | 353 NotifyError(); |
| 354 } | 354 } |
| 355 | 355 |
| 356 } // namespace mojo | 356 } // namespace mojo |
| OLD | NEW |