| OLD | NEW |
| 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 #include "chrome/common/service_process_util_posix.h" | 5 #include "chrome/common/service_process_util_posix.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/eintr_wrapper.h" | 9 #include "base/eintr_wrapper.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 MultiProcessLock* TakeNamedLock(const std::string& name, bool waiting) { | 21 MultiProcessLock* TakeNamedLock(const std::string& name, bool waiting) { |
| 22 scoped_ptr<MultiProcessLock> lock(MultiProcessLock::Create(name)); | 22 scoped_ptr<MultiProcessLock> lock(MultiProcessLock::Create(name)); |
| 23 if (lock == NULL) return NULL; | 23 if (lock == NULL) return NULL; |
| 24 bool got_lock = false; | 24 bool got_lock = false; |
| 25 for (int i = 0; i < 10; ++i) { | 25 for (int i = 0; i < 10; ++i) { |
| 26 if (lock->TryLock()) { | 26 if (lock->TryLock()) { |
| 27 got_lock = true; | 27 got_lock = true; |
| 28 break; | 28 break; |
| 29 } | 29 } |
| 30 if (!waiting) break; | 30 if (!waiting) break; |
| 31 base::PlatformThread::Sleep(100 * i); | 31 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100 * i)); |
| 32 } | 32 } |
| 33 if (!got_lock) { | 33 if (!got_lock) { |
| 34 lock.reset(); | 34 lock.reset(); |
| 35 } | 35 } |
| 36 return lock.release(); | 36 return lock.release(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 ServiceProcessTerminateMonitor::ServiceProcessTerminateMonitor( | 39 ServiceProcessTerminateMonitor::ServiceProcessTerminateMonitor( |
| 40 const base::Closure& terminate_task) | 40 const base::Closure& terminate_task) |
| 41 : terminate_task_(terminate_task) { | 41 : terminate_task_(terminate_task) { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 signal_ready.Wait(); | 186 signal_ready.Wait(); |
| 187 return success; | 187 return success; |
| 188 } | 188 } |
| 189 | 189 |
| 190 void ServiceProcessState::TearDownState() { | 190 void ServiceProcessState::TearDownState() { |
| 191 if (state_) { | 191 if (state_) { |
| 192 state_->Release(); | 192 state_->Release(); |
| 193 state_ = NULL; | 193 state_ = NULL; |
| 194 } | 194 } |
| 195 } | 195 } |
| OLD | NEW |