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_MACH_MESSAGE_SERVER_H_ | 5 #ifndef SANDBOX_MAC_MACH_MESSAGE_SERVER_H_ |
6 #define SANDBOX_MAC_MACH_MESSAGE_SERVER_H_ | 6 #define SANDBOX_MAC_MACH_MESSAGE_SERVER_H_ |
7 | 7 |
8 #include <mach/mach.h> | 8 #include <mach/mach.h> |
9 | 9 |
10 #include "base/mac/scoped_mach_port.h" | 10 #include "base/mac/scoped_mach_port.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // for handling. If the |server_receive_right| is non-NULL, this class will | 26 // for handling. If the |server_receive_right| is non-NULL, this class will |
27 // take ownership of the port and it will be used to receive messages. | 27 // take ownership of the port and it will be used to receive messages. |
28 // Otherwise the server will create a new receive right. | 28 // Otherwise the server will create a new receive right. |
29 // The maximum size of messages is specified by |buffer_size|. | 29 // The maximum size of messages is specified by |buffer_size|. |
30 MachMessageServer(MessageDemuxer* demuxer, | 30 MachMessageServer(MessageDemuxer* demuxer, |
31 mach_port_t server_receive_right, | 31 mach_port_t server_receive_right, |
32 mach_msg_size_t buffer_size); | 32 mach_msg_size_t buffer_size); |
33 virtual ~MachMessageServer(); | 33 virtual ~MachMessageServer(); |
34 | 34 |
35 // MessageServer: | 35 // MessageServer: |
36 virtual bool Initialize() OVERRIDE; | 36 virtual bool Initialize() override; |
37 virtual pid_t GetMessageSenderPID(IPCMessage request) OVERRIDE; | 37 virtual pid_t GetMessageSenderPID(IPCMessage request) override; |
38 virtual IPCMessage CreateReply(IPCMessage request) OVERRIDE; | 38 virtual IPCMessage CreateReply(IPCMessage request) override; |
39 virtual bool SendReply(IPCMessage reply) OVERRIDE; | 39 virtual bool SendReply(IPCMessage reply) override; |
40 virtual void ForwardMessage(IPCMessage request, | 40 virtual void ForwardMessage(IPCMessage request, |
41 mach_port_t destination) OVERRIDE; | 41 mach_port_t destination) override; |
42 // Replies to the message with the specified |error_code| as a MIG | 42 // Replies to the message with the specified |error_code| as a MIG |
43 // error_reply RetCode. | 43 // error_reply RetCode. |
44 virtual void RejectMessage(IPCMessage request, int error_code) OVERRIDE; | 44 virtual void RejectMessage(IPCMessage request, int error_code) override; |
45 virtual mach_port_t GetServerPort() const OVERRIDE; | 45 virtual mach_port_t GetServerPort() const override; |
46 | 46 |
47 private: | 47 private: |
48 // Event handler for the |server_source_| that reads a message from the queue | 48 // Event handler for the |server_source_| that reads a message from the queue |
49 // and processes it. | 49 // and processes it. |
50 void ReceiveMessage(); | 50 void ReceiveMessage(); |
51 | 51 |
52 // The demuxer delegate. Weak. | 52 // The demuxer delegate. Weak. |
53 MessageDemuxer* demuxer_; | 53 MessageDemuxer* demuxer_; |
54 | 54 |
55 // The Mach port on which the server is receiving requests. | 55 // The Mach port on which the server is receiving requests. |
56 base::mac::ScopedMachReceiveRight server_port_; | 56 base::mac::ScopedMachReceiveRight server_port_; |
57 | 57 |
58 // The size of the two message buffers below. | 58 // The size of the two message buffers below. |
59 const mach_msg_size_t buffer_size_; | 59 const mach_msg_size_t buffer_size_; |
60 | 60 |
61 // Request and reply buffers used in ReceiveMessage. | 61 // Request and reply buffers used in ReceiveMessage. |
62 base::mac::ScopedMachVM request_buffer_; | 62 base::mac::ScopedMachVM request_buffer_; |
63 base::mac::ScopedMachVM reply_buffer_; | 63 base::mac::ScopedMachVM reply_buffer_; |
64 | 64 |
65 // MACH_RECV dispatch source that handles the |server_port_|. | 65 // MACH_RECV dispatch source that handles the |server_port_|. |
66 scoped_ptr<DispatchSourceMach> dispatch_source_; | 66 scoped_ptr<DispatchSourceMach> dispatch_source_; |
67 | 67 |
68 // Whether or not ForwardMessage() was called during ReceiveMessage(). | 68 // Whether or not ForwardMessage() was called during ReceiveMessage(). |
69 bool did_forward_message_; | 69 bool did_forward_message_; |
70 }; | 70 }; |
71 | 71 |
72 } // namespace sandbox | 72 } // namespace sandbox |
73 | 73 |
74 #endif // SANDBOX_MAC_MACH_MESSAGE_SERVER_H_ | 74 #endif // SANDBOX_MAC_MACH_MESSAGE_SERVER_H_ |
OLD | NEW |