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/lib/control_message_proxy.h" | 5 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 run_loop_quit_closure_ = run_loop.QuitClosure(); | 156 run_loop_quit_closure_ = run_loop.QuitClosure(); |
157 SendRunMessage( | 157 SendRunMessage( |
158 receiver_, std::move(input_ptr), | 158 receiver_, std::move(input_ptr), |
159 base::Bind(&RunClosure, | 159 base::Bind(&RunClosure, |
160 base::Bind(&ControlMessageProxy::RunFlushForTestingClosure, | 160 base::Bind(&ControlMessageProxy::RunFlushForTestingClosure, |
161 base::Unretained(this))), | 161 base::Unretained(this))), |
162 &context_); | 162 &context_); |
163 run_loop.Run(); | 163 run_loop.Run(); |
164 } | 164 } |
165 | 165 |
| 166 void ControlMessageProxy::SendDisconnectReason(uint32_t custom_reason, |
| 167 const std::string& description) { |
| 168 auto send_disconnect_reason = interface_control::SendDisconnectReason::New(); |
| 169 send_disconnect_reason->custom_reason = custom_reason; |
| 170 send_disconnect_reason->description = description; |
| 171 auto input_ptr = interface_control::RunOrClosePipeInput::New(); |
| 172 input_ptr->set_send_disconnect_reason(std::move(send_disconnect_reason)); |
| 173 SendRunOrClosePipeMessage(receiver_, std::move(input_ptr), &context_); |
| 174 } |
| 175 |
166 void ControlMessageProxy::RunFlushForTestingClosure() { | 176 void ControlMessageProxy::RunFlushForTestingClosure() { |
167 DCHECK(!run_loop_quit_closure_.is_null()); | 177 DCHECK(!run_loop_quit_closure_.is_null()); |
168 base::ResetAndReturn(&run_loop_quit_closure_).Run(); | 178 base::ResetAndReturn(&run_loop_quit_closure_).Run(); |
169 } | 179 } |
170 | 180 |
171 void ControlMessageProxy::OnConnectionError() { | 181 void ControlMessageProxy::OnConnectionError() { |
172 encountered_error_ = true; | 182 encountered_error_ = true; |
173 if (!run_loop_quit_closure_.is_null()) | 183 if (!run_loop_quit_closure_.is_null()) |
174 RunFlushForTestingClosure(); | 184 RunFlushForTestingClosure(); |
175 } | 185 } |
176 | 186 |
177 } // namespace internal | 187 } // namespace internal |
178 } // namespace mojo | 188 } // namespace mojo |
OLD | NEW |