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

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: removed long name test as it tripped a NOTREACHED call. 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>
10
11 // Platform abstraction for a lock that can be shared between processes.
12 // The process that owns the lock will release it on exit even if the exit is
13 // 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 // Try to grab ownership of the lock.
24 virtual bool TryLock() = 0;
Mark Mentovai 2010/11/11 22:08:27 Once you write “virtual” you should think long and
dmac 2010/11/11 23:33:02 Rookie mistake. D'oh. Done. Good catch.
25
26 // Release ownership of the lock.
27 virtual void Unlock() = 0;
28
29 protected:
Mark Mentovai 2010/11/11 22:08:27 protected sucks. I don’t think you need the constr
dmac 2010/11/11 23:33:02 I disagree that protected sucks, but hey. I agree
30 explicit MultiProcessLock(const std::string& name) : name_(name) { }
31
32 std::string name_;
33 };
Mark Mentovai 2010/11/11 22:08:27 #include "base/basictypes.h" [...] private: DIS
dmac 2010/11/11 23:33:02 Is that intended as "is this correct?" It doesn't
34
35 #endif // CHROME_COMMON_MULTI_PROCESS_LOCK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698