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

Unified Diff: chrome/common/multi_process_lock_win.cc

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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/multi_process_lock_win.cc
diff --git a/chrome/common/multi_process_lock_win.cc b/chrome/common/multi_process_lock_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2cf5a88974e3ae1e3382d505227f05324f151165
--- /dev/null
+++ b/chrome/common/multi_process_lock_win.cc
@@ -0,0 +1,34 @@
+// 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.
+
+#include "chrome/common/multi_process_lock.h"
+
+#include "base/utf_string_conversions.h"
+#include "base/win/scoped_handle.h"
+
+class MultiProcessLockWin : public MultiProcessLock {
+ public:
+ explicit MultiProcessLockWin(const std::string& name)
+ : MultiProcessLock(name) { }
+
+ virtual ~MultiProcessLockWin() { Unlock(); }
+
+ virtual bool TryLock() {
+ string16 wname = UTF8ToUTF16(name_);
+ event_.Set(CreateEvent(NULL, FALSE, FALSE, wname.c_str()));
sanjeevr 2010/11/11 22:06:56 CreateEvent will succeed even if the event already
dmac 2010/11/11 23:33:02 Done.
+ return event_.Get() != NULL;
+ }
+
+ virtual void Unlock() {
+ event_.Set(NULL);
+ }
+
+ private:
+ base::win::ScopedHandle event_;
+ DISALLOW_COPY_AND_ASSIGN(MultiProcessLockWin);
+};
+
+MultiProcessLock* MultiProcessLock::Create(const std::string &name) {
+ return new MultiProcessLockWin(name);
+}
« chrome/common/multi_process_lock_linux.cc ('K') | « chrome/common/multi_process_lock_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698