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

Side by Side Diff: content/browser/mach_broker_mac.h

Issue 341073005: Define a bootstrap sandbox policy for renderer processes and enable it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Allow com.apple.windowserver.active Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/bootstrap_sandbox_mac.cc ('k') | content/browser/mach_broker_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CONTENT_BROWSER_MACH_BROKER_MAC_H_ 5 #ifndef CONTENT_BROWSER_MACH_BROKER_MAC_H_
6 #define CONTENT_BROWSER_MACH_BROKER_MAC_H_ 6 #define CONTENT_BROWSER_MACH_BROKER_MAC_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 26 matching lines...) Expand all
37 class CONTENT_EXPORT MachBroker : public base::ProcessMetrics::PortProvider, 37 class CONTENT_EXPORT MachBroker : public base::ProcessMetrics::PortProvider,
38 public BrowserChildProcessObserver, 38 public BrowserChildProcessObserver,
39 public NotificationObserver { 39 public NotificationObserver {
40 public: 40 public:
41 // For use in child processes. This will send the task port of the current 41 // For use in child processes. This will send the task port of the current
42 // process over Mach IPC to the port registered by name (via this class) in 42 // process over Mach IPC to the port registered by name (via this class) in
43 // the parent process. Returns true if the message was sent successfully 43 // the parent process. Returns true if the message was sent successfully
44 // and false if otherwise. 44 // and false if otherwise.
45 static bool ChildSendTaskPortToParent(); 45 static bool ChildSendTaskPortToParent();
46 46
47 // Returns the Mach port name to use when sending or receiving messages.
48 // Does the Right Thing in the browser and in child processes.
49 static std::string GetMachPortName();
50
47 // Returns the global MachBroker. 51 // Returns the global MachBroker.
48 static MachBroker* GetInstance(); 52 static MachBroker* GetInstance();
49 53
50 // The lock that protects this MachBroker object. Clients MUST acquire and 54 // The lock that protects this MachBroker object. Clients MUST acquire and
51 // release this lock around calls to EnsureRunning(), PlaceholderForPid(), 55 // release this lock around calls to EnsureRunning(), PlaceholderForPid(),
52 // and FinalizePid(). 56 // and FinalizePid().
53 base::Lock& GetLock(); 57 base::Lock& GetLock();
54 58
55 // Performs any necessary setup that cannot happen in the constructor. 59 // Performs any necessary setup that cannot happen in the constructor.
56 // Callers MUST acquire the lock given by GetLock() before calling this 60 // Callers MUST acquire the lock given by GetLock() before calling this
(...skipping 29 matching lines...) Expand all
86 90
87 // Updates the mapping for |pid| to include the given |mach_info|. Does 91 // Updates the mapping for |pid| to include the given |mach_info|. Does
88 // nothing if PlaceholderForPid() has not already been called for the given 92 // nothing if PlaceholderForPid() has not already been called for the given
89 // |pid|. Callers MUST acquire the lock given by GetLock() before calling 93 // |pid|. Callers MUST acquire the lock given by GetLock() before calling
90 // this method (and release the lock afterwards). 94 // this method (and release the lock afterwards).
91 void FinalizePid(base::ProcessHandle pid, mach_port_t task_port); 95 void FinalizePid(base::ProcessHandle pid, mach_port_t task_port);
92 96
93 // Removes all mappings belonging to |pid| from the broker. 97 // Removes all mappings belonging to |pid| from the broker.
94 void InvalidatePid(base::ProcessHandle pid); 98 void InvalidatePid(base::ProcessHandle pid);
95 99
96 // Returns the Mach port name to use when sending or receiving messages.
97 // Does the Right Thing in the browser and in child processes.
98 static std::string GetMachPortName();
99 // Callback used to register notifications on the UI thread. 100 // Callback used to register notifications on the UI thread.
100 void RegisterNotifications(); 101 void RegisterNotifications();
101 102
102 // True if the listener thread has been started. 103 // True if the listener thread has been started.
103 bool listener_thread_started_; 104 bool listener_thread_started_;
104 105
105 // Used to register for notifications received by NotificationObserver. 106 // Used to register for notifications received by NotificationObserver.
106 // Accessed only on the UI thread. 107 // Accessed only on the UI thread.
107 NotificationRegistrar registrar_; 108 NotificationRegistrar registrar_;
108 109
109 // Stores mach info for every process in the broker. 110 // Stores mach info for every process in the broker.
110 typedef std::map<base::ProcessHandle, mach_port_t> MachMap; 111 typedef std::map<base::ProcessHandle, mach_port_t> MachMap;
111 MachMap mach_map_; 112 MachMap mach_map_;
112 113
113 // Mutex that guards |mach_map_|. 114 // Mutex that guards |mach_map_|.
114 mutable base::Lock lock_; 115 mutable base::Lock lock_;
115 116
116 DISALLOW_COPY_AND_ASSIGN(MachBroker); 117 DISALLOW_COPY_AND_ASSIGN(MachBroker);
117 }; 118 };
118 119
119 } // namespace content 120 } // namespace content
120 121
121 #endif // CONTENT_BROWSER_MACH_BROKER_MAC_H_ 122 #endif // CONTENT_BROWSER_MACH_BROKER_MAC_H_
OLDNEW
« no previous file with comments | « content/browser/bootstrap_sandbox_mac.cc ('k') | content/browser/mach_broker_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698