OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (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 |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #ifndef CRASHPAD_HANDLER_MAC_EXCEPTION_HANDLER_SERVER_H_ |
| 16 #define CRASHPAD_HANDLER_MAC_EXCEPTION_HANDLER_SERVER_H_ |
| 17 |
| 18 #include "base/basictypes.h" |
| 19 |
| 20 #include <mach/mach.h> |
| 21 |
| 22 #include "base/mac/scoped_mach_port.h" |
| 23 |
| 24 namespace crashpad { |
| 25 |
| 26 //! \brief Runs the main exception-handling server in Crashpad’s handler |
| 27 //! process. |
| 28 class ExceptionHandlerServer { |
| 29 public: |
| 30 ExceptionHandlerServer(); |
| 31 ~ExceptionHandlerServer(); |
| 32 |
| 33 //! \brief Runs the exception-handling server. |
| 34 //! |
| 35 //! This method monitors \a receive_port_ for exception messages and |
| 36 //! no-senders notifications. It continues running until it has no more |
| 37 //! clients, indicated by the receipt of a no-senders notification. It is |
| 38 //! important to assure that a send right has been transferred to a client |
| 39 //! (or queued by `mach_msg()` to be sent to a client) prior to calling this |
| 40 //! method, or it will detect that it is sender-less and return immediately. |
| 41 //! |
| 42 //! This method must only be called once on an ExceptionHandlerServer object. |
| 43 //! |
| 44 //! If an unexpected condition that prevents this method from functioning is |
| 45 //! encountered, it will log a message and terminate execution. Receipt of an |
| 46 //! invalid message on \a receive_port_ will cause a message to be logged, but |
| 47 //! this method will continue running normally. |
| 48 void Run(); |
| 49 |
| 50 //! \brief Returns the receive right that will be monitored for exception |
| 51 //! messages. |
| 52 //! |
| 53 //! The caller does not take ownership of this port. The caller must not use |
| 54 //! this port for any purpose other than to make send rights for clients. |
| 55 mach_port_t receive_port() const { return receive_port_; } |
| 56 |
| 57 private: |
| 58 base::mac::ScopedMachReceiveRight receive_port_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerServer); |
| 61 }; |
| 62 |
| 63 } // namespace crashpad |
| 64 |
| 65 #endif // CRASHPAD_HANDLER_MAC_EXCEPTION_HANDLER_SERVER_H_ |
OLD | NEW |