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

Side by Side Diff: mojo/public/cpp/bindings/lib/control_message_proxy.cc

Issue 2318793002: Mojo C++ bindings: support disconnect with a reason. (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 unified diff | Download patch
OLDNEW
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
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
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/control_message_proxy.h ('k') | mojo/public/cpp/bindings/lib/interface_endpoint_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698