OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_THREAD_SAFE_INTERFACE_PTR_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_THREAD_SAFE_INTERFACE_PTR_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_THREAD_SAFE_INTERFACE_PTR_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_THREAD_SAFE_INTERFACE_PTR_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // AssociatedInterfaceRequest hasn't been sent. | 66 // AssociatedInterfaceRequest hasn't been sent. |
67 DCHECK(associated_group_.GetController()); | 67 DCHECK(associated_group_.GetController()); |
68 message->SerializeAssociatedEndpointHandles( | 68 message->SerializeAssociatedEndpointHandles( |
69 associated_group_.GetController()); | 69 associated_group_.GetController()); |
70 } | 70 } |
71 task_runner_->PostTask(FROM_HERE, | 71 task_runner_->PostTask(FROM_HERE, |
72 base::Bind(forward_, base::Passed(message))); | 72 base::Bind(forward_, base::Passed(message))); |
73 return true; | 73 return true; |
74 } | 74 } |
75 | 75 |
76 bool AcceptWithResponder(Message* message, | 76 bool AcceptWithResponder( |
77 MessageReceiver* response_receiver) override { | 77 Message* message, |
| 78 std::unique_ptr<MessageReceiver> response_receiver) override { |
78 if (!message->associated_endpoint_handles()->empty()) { | 79 if (!message->associated_endpoint_handles()->empty()) { |
79 // Please see comment for the DCHECK in the previous method. | 80 // Please see comment for the DCHECK in the previous method. |
80 DCHECK(associated_group_.GetController()); | 81 DCHECK(associated_group_.GetController()); |
81 message->SerializeAssociatedEndpointHandles( | 82 message->SerializeAssociatedEndpointHandles( |
82 associated_group_.GetController()); | 83 associated_group_.GetController()); |
83 } | 84 } |
84 auto responder = base::MakeUnique<ForwardToCallingThread>( | 85 auto responder = |
85 base::WrapUnique(response_receiver)); | 86 base::MakeUnique<ForwardToCallingThread>(std::move(response_receiver)); |
86 task_runner_->PostTask( | 87 task_runner_->PostTask( |
87 FROM_HERE, base::Bind(forward_with_responder_, base::Passed(message), | 88 FROM_HERE, base::Bind(forward_with_responder_, base::Passed(message), |
88 base::Passed(&responder))); | 89 base::Passed(&responder))); |
89 return true; | 90 return true; |
90 } | 91 } |
91 | 92 |
92 class ForwardToCallingThread : public MessageReceiver { | 93 class ForwardToCallingThread : public MessageReceiver { |
93 public: | 94 public: |
94 explicit ForwardToCallingThread(std::unique_ptr<MessageReceiver> responder) | 95 explicit ForwardToCallingThread(std::unique_ptr<MessageReceiver> responder) |
95 : responder_(std::move(responder)), | 96 : responder_(std::move(responder)), |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 using ThreadSafeAssociatedInterfacePtr = | 270 using ThreadSafeAssociatedInterfacePtr = |
270 ThreadSafeInterfacePtrBase<AssociatedInterfacePtr<Interface>>; | 271 ThreadSafeInterfacePtrBase<AssociatedInterfacePtr<Interface>>; |
271 | 272 |
272 template <typename Interface> | 273 template <typename Interface> |
273 using ThreadSafeInterfacePtr = | 274 using ThreadSafeInterfacePtr = |
274 ThreadSafeInterfacePtrBase<InterfacePtr<Interface>>; | 275 ThreadSafeInterfacePtrBase<InterfacePtr<Interface>>; |
275 | 276 |
276 } // namespace mojo | 277 } // namespace mojo |
277 | 278 |
278 #endif // MOJO_PUBLIC_CPP_BINDINGS_THREAD_SAFE_INTERFACE_PTR_H_ | 279 #endif // MOJO_PUBLIC_CPP_BINDINGS_THREAD_SAFE_INTERFACE_PTR_H_ |
OLD | NEW |