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 10 matching lines...) Expand all Loading... |
21 | 21 |
22 #include "base/mac/scoped_mach_port.h" | 22 #include "base/mac/scoped_mach_port.h" |
23 #include "util/mach/exc_server_variants.h" | 23 #include "util/mach/exc_server_variants.h" |
24 | 24 |
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 ExceptionHandlerServer(); | 31 //! \brief Constructs an ExceptionHandlerServer object. |
| 32 //! |
| 33 //! \param[in] receive_port The port that exception messages and no-senders |
| 34 //! notifications will be received on. |
| 35 explicit ExceptionHandlerServer( |
| 36 base::mac::ScopedMachReceiveRight receive_port); |
32 ~ExceptionHandlerServer(); | 37 ~ExceptionHandlerServer(); |
33 | 38 |
34 //! \brief Runs the exception-handling server. | 39 //! \brief Runs the exception-handling server. |
35 //! | 40 //! |
36 //! \param[in] exception_interface An object to send exception messages to. | 41 //! \param[in] exception_interface An object to send exception messages to. |
37 //! | 42 //! |
38 //! This method monitors receive_port() for exception messages and no-senders | 43 //! This method monitors the receive port for exception messages and |
39 //! notifications. It continues running until it has no more clients, | 44 //! no-senders notifications. It continues running until it has no more |
40 //! indicated by the receipt of a no-senders notification. It is important to | 45 //! clients, indicated by the receipt of a no-senders notification. It is |
41 //! assure that a send right has been transferred to a client (or queued by | 46 //! important to assure that a send right exists in a client (or has been |
42 //! `mach_msg()` to be sent to a client) prior to calling this method, or it | 47 //! queued by `mach_msg()` to be sent to a client) prior to calling this |
43 //! will detect that it is sender-less and return immediately. | 48 //! method, or it will detect that it is sender-less and return immediately. |
44 //! | 49 //! |
45 //! All exception messages will be passed to \a exception_interface. | 50 //! All exception messages will be passed to \a exception_interface. |
46 //! | 51 //! |
47 //! This method must only be called once on an ExceptionHandlerServer object. | 52 //! This method must only be called once on an ExceptionHandlerServer object. |
48 //! | 53 //! |
49 //! If an unexpected condition that prevents this method from functioning is | 54 //! If an unexpected condition that prevents this method from functioning is |
50 //! encountered, it will log a message and terminate execution. Receipt of an | 55 //! encountered, it will log a message and terminate execution. Receipt of an |
51 //! invalid message on receive_port() will cause a message to be logged, but | 56 //! invalid message on the receive port will cause a message to be logged, but |
52 //! this method will continue running normally. | 57 //! this method will continue running normally. |
53 void Run(UniversalMachExcServer::Interface* exception_interface); | 58 void Run(UniversalMachExcServer::Interface* exception_interface); |
54 | 59 |
55 //! \brief Returns the receive right that will be monitored for exception | |
56 //! messages. | |
57 //! | |
58 //! The caller does not take ownership of this port. The caller must not use | |
59 //! this port for any purpose other than to make send rights for clients. | |
60 mach_port_t receive_port() const { return receive_port_.get(); } | |
61 | |
62 private: | 60 private: |
63 base::mac::ScopedMachReceiveRight receive_port_; | 61 base::mac::ScopedMachReceiveRight receive_port_; |
64 | 62 |
65 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerServer); | 63 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerServer); |
66 }; | 64 }; |
67 | 65 |
68 } // namespace crashpad | 66 } // namespace crashpad |
69 | 67 |
70 #endif // CRASHPAD_HANDLER_MAC_EXCEPTION_HANDLER_SERVER_H_ | 68 #endif // CRASHPAD_HANDLER_MAC_EXCEPTION_HANDLER_SERVER_H_ |
OLD | NEW |