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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 const base::FilePath& database, | 510 const base::FilePath& database, |
511 const std::string& url, | 511 const std::string& url, |
512 const std::map<std::string, std::string>& annotations, | 512 const std::map<std::string, std::string>& annotations, |
513 const std::vector<std::string>& arguments, | 513 const std::vector<std::string>& arguments, |
514 bool restartable) { | 514 bool restartable) { |
515 DCHECK(!exception_port_.is_valid()); | 515 DCHECK(!exception_port_.is_valid()); |
516 | 516 |
517 // The “restartable” behavior can only be selected on OS X 10.10 and later. In | 517 // The “restartable” behavior can only be selected on OS X 10.10 and later. In |
518 // previous OS versions, if the initial client were to crash while attempting | 518 // previous OS versions, if the initial client were to crash while attempting |
519 // to restart the handler, it would become an unkillable process. | 519 // to restart the handler, it would become an unkillable process. |
520 exception_port_ = HandlerStarter::InitialStart( | 520 base::mac::ScopedMachSendRight exception_port(HandlerStarter::InitialStart( |
521 handler, | 521 handler, |
522 database, | 522 database, |
523 url, | 523 url, |
524 annotations, | 524 annotations, |
525 arguments, | 525 arguments, |
526 restartable && MacOSXMinorVersion() >= 10); | 526 restartable && MacOSXMinorVersion() >= 10)); |
527 if (!exception_port_.is_valid()) { | 527 if (!exception_port.is_valid()) { |
528 return false; | 528 return false; |
529 } | 529 } |
530 | 530 |
| 531 SetHandlerMachPort(exception_port.Pass()); |
531 return true; | 532 return true; |
532 } | 533 } |
533 | 534 |
| 535 bool CrashpadClient::SetHandlerMachService(const std::string& service_name) { |
| 536 base::mac::ScopedMachSendRight exception_port(BootstrapLookUp(service_name)); |
| 537 if (!exception_port.is_valid()) { |
| 538 return false; |
| 539 } |
| 540 |
| 541 SetHandlerMachPort(exception_port.Pass()); |
| 542 return true; |
| 543 } |
| 544 |
| 545 void CrashpadClient::SetHandlerMachPort( |
| 546 base::mac::ScopedMachSendRight exception_port) { |
| 547 DCHECK(exception_port.is_valid()); |
| 548 exception_port_ = exception_port.Pass(); |
| 549 } |
| 550 |
534 bool CrashpadClient::UseHandler() { | 551 bool CrashpadClient::UseHandler() { |
535 DCHECK(exception_port_.is_valid()); | 552 DCHECK(exception_port_.is_valid()); |
536 | 553 |
537 return SetCrashExceptionPorts(exception_port_.get()); | 554 return SetCrashExceptionPorts(exception_port_.get()); |
538 } | 555 } |
539 | 556 |
540 // static | 557 // static |
541 void CrashpadClient::UseSystemDefaultHandler() { | 558 void CrashpadClient::UseSystemDefaultHandler() { |
542 base::mac::ScopedMachSendRight | 559 base::mac::ScopedMachSendRight |
543 system_crash_reporter_handler(SystemCrashReporterHandler()); | 560 system_crash_reporter_handler(SystemCrashReporterHandler()); |
544 | 561 |
545 // Proceed even if SystemCrashReporterHandler() failed, setting MACH_PORT_NULL | 562 // Proceed even if SystemCrashReporterHandler() failed, setting MACH_PORT_NULL |
546 // to clear the current exception ports. | 563 // to clear the current exception ports. |
547 if (!SetCrashExceptionPorts(system_crash_reporter_handler.get())) { | 564 if (!SetCrashExceptionPorts(system_crash_reporter_handler.get())) { |
548 SetCrashExceptionPorts(MACH_PORT_NULL); | 565 SetCrashExceptionPorts(MACH_PORT_NULL); |
549 } | 566 } |
550 } | 567 } |
551 | 568 |
552 } // namespace crashpad | 569 } // namespace crashpad |
OLD | NEW |