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

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

Issue 681733003: Removed the ProcessHandle from the RendererClosedDetails payload (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed review comments Created 6 years 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
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 <mach/mach.h>
9
8 #include <map> 10 #include <map>
9 #include <string> 11 #include <string>
10 12
11 #include <mach/mach.h>
12
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 #include "base/process/process_handle.h" 14 #include "base/process/process_handle.h"
15 #include "base/process/process_metrics.h" 15 #include "base/process/process_metrics.h"
16 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
17 #include "content/public/browser/browser_child_process_observer.h" 17 #include "content/public/browser/browser_child_process_observer.h"
18 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
20 20
21 namespace content { 21 namespace content {
22 22
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 // Performs any necessary setup that cannot happen in the constructor. 55 // Performs any necessary setup that cannot happen in the constructor.
56 // Callers MUST acquire the lock given by GetLock() before calling this 56 // Callers MUST acquire the lock given by GetLock() before calling this
57 // method (and release the lock afterwards). 57 // method (and release the lock afterwards).
58 void EnsureRunning(); 58 void EnsureRunning();
59 59
60 // Adds a placeholder to the map for the given pid with MACH_PORT_NULL. 60 // Adds a placeholder to the map for the given pid with MACH_PORT_NULL.
61 // Callers are expected to later update the port with FinalizePid(). Callers 61 // Callers are expected to later update the port with FinalizePid(). Callers
62 // MUST acquire the lock given by GetLock() before calling this method (and 62 // MUST acquire the lock given by GetLock() before calling this method (and
63 // release the lock afterwards). 63 // release the lock afterwards).
64 void AddPlaceholderForPid(base::ProcessHandle pid); 64 void AddPlaceholderForPid(base::ProcessHandle pid, int child_process_id);
65 65
66 // Implement |ProcessMetrics::PortProvider|. 66 // Implement |ProcessMetrics::PortProvider|.
67 mach_port_t TaskForPid(base::ProcessHandle process) const override; 67 mach_port_t TaskForPid(base::ProcessHandle process) const override;
68 68
69 // Implement |BrowserChildProcessObserver|. 69 // Implement |BrowserChildProcessObserver|.
70 void BrowserChildProcessHostDisconnected( 70 void BrowserChildProcessHostDisconnected(
71 const ChildProcessData& data) override; 71 const ChildProcessData& data) override;
72 void BrowserChildProcessCrashed(const ChildProcessData& data) override; 72 void BrowserChildProcessCrashed(const ChildProcessData& data) override;
73 73
74 // Implement |NotificationObserver|. 74 // Implement |NotificationObserver|.
75 void Observe(int type, 75 void Observe(int type,
76 const NotificationSource& source, 76 const NotificationSource& source,
77 const NotificationDetails& details) override; 77 const NotificationDetails& details) override;
78 78
79 private: 79 private:
80 friend class MachBrokerTest; 80 friend class MachBrokerTest;
81 friend class MachListenerThreadDelegate; 81 friend class MachListenerThreadDelegate;
82 friend struct DefaultSingletonTraits<MachBroker>; 82 friend struct DefaultSingletonTraits<MachBroker>;
83 83
84 MachBroker(); 84 MachBroker();
85 ~MachBroker() override; 85 ~MachBroker() override;
86 86
87 // Updates the mapping for |pid| to include the given |mach_info|. Does 87 // Updates the mapping for |pid| to include the given |mach_info|. Does
88 // nothing if PlaceholderForPid() has not already been called for the given 88 // nothing if PlaceholderForPid() has not already been called for the given
89 // |pid|. Callers MUST acquire the lock given by GetLock() before calling 89 // |pid|. Callers MUST acquire the lock given by GetLock() before calling
90 // this method (and release the lock afterwards). 90 // this method (and release the lock afterwards).
91 void FinalizePid(base::ProcessHandle pid, mach_port_t task_port); 91 void FinalizePid(base::ProcessHandle pid, mach_port_t task_port);
92 92
93 // Removes all mappings belonging to |pid| from the broker. 93 // Removes all mappings belonging to |child_process_id| from the broker.
94 void InvalidatePid(base::ProcessHandle pid); 94 void InvalidateChildProcessId(int child_process_id);
95 95
96 // Returns the Mach port name to use when sending or receiving messages. 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. 97 // Does the Right Thing in the browser and in child processes.
98 static std::string GetMachPortName(); 98 static std::string GetMachPortName();
99 // Callback used to register notifications on the UI thread. 99 // Callback used to register notifications on the UI thread.
100 void RegisterNotifications(); 100 void RegisterNotifications();
101 101
102 // True if the listener thread has been started. 102 // True if the listener thread has been started.
103 bool listener_thread_started_; 103 bool listener_thread_started_;
104 104
105 // Used to register for notifications received by NotificationObserver. 105 // Used to register for notifications received by NotificationObserver.
106 // Accessed only on the UI thread. 106 // Accessed only on the UI thread.
107 NotificationRegistrar registrar_; 107 NotificationRegistrar registrar_;
108 108
109 // Stores mach info for every process in the broker. 109 // Stores mach info for every process in the broker.
110 typedef std::map<base::ProcessHandle, mach_port_t> MachMap; 110 typedef std::map<base::ProcessHandle, mach_port_t> MachMap;
111 MachMap mach_map_; 111 MachMap mach_map_;
112 112
113 // Mutex that guards |mach_map_|. 113 // Stores the Child process unique id (RenderProcessHost ID) for every
114 // process.
115 typedef std::map<int, base::ProcessHandle> ChildProcessIdMap;
116 ChildProcessIdMap child_process_id_map_;
117
118 // Mutex that guards |mach_map_| and |child_process_id_map_|.
114 mutable base::Lock lock_; 119 mutable base::Lock lock_;
115 120
116 DISALLOW_COPY_AND_ASSIGN(MachBroker); 121 DISALLOW_COPY_AND_ASSIGN(MachBroker);
117 }; 122 };
118 123
119 } // namespace content 124 } // namespace content
120 125
121 #endif // CONTENT_BROWSER_MACH_BROKER_MAC_H_ 126 #endif // CONTENT_BROWSER_MACH_BROKER_MAC_H_
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager_unittest.cc ('k') | content/browser/mach_broker_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698