| 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 <AvailabilityMacros.h> | 8 #include <AvailabilityMacros.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/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "sandbox/mac/message_server.h" | 13 #include "sandbox/mac/message_server.h" |
| 13 #include "sandbox/mac/xpc.h" | 14 #include "sandbox/mac/xpc.h" |
| 14 #include "sandbox/sandbox_export.h" | 15 #include "sandbox/sandbox_export.h" |
| 15 | 16 |
| 16 #if defined(MAC_OS_X_VERSION_10_7) && \ | 17 #if defined(MAC_OS_X_VERSION_10_7) && \ |
| 17 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 | 18 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 |
| 18 // Redeclare methods that only exist on 10.7+ to suppress | 19 // Redeclare methods that only exist on 10.7+ to suppress |
| 19 // -Wpartial-availability warnings. | 20 // -Wpartial-availability warnings. |
| 20 extern "C" { | 21 extern "C" { |
| 21 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 void | 22 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 void |
| 22 xpc_dictionary_set_int64(xpc_object_t xdict, const char* key, int64_t value); | 23 xpc_dictionary_set_int64(xpc_object_t xdict, const char* key, int64_t value); |
| 23 | 24 |
| 24 XPC_EXPORT XPC_NONNULL1 void xpc_release(xpc_object_t object); | 25 XPC_EXPORT XPC_NONNULL1 void xpc_release(xpc_object_t object); |
| 25 } // extern "C" | 26 } // extern "C" |
| 26 #endif | 27 #endif |
| 27 | 28 |
| 28 namespace sandbox { | 29 namespace sandbox { |
| 29 | 30 |
| 30 class DispatchSourceMach; | |
| 31 | |
| 32 // An implementation of MessageServer that uses XPC pipes to read and write XPC | 31 // An implementation of MessageServer that uses XPC pipes to read and write XPC |
| 33 // messages from a Mach port. | 32 // messages from a Mach port. |
| 34 class SANDBOX_EXPORT XPCMessageServer : public MessageServer { | 33 class SANDBOX_EXPORT XPCMessageServer : public MessageServer { |
| 35 public: | 34 public: |
| 36 // Creates a new XPC message server that will send messages to |demuxer| | 35 // Creates a new XPC message server that will send messages to |demuxer| |
| 37 // for handling. If the |server_receive_right| is non-NULL, this class will | 36 // for handling. If the |server_receive_right| is non-NULL, this class will |
| 38 // take ownership of the port and it will be used to receive messages. | 37 // take ownership of the port and it will be used to receive messages. |
| 39 // Otherwise the server will create a new receive right on which to listen. | 38 // Otherwise the server will create a new receive right on which to listen. |
| 40 XPCMessageServer(MessageDemuxer* demuxer, | 39 XPCMessageServer(MessageDemuxer* demuxer, |
| 41 mach_port_t server_receive_right); | 40 mach_port_t server_receive_right); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 55 // Reads a message from the XPC pipe. | 54 // Reads a message from the XPC pipe. |
| 56 void ReceiveMessage(); | 55 void ReceiveMessage(); |
| 57 | 56 |
| 58 // The demuxer delegate. Weak. | 57 // The demuxer delegate. Weak. |
| 59 MessageDemuxer* demuxer_; | 58 MessageDemuxer* demuxer_; |
| 60 | 59 |
| 61 // The Mach port on which the server is receiving requests. | 60 // The Mach port on which the server is receiving requests. |
| 62 base::mac::ScopedMachReceiveRight server_port_; | 61 base::mac::ScopedMachReceiveRight server_port_; |
| 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 // The reply message, if one has been created. | 66 // The reply message, if one has been created. |
| 68 xpc_object_t reply_message_; | 67 xpc_object_t reply_message_; |
| 69 | 68 |
| 70 DISALLOW_COPY_AND_ASSIGN(XPCMessageServer); | 69 DISALLOW_COPY_AND_ASSIGN(XPCMessageServer); |
| 71 }; | 70 }; |
| 72 | 71 |
| 73 } // namespace sandbox | 72 } // namespace sandbox |
| 74 | 73 |
| 75 #endif // SANDBOX_MAC_XPC_MESSAGE_SERVER_H_ | 74 #endif // SANDBOX_MAC_XPC_MESSAGE_SERVER_H_ |
| OLD | NEW |