| 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 14 matching lines...) Expand all Loading... |
| 25 namespace crashpad { | 25 namespace crashpad { |
| 26 | 26 |
| 27 //! \brief Runs the main exception-handling server in Crashpad’s handler | 27 //! \brief Runs the main exception-handling server in Crashpad’s handler |
| 28 //! process. | 28 //! process. |
| 29 class ExceptionHandlerServer { | 29 class ExceptionHandlerServer { |
| 30 public: | 30 public: |
| 31 //! \brief Constructs an ExceptionHandlerServer object. | 31 //! \brief Constructs an ExceptionHandlerServer object. |
| 32 //! | 32 //! |
| 33 //! \param[in] receive_port The port that exception messages and no-senders | 33 //! \param[in] receive_port The port that exception messages and no-senders |
| 34 //! notifications will be received on. | 34 //! notifications will be received on. |
| 35 explicit ExceptionHandlerServer( | 35 //! \param[in] launchd If `true`, the exception handler is being run from |
| 36 base::mac::ScopedMachReceiveRight receive_port); | 36 //! launchd. \a receive_port is not monitored for no-senders |
| 37 //! notifications, and instead, the expected “quit” signal is receipt of |
| 38 //! `SIGTERM`. |
| 39 ExceptionHandlerServer(base::mac::ScopedMachReceiveRight receive_port, |
| 40 bool launchd); |
| 37 ~ExceptionHandlerServer(); | 41 ~ExceptionHandlerServer(); |
| 38 | 42 |
| 39 //! \brief Runs the exception-handling server. | 43 //! \brief Runs the exception-handling server. |
| 40 //! | 44 //! |
| 41 //! \param[in] exception_interface An object to send exception messages to. | 45 //! \param[in] exception_interface An object to send exception messages to. |
| 42 //! | 46 //! |
| 43 //! This method monitors the receive port for exception messages and | 47 //! This method monitors the receive port for exception messages and, if |
| 44 //! no-senders notifications. It continues running until it has no more | 48 //! not being run by launchd, no-senders notifications. It continues running |
| 45 //! clients, indicated by the receipt of a no-senders notification. It is | 49 //! until it has no more clients, indicated by the receipt of a no-senders |
| 46 //! important to assure that a send right exists in a client (or has been | 50 //! notification, or if being run by launchd, receipt of `SIGTERM`. When not |
| 47 //! queued by `mach_msg()` to be sent to a client) prior to calling this | 51 //! being run by launchd, it is important to assure that a send right exists |
| 48 //! method, or it will detect that it is sender-less and return immediately. | 52 //! in a client (or has been queued by `mach_msg()` to be sent to a client) |
| 53 //! prior to calling this method, or it will detect that it is sender-less and |
| 54 //! return immediately. |
| 49 //! | 55 //! |
| 50 //! All exception messages will be passed to \a exception_interface. | 56 //! All exception messages will be passed to \a exception_interface. |
| 51 //! | 57 //! |
| 52 //! This method must only be called once on an ExceptionHandlerServer object. | 58 //! This method must only be called once on an ExceptionHandlerServer object. |
| 53 //! | 59 //! |
| 54 //! If an unexpected condition that prevents this method from functioning is | 60 //! If an unexpected condition that prevents this method from functioning is |
| 55 //! encountered, it will log a message and terminate execution. Receipt of an | 61 //! encountered, it will log a message and terminate execution. Receipt of an |
| 56 //! invalid message on the receive port will cause a message to be logged, but | 62 //! invalid message on the receive port will cause a message to be logged, but |
| 57 //! this method will continue running normally. | 63 //! this method will continue running normally. |
| 58 void Run(UniversalMachExcServer::Interface* exception_interface); | 64 void Run(UniversalMachExcServer::Interface* exception_interface); |
| 59 | 65 |
| 60 private: | 66 private: |
| 61 base::mac::ScopedMachReceiveRight receive_port_; | 67 base::mac::ScopedMachReceiveRight receive_port_; |
| 68 bool launchd_; |
| 62 | 69 |
| 63 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerServer); | 70 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerServer); |
| 64 }; | 71 }; |
| 65 | 72 |
| 66 } // namespace crashpad | 73 } // namespace crashpad |
| 67 | 74 |
| 68 #endif // CRASHPAD_HANDLER_MAC_EXCEPTION_HANDLER_SERVER_H_ | 75 #endif // CRASHPAD_HANDLER_MAC_EXCEPTION_HANDLER_SERVER_H_ |
| OLD | NEW |