Index: chrome/common/multi_process_lock.h |
diff --git a/chrome/common/multi_process_lock.h b/chrome/common/multi_process_lock.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b30426e53779ce367d7742660eef1c225a417a63 |
--- /dev/null |
+++ b/chrome/common/multi_process_lock.h |
@@ -0,0 +1,35 @@ |
+// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_COMMON_MULTI_PROCESS_LOCK_H_ |
+#define CHROME_COMMON_MULTI_PROCESS_LOCK_H_ |
+#pragma once |
+ |
+#include <string> |
+ |
+// Platform abstraction for a lock that can be shared between processes. |
+// The process that owns the lock will release it on exit even if the exit is |
+// due to a crash. |
+class MultiProcessLock { |
+ public: |
+ // Factory method for creating a multi process lock. |
+ // |name| is the name of the lock. The name has special meaning on Windows |
+ // where the prefix can determine the namespace of the lock. |
+ // See http://msdn.microsoft.com/en-us/library/aa382954(v=VS.85).aspx for |
+ // details. |
+ static MultiProcessLock* Create(const std::string& name); |
+ |
+ // Try to grab ownership of the lock. |
+ 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.
|
+ |
+ // Release ownership of the lock. |
+ virtual void Unlock() = 0; |
+ |
+ 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
|
+ explicit MultiProcessLock(const std::string& name) : name_(name) { } |
+ |
+ std::string name_; |
+}; |
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
|
+ |
+#endif // CHROME_COMMON_MULTI_PROCESS_LOCK_H_ |