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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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/mach_broker_mac.h ('k') | content/browser/plugin_service.h » ('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) 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 #include "content/browser/mach_broker_mac.h" 5 #include "content/browser/mach_broker_mac.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/mach_ipc_mac.h" 10 #include "base/mach_ipc_mac.h"
(...skipping 15 matching lines...) Expand all
26 26
27 // Required because notifications happen on the UI thread. 27 // Required because notifications happen on the UI thread.
28 class RegisterNotificationTask : public Task { 28 class RegisterNotificationTask : public Task {
29 public: 29 public:
30 RegisterNotificationTask( 30 RegisterNotificationTask(
31 MachBroker* broker) 31 MachBroker* broker)
32 : broker_(broker) { } 32 : broker_(broker) { }
33 33
34 virtual void Run() { 34 virtual void Run() {
35 broker_->registrar_.Add(broker_, 35 broker_->registrar_.Add(broker_,
36 NotificationType::RENDERER_PROCESS_CLOSED, 36 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
37 NotificationService::AllSources()); 37 NotificationService::AllSources());
38 broker_->registrar_.Add(broker_, 38 broker_->registrar_.Add(broker_,
39 NotificationType::RENDERER_PROCESS_TERMINATED, 39 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
40 NotificationService::AllSources()); 40 NotificationService::AllSources());
41 broker_->registrar_.Add(broker_, 41 broker_->registrar_.Add(broker_,
42 NotificationType::CHILD_PROCESS_CRASHED, 42 content::NOTIFICATION_CHILD_PROCESS_CRASHED,
43 NotificationService::AllSources()); 43 NotificationService::AllSources());
44 broker_->registrar_.Add(broker_, 44 broker_->registrar_.Add(broker_,
45 NotificationType::CHILD_PROCESS_HOST_DISCONNECTED, 45 content::NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED,
46 NotificationService::AllSources()); 46 NotificationService::AllSources());
47 } 47 }
48 48
49 private: 49 private:
50 MachBroker* broker_; 50 MachBroker* broker_;
51 DISALLOW_COPY_AND_ASSIGN(RegisterNotificationTask); 51 DISALLOW_COPY_AND_ASSIGN(RegisterNotificationTask);
52 }; 52 };
53 53
54 class MachListenerThreadDelegate : public base::PlatformThread::Delegate { 54 class MachListenerThreadDelegate : public base::PlatformThread::Delegate {
55 public: 55 public:
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 188
189 // Returns the mach task belonging to |pid|. 189 // Returns the mach task belonging to |pid|.
190 mach_port_t MachBroker::TaskForPid(base::ProcessHandle pid) const { 190 mach_port_t MachBroker::TaskForPid(base::ProcessHandle pid) const {
191 base::AutoLock lock(lock_); 191 base::AutoLock lock(lock_);
192 MachBroker::MachMap::const_iterator it = mach_map_.find(pid); 192 MachBroker::MachMap::const_iterator it = mach_map_.find(pid);
193 if (it == mach_map_.end()) 193 if (it == mach_map_.end())
194 return MACH_PORT_NULL; 194 return MACH_PORT_NULL;
195 return it->second.mach_task_; 195 return it->second.mach_task_;
196 } 196 }
197 197
198 void MachBroker::Observe(NotificationType type, 198 void MachBroker::Observe(int type,
199 const NotificationSource& source, 199 const NotificationSource& source,
200 const NotificationDetails& details) { 200 const NotificationDetails& details) {
201 // TODO(rohitrao): These notifications do not always carry the proper PIDs, 201 // TODO(rohitrao): These notifications do not always carry the proper PIDs,
202 // especially when the renderer is already gone or has crashed. Find a better 202 // especially when the renderer is already gone or has crashed. Find a better
203 // way to listen for child process deaths. http://crbug.com/55734 203 // way to listen for child process deaths. http://crbug.com/55734
204 base::ProcessHandle handle = 0; 204 base::ProcessHandle handle = 0;
205 switch (type.value) { 205 switch (type.value) {
206 case NotificationType::RENDERER_PROCESS_CLOSED: 206 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED:
207 case NotificationType::RENDERER_PROCESS_TERMINATED: 207 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED:
208 handle = Source<RenderProcessHost>(source)->GetHandle(); 208 handle = Source<RenderProcessHost>(source)->GetHandle();
209 break; 209 break;
210 case NotificationType::CHILD_PROCESS_CRASHED: 210 case content::NOTIFICATION_CHILD_PROCESS_CRASHED:
211 case NotificationType::CHILD_PROCESS_HOST_DISCONNECTED: 211 case content::NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED:
212 handle = Details<ChildProcessInfo>(details)->handle(); 212 handle = Details<ChildProcessInfo>(details)->handle();
213 break; 213 break;
214 default: 214 default:
215 NOTREACHED() << "Unexpected notification"; 215 NOTREACHED() << "Unexpected notification";
216 break; 216 break;
217 } 217 }
218 InvalidatePid(handle); 218 InvalidatePid(handle);
219 } 219 }
220 220
221 // static 221 // static
222 std::string MachBroker::GetMachPortName() { 222 std::string MachBroker::GetMachPortName() {
223 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 223 const CommandLine* command_line = CommandLine::ForCurrentProcess();
224 const bool is_child = command_line->HasSwitch(switches::kProcessType); 224 const bool is_child = command_line->HasSwitch(switches::kProcessType);
225 225
226 // In non-browser (child) processes, use the parent's pid. 226 // In non-browser (child) processes, use the parent's pid.
227 const pid_t pid = is_child ? getppid() : getpid(); 227 const pid_t pid = is_child ? getppid() : getpid();
228 return StringPrintf("%s.rohitfork.%d", base::mac::BaseBundleID(), pid); 228 return StringPrintf("%s.rohitfork.%d", base::mac::BaseBundleID(), pid);
229 } 229 }
OLDNEW
« no previous file with comments | « content/browser/mach_broker_mac.h ('k') | content/browser/plugin_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698