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

Side by Side Diff: mojo/shell/runner/host/mach_broker.h

Issue 1877753003: Move mojo\shell to services\shell (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@62scan
Patch Set: . Created 4 years, 8 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
« no previous file with comments | « mojo/shell/runner/host/linux_sandbox.cc ('k') | mojo/shell/runner/host/mach_broker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 MOJO_SHELL_RUNNER_HOST_MACH_BROKER_H_
6 #define MOJO_SHELL_RUNNER_HOST_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 mojo {
15 namespace shell {
16
17 // A global singleton |MachBroker| is used by the shell to provide access to
18 // Mach task ports for shell 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 shell.
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 shell
52 } // namespace mojo
53
54 #endif // MOJO_SHELL_RUNNER_HOST_MACH_BROKER_H_
OLDNEW
« no previous file with comments | « mojo/shell/runner/host/linux_sandbox.cc ('k') | mojo/shell/runner/host/mach_broker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698