OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 std::string* service_name) { | 312 std::string* service_name) { |
313 // Read the token from the pipe. | 313 // Read the token from the pipe. |
314 CheckedReadFile(pipe_read, token, sizeof(*token)); | 314 CheckedReadFile(pipe_read, token, sizeof(*token)); |
315 | 315 |
316 // Read the service name from the pipe. | 316 // Read the service name from the pipe. |
317 uint32_t service_name_length; | 317 uint32_t service_name_length; |
318 CheckedReadFile(pipe_read, &service_name_length, sizeof(service_name_length)); | 318 CheckedReadFile(pipe_read, &service_name_length, sizeof(service_name_length)); |
319 DCHECK_LT(service_name_length, | 319 DCHECK_LT(service_name_length, |
320 implicit_cast<uint32_t>(BOOTSTRAP_MAX_NAME_LEN)); | 320 implicit_cast<uint32_t>(BOOTSTRAP_MAX_NAME_LEN)); |
321 | 321 |
322 if (service_name_length > 0) { | 322 service_name->resize(service_name_length); |
323 service_name->resize(service_name_length); | 323 if (!service_name->empty()) { |
324 CheckedReadFile(pipe_read, &(*service_name)[0], service_name_length); | 324 CheckedReadFile(pipe_read, &(*service_name)[0], service_name_length); |
325 } | 325 } |
326 } | 326 } |
327 | 327 |
328 // static | 328 // static |
329 void ChildPortHandshake::RunClientInternal_SendCheckIn( | 329 void ChildPortHandshake::RunClientInternal_SendCheckIn( |
330 const std::string& service_name, | 330 const std::string& service_name, |
331 child_port_token_t token, | 331 child_port_token_t token, |
332 mach_port_t port, | 332 mach_port_t port, |
333 mach_msg_type_name_t right_type) { | 333 mach_msg_type_name_t right_type) { |
334 // Get a send right to the server by looking up the service with the bootstrap | 334 // Get a send right to the server by looking up the service with the bootstrap |
335 // server by name. | 335 // server by name. |
336 mach_port_t server_port; | 336 mach_port_t server_port; |
337 kern_return_t kr = | 337 kern_return_t kr = |
338 bootstrap_look_up(bootstrap_port, service_name.c_str(), &server_port); | 338 bootstrap_look_up(bootstrap_port, service_name.c_str(), &server_port); |
339 BOOTSTRAP_CHECK(kr == BOOTSTRAP_SUCCESS, kr) << "bootstrap_look_up"; | 339 BOOTSTRAP_CHECK(kr == BOOTSTRAP_SUCCESS, kr) << "bootstrap_look_up"; |
340 base::mac::ScopedMachSendRight server_port_owner(server_port); | 340 base::mac::ScopedMachSendRight server_port_owner(server_port); |
341 | 341 |
342 // Check in with the server. | 342 // Check in with the server. |
343 kr = child_port_check_in(server_port, token, port, right_type); | 343 kr = child_port_check_in(server_port, token, port, right_type); |
344 MACH_CHECK(kr == KERN_SUCCESS, kr) << "child_port_check_in"; | 344 MACH_CHECK(kr == KERN_SUCCESS, kr) << "child_port_check_in"; |
345 } | 345 } |
346 | 346 |
347 } // namespace crashpad | 347 } // namespace crashpad |
OLD | NEW |