Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(729)

Side by Side Diff: chrome/common/multi_process_lock.h

Issue 8341052: share all the needed linux code with OpenBSD in chrome and content (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebased due to LOG macro changes Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 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 #ifndef CHROME_COMMON_MULTI_PROCESS_LOCK_H_ 5 #ifndef CHROME_COMMON_MULTI_PROCESS_LOCK_H_
6 #define CHROME_COMMON_MULTI_PROCESS_LOCK_H_ 6 #define CHROME_COMMON_MULTI_PROCESS_LOCK_H_
7 #pragma once 7 #pragma once
8 8
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #include <string> 10 #include <string>
11 11
12 // Platform abstraction for a lock that can be shared between processes. 12 // Platform abstraction for a lock that can be shared between processes.
13 // The process that owns the lock will release it on exit even if 13 // The process that owns the lock will release it on exit even if
14 // the exit is due to a crash. Locks are not recursive. 14 // the exit is due to a crash. Locks are not recursive.
15 class MultiProcessLock { 15 class MultiProcessLock {
16 public: 16 public:
17 17
18 // The length of a multi-process lock name is limited on Linux, so
19 // it is limited it on all platforms for consistency. This length does
20 // not include a terminator.
21 static const size_t MULTI_PROCESS_LOCK_NAME_MAX_LEN = 106;
22
23 // Factory method for creating a multi-process lock. 18 // Factory method for creating a multi-process lock.
24 // |name| is the name of the lock. The name has special meaning on Windows 19 // |name| is the name of the lock. The name has special meaning on Windows
25 // where the prefix can determine the namespace of the lock. 20 // where the prefix can determine the namespace of the lock.
26 // See http://msdn.microsoft.com/en-us/library/aa382954(v=VS.85).aspx for 21 // See http://msdn.microsoft.com/en-us/library/aa382954(v=VS.85).aspx for
27 // details. 22 // details.
28 static MultiProcessLock* Create(const std::string& name); 23 static MultiProcessLock* Create(const std::string& name);
29 24
30 virtual ~MultiProcessLock() { } 25 virtual ~MultiProcessLock() { }
31 26
32 // Try to grab ownership of the lock. 27 // Try to grab ownership of the lock.
33 virtual bool TryLock() = 0; 28 virtual bool TryLock() = 0;
34 29
35 // Release ownership of the lock. 30 // Release ownership of the lock.
36 virtual void Unlock() = 0; 31 virtual void Unlock() = 0;
37 }; 32 };
38 33
39 #endif // CHROME_COMMON_MULTI_PROCESS_LOCK_H_ 34 #endif // CHROME_COMMON_MULTI_PROCESS_LOCK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698