| 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 18 matching lines...) Expand all Loading... |
| 29 // the regular IPC system uses. Hence, the child processes open a Mach | 29 // the regular IPC system uses. Hence, the child processes open a Mach |
| 30 // connection shortly after launching and ipc their mach data to the browser | 30 // connection shortly after launching and ipc their mach data to the browser |
| 31 // process. This data is kept in a global |MachBroker| object. | 31 // process. This data is kept in a global |MachBroker| object. |
| 32 // | 32 // |
| 33 // Since this data arrives over a separate channel, it is not available | 33 // Since this data arrives over a separate channel, it is not available |
| 34 // immediately after a child process has been started. | 34 // immediately after a child process has been started. |
| 35 class MachBroker : public base::ProcessMetrics::PortProvider, | 35 class MachBroker : public base::ProcessMetrics::PortProvider, |
| 36 public content::NotificationObserver { | 36 public content::NotificationObserver { |
| 37 public: | 37 public: |
| 38 // Returns the global MachBroker. | 38 // Returns the global MachBroker. |
| 39 static MachBroker* GetInstance(); | 39 CONTENT_EXPORT static MachBroker* GetInstance(); |
| 40 | 40 |
| 41 // Performs any necessary setup that cannot happen in the constructor. | 41 // Performs any necessary setup that cannot happen in the constructor. |
| 42 // Callers MUST acquire the lock given by GetLock() before calling this | 42 // Callers MUST acquire the lock given by GetLock() before calling this |
| 43 // method (and release the lock afterwards). | 43 // method (and release the lock afterwards). |
| 44 void EnsureRunning(); | 44 void EnsureRunning(); |
| 45 | 45 |
| 46 struct MachInfo { | 46 struct MachInfo { |
| 47 MachInfo() : mach_task_(MACH_PORT_NULL) {} | 47 MachInfo() : mach_task_(MACH_PORT_NULL) {} |
| 48 | 48 |
| 49 MachInfo& SetTask(mach_port_t task) { | 49 MachInfo& SetTask(mach_port_t task) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 typedef std::map<base::ProcessHandle, MachInfo> MachMap; | 106 typedef std::map<base::ProcessHandle, MachInfo> MachMap; |
| 107 MachMap mach_map_; | 107 MachMap mach_map_; |
| 108 | 108 |
| 109 // Mutex that guards |mach_map_|. | 109 // Mutex that guards |mach_map_|. |
| 110 mutable base::Lock lock_; | 110 mutable base::Lock lock_; |
| 111 | 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(MachBroker); | 112 DISALLOW_COPY_AND_ASSIGN(MachBroker); |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 #endif // CONTENT_BROWSER_MACH_BROKER_MAC_H_ | 115 #endif // CONTENT_BROWSER_MACH_BROKER_MAC_H_ |
| OLD | NEW |