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

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

Issue 4721001: Add multi_process_lock to chrome/common (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more clean up for mento Created 10 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 | Annotate | Revision Log
OLDNEW
(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>
Mark Mentovai 2010/11/16 18:55:15 C++ headers should follow C headers. <string> afte
10 #include <sys/types.h>
11
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
14 // the exit is due to a crash. Locks are not recursive.
15 class MultiProcessLock {
16 public:
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.
24 // |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.
26 // See http://msdn.microsoft.com/en-us/library/aa382954(v=VS.85).aspx for
27 // details.
28 static MultiProcessLock* Create(const std::string& name);
29
30 virtual ~MultiProcessLock() { }
31
32 // Try to grab ownership of the lock.
33 virtual bool TryLock() = 0;
34
35 // Release ownership of the lock.
36 virtual void Unlock() = 0;
37 };
38
39 #endif // CHROME_COMMON_MULTI_PROCESS_LOCK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698