OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SANDBOX_MAC_MESSAGE_SERVER_H_ | 5 #ifndef SANDBOX_MAC_MESSAGE_SERVER_H_ |
6 #define SANDBOX_MAC_MESSAGE_SERVER_H_ | 6 #define SANDBOX_MAC_MESSAGE_SERVER_H_ |
7 | 7 |
8 #include <mach/mach.h> | 8 #include <mach/mach.h> |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 // some other technology. This interface is the abstraction on top of those | 37 // some other technology. This interface is the abstraction on top of those |
38 // that enables message interception. | 38 // that enables message interception. |
39 class MessageServer { | 39 class MessageServer { |
40 public: | 40 public: |
41 virtual ~MessageServer() {} | 41 virtual ~MessageServer() {} |
42 | 42 |
43 // Initializes the class and starts running the message server. If this | 43 // Initializes the class and starts running the message server. If this |
44 // returns false, no other methods may be called on this class. | 44 // returns false, no other methods may be called on this class. |
45 virtual bool Initialize() = 0; | 45 virtual bool Initialize() = 0; |
46 | 46 |
| 47 // Blocks the calling thread while the server shuts down. This prevents |
| 48 // the server from receiving new messages. After this method is called, |
| 49 // no other methods may be called on this class. |
| 50 virtual void Shutdown() = 0; |
| 51 |
47 // Given a received request message, returns the PID of the sending process. | 52 // Given a received request message, returns the PID of the sending process. |
48 virtual pid_t GetMessageSenderPID(IPCMessage request) = 0; | 53 virtual pid_t GetMessageSenderPID(IPCMessage request) = 0; |
49 | 54 |
50 // Creates a reply message from a request message. The result is owned by | 55 // Creates a reply message from a request message. The result is owned by |
51 // the server. | 56 // the server. |
52 virtual IPCMessage CreateReply(IPCMessage request) = 0; | 57 virtual IPCMessage CreateReply(IPCMessage request) = 0; |
53 | 58 |
54 // Sends a reply message. Returns true if the message was sent successfully. | 59 // Sends a reply message. Returns true if the message was sent successfully. |
55 virtual bool SendReply(IPCMessage reply) = 0; | 60 virtual bool SendReply(IPCMessage reply) = 0; |
56 | 61 |
57 // Forwards the original |request| to the |destination| for handling. | 62 // Forwards the original |request| to the |destination| for handling. |
58 virtual void ForwardMessage(IPCMessage request, mach_port_t destination) = 0; | 63 virtual void ForwardMessage(IPCMessage request, mach_port_t destination) = 0; |
59 | 64 |
60 // Replies to the received |request| message by creating a reply and setting | 65 // Replies to the received |request| message by creating a reply and setting |
61 // the specified |error_code| in a field that is interpreted by the | 66 // the specified |error_code| in a field that is interpreted by the |
62 // underlying IPC system. | 67 // underlying IPC system. |
63 virtual void RejectMessage(IPCMessage request, int error_code) = 0; | 68 virtual void RejectMessage(IPCMessage request, int error_code) = 0; |
64 | 69 |
65 // Returns the Mach port on which the MessageServer is listening. | 70 // Returns the Mach port on which the MessageServer is listening. |
66 virtual mach_port_t GetServerPort() const = 0; | 71 virtual mach_port_t GetServerPort() const = 0; |
67 }; | 72 }; |
68 | 73 |
69 } // namespace sandbox | 74 } // namespace sandbox |
70 | 75 |
71 #endif // SANDBOX_MAC_MESSAGE_SERVER_H_ | 76 #endif // SANDBOX_MAC_MESSAGE_SERVER_H_ |
OLD | NEW |