| OLD | NEW |
| 1 // Copyright (c) 2012 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 "chrome/common/service_process_util_posix.h" | 5 #include "chrome/common/service_process_util_posix.h" |
| 6 | 6 |
| 7 #include <signal.h> | 7 #include <signal.h> |
| 8 #include <unistd.h> | 8 #include <unistd.h> |
| 9 | 9 |
| 10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 24 MultiProcessLock* TakeNamedLock(const std::string& name, bool waiting) { | 24 MultiProcessLock* TakeNamedLock(const std::string& name, bool waiting) { |
| 25 scoped_ptr<MultiProcessLock> lock(MultiProcessLock::Create(name)); | 25 scoped_ptr<MultiProcessLock> lock(MultiProcessLock::Create(name)); |
| 26 if (lock == NULL) return NULL; | 26 if (lock == NULL) return NULL; |
| 27 bool got_lock = false; | 27 bool got_lock = false; |
| 28 for (int i = 0; i < 10; ++i) { | 28 for (int i = 0; i < 10; ++i) { |
| 29 if (lock->TryLock()) { | 29 if (lock->TryLock()) { |
| 30 got_lock = true; | 30 got_lock = true; |
| 31 break; | 31 break; |
| 32 } | 32 } |
| 33 if (!waiting) break; | 33 if (!waiting) break; |
| 34 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100 * i)); | 34 base::PlatformThread::Sleep(100 * i); |
| 35 } | 35 } |
| 36 if (!got_lock) { | 36 if (!got_lock) { |
| 37 lock.reset(); | 37 lock.reset(); |
| 38 } | 38 } |
| 39 return lock.release(); | 39 return lock.release(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 MultiProcessLock* TakeServiceInitializingLock(bool waiting) { | 42 MultiProcessLock* TakeServiceInitializingLock(bool waiting) { |
| 43 std::string lock_name = | 43 std::string lock_name = |
| 44 GetServiceProcessScopedName("_service_initializing"); | 44 GetServiceProcessScopedName("_service_initializing"); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 GetServiceProcessScopedName(GetBaseDesktopName()), | 102 GetServiceProcessScopedName(GetBaseDesktopName()), |
| 103 app_name, | 103 app_name, |
| 104 autorun_command_line_->GetCommandLineString(), | 104 autorun_command_line_->GetCommandLineString(), |
| 105 false); | 105 false); |
| 106 } | 106 } |
| 107 | 107 |
| 108 bool ServiceProcessState::RemoveFromAutoRun() { | 108 bool ServiceProcessState::RemoveFromAutoRun() { |
| 109 return AutoStart::Remove( | 109 return AutoStart::Remove( |
| 110 GetServiceProcessScopedName(GetBaseDesktopName())); | 110 GetServiceProcessScopedName(GetBaseDesktopName())); |
| 111 } | 111 } |
| OLD | NEW |