Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: util/mach/notify_server.h

Issue 1414413006: mac: Add NotifyServer::DefaultInterface, a default no-op implementation (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « handler/mac/exception_handler_server.cc ('k') | util/mach/notify_server.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
30 //! href="https://lists.apple.com/archives/darwin-development/2001/Sep/msg00451. html">mach 30 //! href="https://lists.apple.com/archives/darwin-development/2001/Sep/msg00451. html">mach
31 //! port notifications</a> thread on the <a 31 //! port notifications</a> thread on the <a
32 //! href="https://lists.apple.com/archives/darwin-development/">darwin-developme nt</a> 32 //! href="https://lists.apple.com/archives/darwin-development/">darwin-developme nt</a>
33 //! mailing list (now known as <a 33 //! mailing list (now known as <a
34 //! href="https://lists.apple.com/mailman/listinfo/darwin-dev">darwin-dev</a>) 34 //! href="https://lists.apple.com/mailman/listinfo/darwin-dev">darwin-dev</a>)
35 //! is good background for the various notification types. 35 //! is good background for the various notification types.
36 class NotifyServer : public MachMessageServer::Interface { 36 class NotifyServer : public MachMessageServer::Interface {
37 public: 37 public:
38 //! \brief An interface that the different request messages that are a part of 38 //! \brief An interface that the different request messages that are a part of
39 //! the `notify` Mach subsystem can be dispatched to. 39 //! the `notify` Mach subsystem can be dispatched to.
40 //!
41 //! Default implementations of all methods are available in the
42 //! DefaultInterface class.
40 class Interface { 43 class Interface {
41 public: 44 public:
42 //! \brief Handles port-deleted notifications sent by 45 //! \brief Handles port-deleted notifications sent by
43 //! `mach_notify_port_deleted()`. 46 //! `mach_notify_port_deleted()`.
44 //! 47 //!
45 //! A port-deleted notification is generated when a port with a dead-name 48 //! A port-deleted notification is generated when a port with a dead-name
46 //! notification request is destroyed and the port name becomes available 49 //! notification request is destroyed and the port name becomes available
47 //! for reuse. 50 //! for reuse.
48 //! 51 //!
49 //! This behaves equivalently to a `do_mach_notify_port_deleted()` function 52 //! This behaves equivalently to a `do_mach_notify_port_deleted()` function
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 //! not complex Mach messages. 162 //! not complex Mach messages.
160 virtual kern_return_t DoMachNotifyDeadName( 163 virtual kern_return_t DoMachNotifyDeadName(
161 notify_port_t notify, 164 notify_port_t notify,
162 mach_port_name_t name, 165 mach_port_name_t name,
163 const mach_msg_trailer_t* trailer) = 0; 166 const mach_msg_trailer_t* trailer) = 0;
164 167
165 protected: 168 protected:
166 ~Interface() {} 169 ~Interface() {}
167 }; 170 };
168 171
172 //! \brief A concrete implementation of Interface that provides a default
173 //! behavior for all `notify` routines.
174 //!
175 //! The Mach `notify` subsystem contains a collection of unrelated routines,
176 //! and a single server would rarely need to implement all of them. To make it
177 //! easier to use NotifyServer, a server can inherit from DefaultInterface
178 //! instead of Interface. Unless overridden, each routine in DefaultInterface
179 //! returns `MIG_BAD_ID` to indicate to the caller that the `notify` message
180 //! was unexpected and not processed.
181 class DefaultInterface : public Interface {
182 public:
183 // Interface:
184
185 kern_return_t DoMachNotifyPortDeleted(
186 notify_port_t notify,
187 mach_port_name_t name,
188 const mach_msg_trailer_t* trailer) override;
189
190 kern_return_t DoMachNotifyPortDestroyed(
191 notify_port_t notify,
192 mach_port_t rights,
193 const mach_msg_trailer_t* trailer,
194 bool* destroy_request) override;
195
196 kern_return_t DoMachNotifyNoSenders(
197 notify_port_t notify,
198 mach_port_mscount_t mscount,
199 const mach_msg_trailer_t* trailer) override;
200
201 kern_return_t DoMachNotifySendOnce(
202 notify_port_t notify,
203 const mach_msg_trailer_t* trailer) override;
204
205 kern_return_t DoMachNotifyDeadName(
206 notify_port_t notify,
207 mach_port_name_t name,
208 const mach_msg_trailer_t* trailer) override;
209
210 protected:
211 DefaultInterface() : Interface() {}
212 ~DefaultInterface() {}
213
214 private:
215 DISALLOW_COPY_AND_ASSIGN(DefaultInterface);
216 };
217
169 //! \brief Constructs an object of this class. 218 //! \brief Constructs an object of this class.
170 //! 219 //!
171 //! \param[in] interface The interface to dispatch requests to. Weak. 220 //! \param[in] interface The interface to dispatch requests to. Weak.
172 explicit NotifyServer(Interface* interface); 221 explicit NotifyServer(Interface* interface);
173 222
174 // MachMessageServer::Interface: 223 // MachMessageServer::Interface:
175 224
176 bool MachMessageServerFunction(const mach_msg_header_t* in_header, 225 bool MachMessageServerFunction(const mach_msg_header_t* in_header,
177 mach_msg_header_t* out_header, 226 mach_msg_header_t* out_header,
178 bool* destroy_complex_request) override; 227 bool* destroy_complex_request) override;
179 228
180 std::set<mach_msg_id_t> MachMessageServerRequestIDs() override; 229 std::set<mach_msg_id_t> MachMessageServerRequestIDs() override;
181 230
182 mach_msg_size_t MachMessageServerRequestSize() override; 231 mach_msg_size_t MachMessageServerRequestSize() override;
183 mach_msg_size_t MachMessageServerReplySize() override; 232 mach_msg_size_t MachMessageServerReplySize() override;
184 233
185 private: 234 private:
186 Interface* interface_; // weak 235 Interface* interface_; // weak
187 236
188 DISALLOW_COPY_AND_ASSIGN(NotifyServer); 237 DISALLOW_COPY_AND_ASSIGN(NotifyServer);
189 }; 238 };
190 239
191 } // namespace crashpad 240 } // namespace crashpad
192 241
193 #endif // CRASHPAD_UTIL_MACH_NOTIFY_SERVER_H_ 242 #endif // CRASHPAD_UTIL_MACH_NOTIFY_SERVER_H_
OLDNEW
« no previous file with comments | « handler/mac/exception_handler_server.cc ('k') | util/mach/notify_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698