| 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 19 matching lines...) Expand all Loading... |
| 30 //! \brief A Mach RPC callback interface, called by Run(). | 30 //! \brief A Mach RPC callback interface, called by Run(). |
| 31 class Interface { | 31 class Interface { |
| 32 public: | 32 public: |
| 33 //! \brief Handles a Mach RPC request. | 33 //! \brief Handles a Mach RPC request. |
| 34 //! | 34 //! |
| 35 //! This method is a stand-in for a MIG-generated Mach RPC server “demux” | 35 //! This method is a stand-in for a MIG-generated Mach RPC server “demux” |
| 36 //! function such as `exc_server()` and `mach_exc_server()`. Implementations | 36 //! function such as `exc_server()` and `mach_exc_server()`. Implementations |
| 37 //! may call such a function directly. This method is expected to behave | 37 //! may call such a function directly. This method is expected to behave |
| 38 //! exactly as these functions behave. | 38 //! exactly as these functions behave. |
| 39 //! | 39 //! |
| 40 //! \param[in] in The request message, received as a Mach message. | 40 //! \param[in] in The request message, received as a Mach message. Note that |
| 41 //! this interface uses a `const` parameter for this purpose, whereas |
| 42 //! MIG-generated “demux” functions do not. |
| 41 //! \param[out] out The reply message. The caller allocates storage, and the | 43 //! \param[out] out The reply message. The caller allocates storage, and the |
| 42 //! callee is expected to populate the reply message appropriately. | 44 //! callee is expected to populate the reply message appropriately. |
| 43 //! After returning, the caller will send this reply as a Mach message | 45 //! After returning, the caller will send this reply as a Mach message |
| 44 //! via the message’s reply port. | 46 //! via the message’s reply port. |
| 45 //! \param[out] destroy_complex_request `true` if a complex request message | 47 //! \param[out] destroy_complex_request `true` if a complex request message |
| 46 //! is to be destroyed even when handled successfully, `false` | 48 //! is to be destroyed even when handled successfully, `false` |
| 47 //! otherwise. The traditional behavior is `false`. In this case, the | 49 //! otherwise. The traditional behavior is `false`. In this case, the |
| 48 //! caller only destroys the request message in \a in when the reply | 50 //! caller only destroys the request message in \a in when the reply |
| 49 //! message in \a out is not complex and when it indicates a return code | 51 //! message in \a out is not complex and when it indicates a return code |
| 50 //! other than `KERN_SUCCESS` or `MIG_NO_REPLY`. The assumption is that | 52 //! other than `KERN_SUCCESS` or `MIG_NO_REPLY`. The assumption is that |
| 51 //! the rights or out-of-line data carried in a complex message may be | 53 //! the rights or out-of-line data carried in a complex message may be |
| 52 //! retained by the server in this situation, and that it is the | 54 //! retained by the server in this situation, and that it is the |
| 53 //! responsibility of the server to release these resources as needed. | 55 //! responsibility of the server to release these resources as needed. |
| 54 //! However, in many cases, these resources are not needed beyond the | 56 //! However, in many cases, these resources are not needed beyond the |
| 55 //! duration of a request-reply transaction, and in such cases, it is | 57 //! duration of a request-reply transaction, and in such cases, it is |
| 56 //! less error-prone to always have the caller, | 58 //! less error-prone to always have the caller, |
| 57 //! MachMessageServer::Run(), destroy complex request messages. To | 59 //! MachMessageServer::Run(), destroy complex request messages. To |
| 58 //! choose this behavior, this parameter should be set to `true`. | 60 //! choose this behavior, this parameter should be set to `true`. |
| 59 //! | 61 //! |
| 60 //! \return `true` on success and `false` on failure, although the caller | 62 //! \return `true` on success and `false` on failure, although the caller |
| 61 //! ignores the return value. However, the return code to be included in | 63 //! ignores the return value. However, the return code to be included in |
| 62 //! the reply message should be set as `mig_reply_error_t::RetCode`. The | 64 //! the reply message should be set as `mig_reply_error_t::RetCode`. The |
| 63 //! non-`void` return value is used for increased compatibility with | 65 //! non-`void` return value is used for increased compatibility with |
| 64 //! MIG-generated functions. | 66 //! MIG-generated functions. |
| 65 virtual bool MachMessageServerFunction(mach_msg_header_t* in, | 67 virtual bool MachMessageServerFunction(const mach_msg_header_t* in, |
| 66 mach_msg_header_t* out, | 68 mach_msg_header_t* out, |
| 67 bool* destroy_complex_request) = 0; | 69 bool* destroy_complex_request) = 0; |
| 68 | 70 |
| 69 //! \return The expected or maximum size, in bytes, of a request message to | 71 //! \return The expected or maximum size, in bytes, of a request message to |
| 70 //! be received as the \a in parameter of MachMessageServerFunction(). | 72 //! be received as the \a in parameter of MachMessageServerFunction(). |
| 71 virtual mach_msg_size_t MachMessageServerRequestSize() = 0; | 73 virtual mach_msg_size_t MachMessageServerRequestSize() = 0; |
| 72 | 74 |
| 73 //! \return The maximum size, in bytes, of a reply message to be sent via | 75 //! \return The maximum size, in bytes, of a reply message to be sent via |
| 74 //! the \a out parameter of MachMessageServerFunction(). This value does | 76 //! the \a out parameter of MachMessageServerFunction(). This value does |
| 75 //! not need to include the size of any trailer to be sent with the | 77 //! not need to include the size of any trailer to be sent with the |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 Nonblocking nonblocking, | 148 Nonblocking nonblocking, |
| 147 mach_msg_timeout_t timeout_ms); | 149 mach_msg_timeout_t timeout_ms); |
| 148 | 150 |
| 149 private: | 151 private: |
| 150 DISALLOW_IMPLICIT_CONSTRUCTORS(MachMessageServer); | 152 DISALLOW_IMPLICIT_CONSTRUCTORS(MachMessageServer); |
| 151 }; | 153 }; |
| 152 | 154 |
| 153 } // namespace crashpad | 155 } // namespace crashpad |
| 154 | 156 |
| 155 #endif // CRASHPAD_UTIL_MACH_MACH_MESSAGE_SERVER_H_ | 157 #endif // CRASHPAD_UTIL_MACH_MACH_MESSAGE_SERVER_H_ |
| OLD | NEW |