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

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: 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 "build/build_config.h"
10
9 #include <sys/types.h> 11 #include <sys/types.h>
10 #include <string> 12 #include <string>
11 13
12 // Platform abstraction for a lock that can be shared between processes. 14 // 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 15 // 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. 16 // the exit is due to a crash. Locks are not recursive.
15 class MultiProcessLock { 17 class MultiProcessLock {
16 public: 18 public:
17 19
18 // The length of a multi-process lock name is limited on Linux, so 20 // The length of a multi-process lock name is limited on Linux, so
Mark Mentovai 2011/10/26 23:24:28 This comment indicates that MULTI_PROCESS_LOCK_NAM
Robert Nagy 2011/10/31 15:38:38 I've done the modifications for the linux and the
Mark Mentovai 2011/10/31 15:47:40 Robert Nagy wrote:
19 // it is limited it on all platforms for consistency. This length does 21 // it is limited it on all platforms for consistency. This length does
20 // not include a terminator. 22 // not include a terminator.
23 #if defined(OS_OPENBSD)
24 static const size_t MULTI_PROCESS_LOCK_NAME_MAX_LEN = 102;
25 #else
21 static const size_t MULTI_PROCESS_LOCK_NAME_MAX_LEN = 106; 26 static const size_t MULTI_PROCESS_LOCK_NAME_MAX_LEN = 106;
27 #endif
22 28
23 // Factory method for creating a multi-process lock. 29 // Factory method for creating a multi-process lock.
24 // |name| is the name of the lock. The name has special meaning on Windows 30 // |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. 31 // 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 32 // See http://msdn.microsoft.com/en-us/library/aa382954(v=VS.85).aspx for
27 // details. 33 // details.
28 static MultiProcessLock* Create(const std::string& name); 34 static MultiProcessLock* Create(const std::string& name);
29 35
30 virtual ~MultiProcessLock() { } 36 virtual ~MultiProcessLock() { }
31 37
32 // Try to grab ownership of the lock. 38 // Try to grab ownership of the lock.
33 virtual bool TryLock() = 0; 39 virtual bool TryLock() = 0;
34 40
35 // Release ownership of the lock. 41 // Release ownership of the lock.
36 virtual void Unlock() = 0; 42 virtual void Unlock() = 0;
37 }; 43 };
38 44
39 #endif // CHROME_COMMON_MULTI_PROCESS_LOCK_H_ 45 #endif // CHROME_COMMON_MULTI_PROCESS_LOCK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698