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/dispatch_source_mach.h" |
10 #include "base/mac/scoped_mach_port.h" | 11 #include "base/mac/scoped_mach_port.h" |
11 #include "base/mac/scoped_mach_vm.h" | 12 #include "base/mac/scoped_mach_vm.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "sandbox/mac/message_server.h" | 14 #include "sandbox/mac/message_server.h" |
14 | 15 |
15 namespace sandbox { | 16 namespace sandbox { |
16 | 17 |
17 class DispatchSourceMach; | |
18 | |
19 // A Mach message server that operates a receive port. Messages are received | 18 // A Mach message server that operates a receive port. Messages are received |
20 // and then passed to the MessageDemuxer for handling. The Demuxer | 19 // and then passed to the MessageDemuxer for handling. The Demuxer |
21 // can use the server class to send a reply, forward the message to a | 20 // can use the server class to send a reply, forward the message to a |
22 // different port, or reply to the message with a MIG error. | 21 // different port, or reply to the message with a MIG error. |
23 class MachMessageServer : public MessageServer { | 22 class MachMessageServer : public MessageServer { |
24 public: | 23 public: |
25 // Creates a new Mach message server that will send messages to |demuxer| | 24 // Creates a new Mach message server that will send messages to |demuxer| |
26 // for handling. If the |server_receive_right| is non-NULL, this class will | 25 // 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. | 26 // take ownership of the port and it will be used to receive messages. |
28 // Otherwise the server will create a new receive right. | 27 // Otherwise the server will create a new receive right. |
(...skipping 26 matching lines...) Expand all Loading... |
55 base::mac::ScopedMachReceiveRight server_port_; | 54 base::mac::ScopedMachReceiveRight server_port_; |
56 | 55 |
57 // The size of the two message buffers below. | 56 // The size of the two message buffers below. |
58 const mach_msg_size_t buffer_size_; | 57 const mach_msg_size_t buffer_size_; |
59 | 58 |
60 // Request and reply buffers used in ReceiveMessage. | 59 // Request and reply buffers used in ReceiveMessage. |
61 base::mac::ScopedMachVM request_buffer_; | 60 base::mac::ScopedMachVM request_buffer_; |
62 base::mac::ScopedMachVM reply_buffer_; | 61 base::mac::ScopedMachVM reply_buffer_; |
63 | 62 |
64 // MACH_RECV dispatch source that handles the |server_port_|. | 63 // MACH_RECV dispatch source that handles the |server_port_|. |
65 scoped_ptr<DispatchSourceMach> dispatch_source_; | 64 scoped_ptr<base::DispatchSourceMach> dispatch_source_; |
66 | 65 |
67 // Whether or not ForwardMessage() was called during ReceiveMessage(). | 66 // Whether or not ForwardMessage() was called during ReceiveMessage(). |
68 bool did_forward_message_; | 67 bool did_forward_message_; |
69 }; | 68 }; |
70 | 69 |
71 } // namespace sandbox | 70 } // namespace sandbox |
72 | 71 |
73 #endif // SANDBOX_MAC_MACH_MESSAGE_SERVER_H_ | 72 #endif // SANDBOX_MAC_MACH_MESSAGE_SERVER_H_ |
OLD | NEW |