| 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_XPC_MESSAGE_SERVER_H_ | 5 #ifndef SANDBOX_MAC_XPC_MESSAGE_SERVER_H_ |
| 6 #define SANDBOX_MAC_XPC_MESSAGE_SERVER_H_ | 6 #define SANDBOX_MAC_XPC_MESSAGE_SERVER_H_ |
| 7 | 7 |
| 8 #include "base/mac/scoped_mach_port.h" | 8 #include "base/mac/scoped_mach_port.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "sandbox/mac/message_server.h" | 10 #include "sandbox/mac/message_server.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 public: | 21 public: |
| 22 // Creates a new XPC message server that will send messages to |demuxer| | 22 // Creates a new XPC message server that will send messages to |demuxer| |
| 23 // for handling. If the |server_receive_right| is non-NULL, this class will | 23 // for handling. If the |server_receive_right| is non-NULL, this class will |
| 24 // take ownership of the port and it will be used to receive messages. | 24 // take ownership of the port and it will be used to receive messages. |
| 25 // Otherwise the server will create a new receive right on which to listen. | 25 // Otherwise the server will create a new receive right on which to listen. |
| 26 XPCMessageServer(MessageDemuxer* demuxer, | 26 XPCMessageServer(MessageDemuxer* demuxer, |
| 27 mach_port_t server_receive_right); | 27 mach_port_t server_receive_right); |
| 28 virtual ~XPCMessageServer(); | 28 virtual ~XPCMessageServer(); |
| 29 | 29 |
| 30 // MessageServer: | 30 // MessageServer: |
| 31 virtual bool Initialize() OVERRIDE; | 31 virtual bool Initialize() override; |
| 32 virtual pid_t GetMessageSenderPID(IPCMessage request) OVERRIDE; | 32 virtual pid_t GetMessageSenderPID(IPCMessage request) override; |
| 33 virtual IPCMessage CreateReply(IPCMessage request) OVERRIDE; | 33 virtual IPCMessage CreateReply(IPCMessage request) override; |
| 34 virtual bool SendReply(IPCMessage reply) OVERRIDE; | 34 virtual bool SendReply(IPCMessage reply) override; |
| 35 virtual void ForwardMessage(IPCMessage request, | 35 virtual void ForwardMessage(IPCMessage request, |
| 36 mach_port_t destination) OVERRIDE; | 36 mach_port_t destination) override; |
| 37 // Creates an error reply message with a field "error" set to |error_code|. | 37 // Creates an error reply message with a field "error" set to |error_code|. |
| 38 virtual void RejectMessage(IPCMessage request, int error_code) OVERRIDE; | 38 virtual void RejectMessage(IPCMessage request, int error_code) override; |
| 39 virtual mach_port_t GetServerPort() const OVERRIDE; | 39 virtual mach_port_t GetServerPort() const override; |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 // Reads a message from the XPC pipe. | 42 // Reads a message from the XPC pipe. |
| 43 void ReceiveMessage(); | 43 void ReceiveMessage(); |
| 44 | 44 |
| 45 // The demuxer delegate. Weak. | 45 // The demuxer delegate. Weak. |
| 46 MessageDemuxer* demuxer_; | 46 MessageDemuxer* demuxer_; |
| 47 | 47 |
| 48 // The Mach port on which the server is receiving requests. | 48 // The Mach port on which the server is receiving requests. |
| 49 base::mac::ScopedMachReceiveRight server_port_; | 49 base::mac::ScopedMachReceiveRight server_port_; |
| 50 | 50 |
| 51 // MACH_RECV dispatch source that handles the |server_port_|. | 51 // MACH_RECV dispatch source that handles the |server_port_|. |
| 52 scoped_ptr<DispatchSourceMach> dispatch_source_; | 52 scoped_ptr<DispatchSourceMach> dispatch_source_; |
| 53 | 53 |
| 54 // The reply message, if one has been created. | 54 // The reply message, if one has been created. |
| 55 xpc_object_t reply_message_; | 55 xpc_object_t reply_message_; |
| 56 | 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(XPCMessageServer); | 57 DISALLOW_COPY_AND_ASSIGN(XPCMessageServer); |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 } // namespace sandbox | 60 } // namespace sandbox |
| 61 | 61 |
| 62 #endif // SANDBOX_MAC_XPC_MESSAGE_SERVER_H_ | 62 #endif // SANDBOX_MAC_XPC_MESSAGE_SERVER_H_ |
| OLD | NEW |