Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(591)

Side by Side Diff: services/service_manager/runner/host/mach_broker.h

Issue 2427443002: Replace remaining shell references with service manager (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 SERVICES_SERVICE_MANAGER_RUNNER_HOST_MACH_BROKER_H_ 5 #ifndef SERVICES_SERVICE_MANAGER_RUNNER_HOST_MACH_BROKER_H_
6 #define SERVICES_SERVICE_MANAGER_RUNNER_HOST_MACH_BROKER_H_ 6 #define SERVICES_SERVICE_MANAGER_RUNNER_HOST_MACH_BROKER_H_
7 7
8 #include "base/mac/mach_port_broker.h" 8 #include "base/mac/mach_port_broker.h"
9 9
10 namespace base { 10 namespace base {
11 template <typename T> struct DefaultSingletonTraits; 11 template <typename T> struct DefaultSingletonTraits;
12 } 12 }
13 13
14 namespace service_manager { 14 namespace service_manager {
15 15
16 // A global singleton |MachBroker| is used by the shell to provide access to 16 // A global singleton |MachBroker| is used by the service manager to provide
17 // Mach task ports for shell out-of-process applications. 17 // access to
18 // Mach task ports for service manager out-of-process applications.
18 class MachBroker { 19 class MachBroker {
19 public: 20 public:
20 // Sends the task port of the current process to the parent over Mach IPC. 21 // Sends the task port of the current process to the parent over Mach IPC.
21 // For use in child processes. 22 // For use in child processes.
22 static void SendTaskPortToParent(); 23 static void SendTaskPortToParent();
23 24
24 // Returns the global |MachBroker|. For use in the shell. 25 // Returns the global |MachBroker|. For use in the service manager.
25 static MachBroker* GetInstance(); 26 static MachBroker* GetInstance();
26 27
27 // Registers |pid| with a MACH_PORT_NULL task port in the port provider. A 28 // Registers |pid| with a MACH_PORT_NULL task port in the port provider. A
28 // child's pid must be registered before the broker will accept a task port 29 // child's pid must be registered before the broker will accept a task port
29 // from that child. 30 // from that child.
30 // Callers MUST acquire the lock given by GetLock() before calling this method 31 // Callers MUST acquire the lock given by GetLock() before calling this method
31 // (and release the lock afterwards). 32 // (and release the lock afterwards).
32 void ExpectPid(base::ProcessHandle pid); 33 void ExpectPid(base::ProcessHandle pid);
33 34
34 // Removes |pid| from the port provider. 35 // Removes |pid| from the port provider.
35 // Callers MUST acquire the lock given by GetLock() before calling this method 36 // Callers MUST acquire the lock given by GetLock() before calling this method
36 // (and release the lock afterwards). 37 // (and release the lock afterwards).
37 void RemovePid(base::ProcessHandle pid); 38 void RemovePid(base::ProcessHandle pid);
38 39
39 base::Lock& GetLock() { return broker_.GetLock(); } 40 base::Lock& GetLock() { return broker_.GetLock(); }
40 base::PortProvider* port_provider() { return &broker_; } 41 base::PortProvider* port_provider() { return &broker_; }
41 42
42 private: 43 private:
43 MachBroker(); 44 MachBroker();
44 ~MachBroker(); 45 ~MachBroker();
45 friend struct base::DefaultSingletonTraits<MachBroker>; 46 friend struct base::DefaultSingletonTraits<MachBroker>;
46 47
47 base::MachPortBroker broker_; 48 base::MachPortBroker broker_;
48 }; 49 };
49 50
50 } // namespace service_manager 51 } // namespace service_manager
51 52
52 #endif // SERVICES_SERVICE_MANAGER_RUNNER_HOST_MACH_BROKER_H_ 53 #endif // SERVICES_SERVICE_MANAGER_RUNNER_HOST_MACH_BROKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698