| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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 SERVICES_SERVICE_MANAGER_PUBLIC_CPP_STANDALONE_SERVICE_MACH_BROKER_H_ | |
| 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_STANDALONE_SERVICE_MACH_BROKER_H_ | |
| 7 | |
| 8 #include "base/mac/mach_port_broker.h" | |
| 9 | |
| 10 namespace base { | |
| 11 template <typename T> struct DefaultSingletonTraits; | |
| 12 } | |
| 13 | |
| 14 namespace service_manager { | |
| 15 | |
| 16 // A global singleton |MachBroker| is used by the service manager to provide | |
| 17 // access to | |
| 18 // Mach task ports for service manager out-of-process applications. | |
| 19 class MachBroker { | |
| 20 public: | |
| 21 // Sends the task port of the current process to the parent over Mach IPC. | |
| 22 // For use in child processes. | |
| 23 static void SendTaskPortToParent(); | |
| 24 | |
| 25 // Returns the global |MachBroker|. For use in the service manager. | |
| 26 static MachBroker* GetInstance(); | |
| 27 | |
| 28 // Registers |pid| with a MACH_PORT_NULL task port in the port provider. A | |
| 29 // child's pid must be registered before the broker will accept a task port | |
| 30 // from that child. | |
| 31 // Callers MUST acquire the lock given by GetLock() before calling this method | |
| 32 // (and release the lock afterwards). | |
| 33 void ExpectPid(base::ProcessHandle pid); | |
| 34 | |
| 35 // Removes |pid| from the port provider. | |
| 36 // Callers MUST acquire the lock given by GetLock() before calling this method | |
| 37 // (and release the lock afterwards). | |
| 38 void RemovePid(base::ProcessHandle pid); | |
| 39 | |
| 40 base::Lock& GetLock() { return broker_.GetLock(); } | |
| 41 base::PortProvider* port_provider() { return &broker_; } | |
| 42 | |
| 43 private: | |
| 44 MachBroker(); | |
| 45 ~MachBroker(); | |
| 46 friend struct base::DefaultSingletonTraits<MachBroker>; | |
| 47 | |
| 48 base::MachPortBroker broker_; | |
| 49 }; | |
| 50 | |
| 51 } // namespace service_manager | |
| 52 | |
| 53 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_STANDALONE_SERVICE_MACH_BROKER_H_ | |
| OLD | NEW |