Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_XPC_MACH_PORT_H_ | |
| 6 #define CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_XPC_MACH_PORT_H_ | |
| 7 | |
| 8 #import <Foundation/Foundation.h> | |
| 9 | |
| 10 #include "base/mac/scoped_mach_port.h" | |
| 11 | |
| 12 // An XPC transit type for Mach send rights. While this class conforms to | |
| 13 // NSSecureCoding, it is only valid to use the NSCoding methods for XPC. | |
| 14 // | |
| 15 // The public XPC APIs do not proivde any way to transfer Mach ports. Using the | |
| 16 // C-based API, the functions for setting/creating an XPC Mach port object can | |
| 17 // simply be forward-declared. But the Foundation API does not provide any way | |
| 18 // to pass a Mach port as part of a message. The OS_xpc_object Obj-C types | |
| 19 // do not conform to NSSecureCoding either, so they cannot be used to transport | |
| 20 // ports via the Foundation-level API. | |
| 21 // | |
| 22 // Instead, this class encodes Mach port OOL data using the private | |
|
Mark Mentovai
2017/03/14 23:24:52
Seems like we might want to have a test for at lea
Robert Sesek
2017/03/15 19:22:09
Agreed, but the "how" of that is not-trivial. Whil
| |
| 23 // NSXPCEncoder and NSXPCDecoder APIs. These APIs expose methods by which | |
| 24 // xpc_objct_t's (and their OS_object-bridged-siblings) can be encoded into a | |
| 25 // Foundation-level XPC message. | |
| 26 @interface CrXPCMachPort : NSObject<NSSecureCoding> | |
| 27 | |
| 28 // Creates a new transit Mach port by taking ownership of the |sendRight|. | |
| 29 - (instancetype)initWithMachSendRight:(base::mac::ScopedMachSendRight)sendRight; | |
| 30 | |
| 31 // Relinquishes ownership of the Mach port to the caller. | |
| 32 - (base::mac::ScopedMachSendRight)takeRight; | |
| 33 | |
| 34 @end | |
| 35 | |
| 36 #endif // CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_XPC_MACH_PORT_H_ | |
| OLD | NEW |