| 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 #include "content/browser/mach_broker_mac.h" | 5 #include "content/browser/mach_broker_mac.h" |
| 6 | 6 |
| 7 #include <bsm/libbsm.h> | 7 #include <bsm/libbsm.h> |
| 8 #include <servers/bootstrap.h> | 8 #include <servers/bootstrap.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 return; | 269 return; |
| 270 | 270 |
| 271 kern_return_t kr = mach_port_deallocate(mach_task_self(), | 271 kern_return_t kr = mach_port_deallocate(mach_task_self(), |
| 272 it->second); | 272 it->second); |
| 273 MACH_LOG_IF(WARNING, kr != KERN_SUCCESS, kr) << "mach_port_deallocate"; | 273 MACH_LOG_IF(WARNING, kr != KERN_SUCCESS, kr) << "mach_port_deallocate"; |
| 274 mach_map_.erase(it); | 274 mach_map_.erase(it); |
| 275 } | 275 } |
| 276 | 276 |
| 277 // static | 277 // static |
| 278 std::string MachBroker::GetMachPortName() { | 278 std::string MachBroker::GetMachPortName() { |
| 279 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 279 const base::CommandLine* command_line = |
| 280 base::CommandLine::ForCurrentProcess(); |
| 280 const bool is_child = command_line->HasSwitch(switches::kProcessType); | 281 const bool is_child = command_line->HasSwitch(switches::kProcessType); |
| 281 | 282 |
| 282 // In non-browser (child) processes, use the parent's pid. | 283 // In non-browser (child) processes, use the parent's pid. |
| 283 const pid_t pid = is_child ? getppid() : getpid(); | 284 const pid_t pid = is_child ? getppid() : getpid(); |
| 284 return base::StringPrintf("%s.rohitfork.%d", base::mac::BaseBundleID(), pid); | 285 return base::StringPrintf("%s.rohitfork.%d", base::mac::BaseBundleID(), pid); |
| 285 } | 286 } |
| 286 | 287 |
| 287 void MachBroker::RegisterNotifications() { | 288 void MachBroker::RegisterNotifications() { |
| 288 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSED, | 289 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 289 NotificationService::AllBrowserContextsAndSources()); | 290 NotificationService::AllBrowserContextsAndSources()); |
| 290 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 291 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| 291 NotificationService::AllBrowserContextsAndSources()); | 292 NotificationService::AllBrowserContextsAndSources()); |
| 292 | 293 |
| 293 // No corresponding StopObservingBrowserChildProcesses, | 294 // No corresponding StopObservingBrowserChildProcesses, |
| 294 // we leak this singleton. | 295 // we leak this singleton. |
| 295 BrowserChildProcessObserver::Add(this); | 296 BrowserChildProcessObserver::Add(this); |
| 296 } | 297 } |
| 297 | 298 |
| 298 } // namespace content | 299 } // namespace content |
| OLD | NEW |