OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_COMMON_MULTI_PROCESS_LOCK_H_ |
| 6 #define CHROME_COMMON_MULTI_PROCESS_LOCK_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 |
| 11 // Platform abstraction for a recursive lock that can be shared between |
| 12 // processes. The process that owns the lock will release it on exit even if |
| 13 // the exit is due to a crash. |
| 14 class MultiProcessLock { |
| 15 public: |
| 16 // Factory method for creating a multi process lock. |
| 17 // |name| is the name of the lock. The name has special meaning on Windows |
| 18 // where the prefix can determine the namespace of the lock. |
| 19 // See http://msdn.microsoft.com/en-us/library/aa382954(v=VS.85).aspx for |
| 20 // details. |
| 21 static MultiProcessLock* Create(const std::string& name); |
| 22 |
| 23 virtual ~MultiProcessLock() { } |
| 24 |
| 25 // Try to grab ownership of the lock. |
| 26 virtual bool TryLock() = 0; |
| 27 |
| 28 // Release ownership of the lock. |
| 29 virtual void Unlock() = 0; |
| 30 }; |
| 31 |
| 32 #endif // CHROME_COMMON_MULTI_PROCESS_LOCK_H_ |
OLD | NEW |