OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // The lock that protects this MachBroker object. Clients MUST acquire and | 72 // The lock that protects this MachBroker object. Clients MUST acquire and |
73 // release this lock around calls to EnsureRunning(), PlaceholderForPid(), | 73 // release this lock around calls to EnsureRunning(), PlaceholderForPid(), |
74 // and FinalizePid(). | 74 // and FinalizePid(). |
75 base::Lock& GetLock(); | 75 base::Lock& GetLock(); |
76 | 76 |
77 // Returns the Mach port name to use when sending or receiving messages. | 77 // Returns the Mach port name to use when sending or receiving messages. |
78 // Does the Right Thing in the browser and in child processes. | 78 // Does the Right Thing in the browser and in child processes. |
79 static std::string GetMachPortName(); | 79 static std::string GetMachPortName(); |
80 | 80 |
81 // Implement |ProcessMetrics::PortProvider|. | 81 // Implement |ProcessMetrics::PortProvider|. |
82 virtual mach_port_t TaskForPid(base::ProcessHandle process) const; | 82 virtual mach_port_t TaskForPid(base::ProcessHandle process) const OVERRIDE; |
83 | 83 |
84 // Implement |content::NotificationObserver|. | 84 // Implement |content::NotificationObserver|. |
85 virtual void Observe(int type, | 85 virtual void Observe(int type, |
86 const content::NotificationSource& source, | 86 const content::NotificationSource& source, |
87 const content::NotificationDetails& details); | 87 const content::NotificationDetails& details) OVERRIDE; |
88 private: | 88 private: |
89 // Private constructor. | 89 // Private constructor. |
90 MachBroker(); | 90 MachBroker(); |
91 virtual ~MachBroker(); | 91 virtual ~MachBroker(); |
92 | 92 |
93 // True if the listener thread has been started. | 93 // True if the listener thread has been started. |
94 bool listener_thread_started_; | 94 bool listener_thread_started_; |
95 | 95 |
96 // Used to register for notifications received by NotificationObserver. | 96 // Used to register for notifications received by NotificationObserver. |
97 // Accessed only on the UI thread. | 97 // Accessed only on the UI thread. |
98 content::NotificationRegistrar registrar_; | 98 content::NotificationRegistrar registrar_; |
99 | 99 |
100 // Stores mach info for every process in the broker. | 100 // Stores mach info for every process in the broker. |
101 typedef std::map<base::ProcessHandle, MachInfo> MachMap; | 101 typedef std::map<base::ProcessHandle, MachInfo> MachMap; |
102 MachMap mach_map_; | 102 MachMap mach_map_; |
103 | 103 |
104 // Mutex that guards |mach_map_|. | 104 // Mutex that guards |mach_map_|. |
105 mutable base::Lock lock_; | 105 mutable base::Lock lock_; |
106 | 106 |
107 friend class MachBrokerTest; | 107 friend class MachBrokerTest; |
108 friend class RegisterNotificationTask; | 108 friend class RegisterNotificationTask; |
109 // Needed in order to make the constructor private. | 109 // Needed in order to make the constructor private. |
110 friend struct DefaultSingletonTraits<MachBroker>; | 110 friend struct DefaultSingletonTraits<MachBroker>; |
111 DISALLOW_COPY_AND_ASSIGN(MachBroker); | 111 DISALLOW_COPY_AND_ASSIGN(MachBroker); |
112 }; | 112 }; |
113 | 113 |
114 #endif // CONTENT_BROWSER_MACH_BROKER_MAC_H_ | 114 #endif // CONTENT_BROWSER_MACH_BROKER_MAC_H_ |
OLD | NEW |