| 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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 std::map<std::string, std::string> annotations_; | 516 std::map<std::string, std::string> annotations_; |
| 517 std::vector<std::string> arguments_; | 517 std::vector<std::string> arguments_; |
| 518 base::mac::ScopedMachReceiveRight notify_port_; | 518 base::mac::ScopedMachReceiveRight notify_port_; |
| 519 uint64_t last_start_time_; | 519 uint64_t last_start_time_; |
| 520 | 520 |
| 521 DISALLOW_COPY_AND_ASSIGN(HandlerStarter); | 521 DISALLOW_COPY_AND_ASSIGN(HandlerStarter); |
| 522 }; | 522 }; |
| 523 | 523 |
| 524 } // namespace | 524 } // namespace |
| 525 | 525 |
| 526 CrashpadClient::CrashpadClient() | 526 CrashpadClient::CrashpadClient() { |
| 527 : exception_port_() { | |
| 528 } | 527 } |
| 529 | 528 |
| 530 CrashpadClient::~CrashpadClient() { | 529 CrashpadClient::~CrashpadClient() { |
| 531 } | 530 } |
| 532 | 531 |
| 533 bool CrashpadClient::StartHandler( | 532 bool CrashpadClient::StartHandler( |
| 534 const base::FilePath& handler, | 533 const base::FilePath& handler, |
| 535 const base::FilePath& database, | 534 const base::FilePath& database, |
| 536 const base::FilePath& metrics_dir, | 535 const base::FilePath& metrics_dir, |
| 537 const std::string& url, | 536 const std::string& url, |
| 538 const std::map<std::string, std::string>& annotations, | 537 const std::map<std::string, std::string>& annotations, |
| 539 const std::vector<std::string>& arguments, | 538 const std::vector<std::string>& arguments, |
| 540 bool restartable) { | 539 bool restartable, |
| 541 DCHECK(!exception_port_.is_valid()); | 540 bool asynchronous_start) { |
| 542 | |
| 543 // The “restartable” behavior can only be selected on OS X 10.10 and later. In | 541 // The “restartable” behavior can only be selected on OS X 10.10 and later. In |
| 544 // previous OS versions, if the initial client were to crash while attempting | 542 // previous OS versions, if the initial client were to crash while attempting |
| 545 // to restart the handler, it would become an unkillable process. | 543 // to restart the handler, it would become an unkillable process. |
| 546 base::mac::ScopedMachSendRight exception_port( | 544 base::mac::ScopedMachSendRight exception_port( |
| 547 HandlerStarter::InitialStart(handler, | 545 HandlerStarter::InitialStart(handler, |
| 548 database, | 546 database, |
| 549 metrics_dir, | 547 metrics_dir, |
| 550 url, | 548 url, |
| 551 annotations, | 549 annotations, |
| 552 arguments, | 550 arguments, |
| 553 restartable && MacOSXMinorVersion() >= 10)); | 551 restartable && MacOSXMinorVersion() >= 10)); |
| 554 if (!exception_port.is_valid()) { | 552 if (!exception_port.is_valid()) { |
| 555 return false; | 553 return false; |
| 556 } | 554 } |
| 557 | 555 |
| 558 SetHandlerMachPort(std::move(exception_port)); | 556 SetHandlerMachPort(std::move(exception_port)); |
| 559 return true; | 557 return true; |
| 560 } | 558 } |
| 561 | 559 |
| 562 bool CrashpadClient::SetHandlerMachService(const std::string& service_name) { | 560 bool CrashpadClient::SetHandlerMachService(const std::string& service_name) { |
| 563 base::mac::ScopedMachSendRight exception_port(BootstrapLookUp(service_name)); | 561 base::mac::ScopedMachSendRight exception_port(BootstrapLookUp(service_name)); |
| 564 if (!exception_port.is_valid()) { | 562 if (!exception_port.is_valid()) { |
| 565 return false; | 563 return false; |
| 566 } | 564 } |
| 567 | 565 |
| 568 SetHandlerMachPort(std::move(exception_port)); | 566 SetHandlerMachPort(std::move(exception_port)); |
| 569 return true; | 567 return true; |
| 570 } | 568 } |
| 571 | 569 |
| 572 void CrashpadClient::SetHandlerMachPort( | 570 bool CrashpadClient::SetHandlerMachPort( |
| 573 base::mac::ScopedMachSendRight exception_port) { | 571 base::mac::ScopedMachSendRight exception_port) { |
| 574 DCHECK(exception_port.is_valid()); | 572 DCHECK(exception_port.is_valid()); |
| 575 exception_port_ = std::move(exception_port); | 573 return SetCrashExceptionPorts(exception_port.get()); |
| 576 } | |
| 577 | |
| 578 bool CrashpadClient::UseHandler() { | |
| 579 DCHECK(exception_port_.is_valid()); | |
| 580 | |
| 581 return SetCrashExceptionPorts(exception_port_.get()); | |
| 582 } | 574 } |
| 583 | 575 |
| 584 // static | 576 // static |
| 585 void CrashpadClient::UseSystemDefaultHandler() { | 577 void CrashpadClient::UseSystemDefaultHandler() { |
| 586 base::mac::ScopedMachSendRight | 578 base::mac::ScopedMachSendRight |
| 587 system_crash_reporter_handler(SystemCrashReporterHandler()); | 579 system_crash_reporter_handler(SystemCrashReporterHandler()); |
| 588 | 580 |
| 589 // Proceed even if SystemCrashReporterHandler() failed, setting MACH_PORT_NULL | 581 // Proceed even if SystemCrashReporterHandler() failed, setting MACH_PORT_NULL |
| 590 // to clear the current exception ports. | 582 // to clear the current exception ports. |
| 591 if (!SetCrashExceptionPorts(system_crash_reporter_handler.get())) { | 583 if (!SetCrashExceptionPorts(system_crash_reporter_handler.get())) { |
| 592 SetCrashExceptionPorts(MACH_PORT_NULL); | 584 SetCrashExceptionPorts(MACH_PORT_NULL); |
| 593 } | 585 } |
| 594 } | 586 } |
| 595 | 587 |
| 596 } // namespace crashpad | 588 } // namespace crashpad |
| OLD | NEW |