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

Side by Side Diff: mojo/edk/system/core.cc

Issue 2202893002: Mojo C++ Bindings: Add helpers for bad message reporting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 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
« no previous file with comments | « mojo/edk/system/core.h ('k') | mojo/public/cpp/bindings/lib/message.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/edk/system/core.h" 5 #include "mojo/edk/system/core.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if (!node_controller_) 160 if (!node_controller_)
161 node_controller_.reset(new NodeController(this)); 161 node_controller_.reset(new NodeController(this));
162 return node_controller_.get(); 162 return node_controller_.get();
163 } 163 }
164 164
165 scoped_refptr<Dispatcher> Core::GetDispatcher(MojoHandle handle) { 165 scoped_refptr<Dispatcher> Core::GetDispatcher(MojoHandle handle) {
166 base::AutoLock lock(handles_lock_); 166 base::AutoLock lock(handles_lock_);
167 return handles_.GetDispatcher(handle); 167 return handles_.GetDispatcher(handle);
168 } 168 }
169 169
170 void Core::SetDefaultProcessErrorCallback(
171 const ProcessErrorCallback& callback) {
172 default_process_error_callback_ = callback;
173 }
174
170 void Core::AddChild(base::ProcessHandle process_handle, 175 void Core::AddChild(base::ProcessHandle process_handle,
171 ScopedPlatformHandle platform_handle, 176 ScopedPlatformHandle platform_handle,
172 const std::string& child_token, 177 const std::string& child_token,
173 const ProcessErrorCallback& process_error_callback) { 178 const ProcessErrorCallback& process_error_callback) {
174 GetNodeController()->ConnectToChild(process_handle, 179 GetNodeController()->ConnectToChild(process_handle,
175 std::move(platform_handle), 180 std::move(platform_handle),
176 child_token, 181 child_token,
177 process_error_callback); 182 process_error_callback);
178 } 183 }
179 184
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 MojoResult Core::NotifyBadMessage(MojoMessageHandle message, 770 MojoResult Core::NotifyBadMessage(MojoMessageHandle message,
766 const char* error, 771 const char* error,
767 size_t error_num_bytes) { 772 size_t error_num_bytes) {
768 if (!message) 773 if (!message)
769 return MOJO_RESULT_INVALID_ARGUMENT; 774 return MOJO_RESULT_INVALID_ARGUMENT;
770 775
771 const PortsMessage& ports_message = 776 const PortsMessage& ports_message =
772 reinterpret_cast<MessageForTransit*>(message)->ports_message(); 777 reinterpret_cast<MessageForTransit*>(message)->ports_message();
773 if (ports_message.source_node() == ports::kInvalidNodeName) { 778 if (ports_message.source_node() == ports::kInvalidNodeName) {
774 DVLOG(1) << "Received invalid message from unknown node."; 779 DVLOG(1) << "Received invalid message from unknown node.";
780 if (!default_process_error_callback_.is_null())
781 default_process_error_callback_.Run(std::string(error, error_num_bytes));
775 return MOJO_RESULT_OK; 782 return MOJO_RESULT_OK;
776 } 783 }
777 784
778 GetNodeController()->NotifyBadMessageFrom( 785 GetNodeController()->NotifyBadMessageFrom(
779 ports_message.source_node(), std::string(error, error_num_bytes)); 786 ports_message.source_node(), std::string(error, error_num_bytes));
780 return MOJO_RESULT_OK; 787 return MOJO_RESULT_OK;
781 } 788 }
782 789
783 MojoResult Core::CreateDataPipe( 790 MojoResult Core::CreateDataPipe(
784 const MojoCreateDataPipeOptions* options, 791 const MojoCreateDataPipeOptions* options,
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 std::unique_ptr<NodeController> node_controller) { 1179 std::unique_ptr<NodeController> node_controller) {
1173 // It's OK to leak this reference. At this point we know the IO loop is still 1180 // It's OK to leak this reference. At this point we know the IO loop is still
1174 // running, and we know the NodeController will observe its eventual 1181 // running, and we know the NodeController will observe its eventual
1175 // destruction. This tells the NodeController to delete itself when that 1182 // destruction. This tells the NodeController to delete itself when that
1176 // happens. 1183 // happens.
1177 node_controller.release()->DestroyOnIOThreadShutdown(); 1184 node_controller.release()->DestroyOnIOThreadShutdown();
1178 } 1185 }
1179 1186
1180 } // namespace edk 1187 } // namespace edk
1181 } // namespace mojo 1188 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/core.h ('k') | mojo/public/cpp/bindings/lib/message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698