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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 OVERRIDE; | 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) OVERRIDE; | 87 const content::NotificationDetails& details) OVERRIDE; |
88 private: | 88 private: |
89 // Private constructor. | 89 friend class MachBrokerTest; |
| 90 friend struct DefaultSingletonTraits<MachBroker>; |
| 91 |
90 MachBroker(); | 92 MachBroker(); |
91 virtual ~MachBroker(); | 93 virtual ~MachBroker(); |
92 | 94 |
| 95 // Callback used to register notifications on the UI thread. |
| 96 void RegisterNotifications(); |
| 97 |
93 // True if the listener thread has been started. | 98 // True if the listener thread has been started. |
94 bool listener_thread_started_; | 99 bool listener_thread_started_; |
95 | 100 |
96 // Used to register for notifications received by NotificationObserver. | 101 // Used to register for notifications received by NotificationObserver. |
97 // Accessed only on the UI thread. | 102 // Accessed only on the UI thread. |
98 content::NotificationRegistrar registrar_; | 103 content::NotificationRegistrar registrar_; |
99 | 104 |
100 // Stores mach info for every process in the broker. | 105 // Stores mach info for every process in the broker. |
101 typedef std::map<base::ProcessHandle, MachInfo> MachMap; | 106 typedef std::map<base::ProcessHandle, MachInfo> MachMap; |
102 MachMap mach_map_; | 107 MachMap mach_map_; |
103 | 108 |
104 // Mutex that guards |mach_map_|. | 109 // Mutex that guards |mach_map_|. |
105 mutable base::Lock lock_; | 110 mutable base::Lock lock_; |
106 | 111 |
107 friend class MachBrokerTest; | |
108 friend class RegisterNotificationTask; | |
109 // Needed in order to make the constructor private. | |
110 friend struct DefaultSingletonTraits<MachBroker>; | |
111 DISALLOW_COPY_AND_ASSIGN(MachBroker); | 112 DISALLOW_COPY_AND_ASSIGN(MachBroker); |
112 }; | 113 }; |
113 | 114 |
114 #endif // CONTENT_BROWSER_MACH_BROKER_MAC_H_ | 115 #endif // CONTENT_BROWSER_MACH_BROKER_MAC_H_ |
OLD | NEW |