| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/mach_broker_mac.h" | 5 #include "chrome/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/mach_ipc_mac.h" | 9 #include "base/mach_ipc_mac.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 // Returns the global MachBroker. | 123 // Returns the global MachBroker. |
| 124 MachBroker* MachBroker::GetInstance() { | 124 MachBroker* MachBroker::GetInstance() { |
| 125 return Singleton<MachBroker, LeakySingletonTraits<MachBroker> >::get(); | 125 return Singleton<MachBroker, LeakySingletonTraits<MachBroker> >::get(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 MachBroker::MachBroker() : listener_thread_started_(false) { | 128 MachBroker::MachBroker() : listener_thread_started_(false) { |
| 129 } | 129 } |
| 130 | 130 |
| 131 MachBroker::~MachBroker() {} |
| 132 |
| 131 void MachBroker::PrepareForFork() { | 133 void MachBroker::PrepareForFork() { |
| 132 if (!listener_thread_started_) { | 134 if (!listener_thread_started_) { |
| 133 listener_thread_started_ = true; | 135 listener_thread_started_ = true; |
| 134 | 136 |
| 135 BrowserThread::PostTask( | 137 BrowserThread::PostTask( |
| 136 BrowserThread::UI, FROM_HERE, new RegisterNotificationTask(this)); | 138 BrowserThread::UI, FROM_HERE, new RegisterNotificationTask(this)); |
| 137 | 139 |
| 138 // Intentional leak. This thread is never joined or reaped. | 140 // Intentional leak. This thread is never joined or reaped. |
| 139 base::PlatformThread::CreateNonJoinable( | 141 base::PlatformThread::CreateNonJoinable( |
| 140 0, new MachListenerThreadDelegate(this)); | 142 0, new MachListenerThreadDelegate(this)); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 #endif | 235 #endif |
| 234 ".rohitfork.%d"; | 236 ".rohitfork.%d"; |
| 235 | 237 |
| 236 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 238 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 237 const bool is_child = command_line.HasSwitch(switches::kProcessType); | 239 const bool is_child = command_line.HasSwitch(switches::kProcessType); |
| 238 | 240 |
| 239 // In non-browser (child) processes, use the parent's pid. | 241 // In non-browser (child) processes, use the parent's pid. |
| 240 const pid_t pid = is_child ? getppid() : getpid(); | 242 const pid_t pid = is_child ? getppid() : getpid(); |
| 241 return StringPrintf(kFormatString, pid); | 243 return StringPrintf(kFormatString, pid); |
| 242 } | 244 } |
| OLD | NEW |