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

Unified Diff: base/shared_mutex_win.cc

Issue 4721001: Add multi_process_lock to chrome/common (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« base/shared_mutex_unittest.cc ('K') | « base/shared_mutex_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/shared_mutex_win.cc
diff --git a/base/shared_mutex_win.cc b/base/shared_mutex_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..324d3930db1b8d64a4a1d8da0d671db10a46717c
--- /dev/null
+++ b/base/shared_mutex_win.cc
@@ -0,0 +1,33 @@
+// 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 "base/shared_mutex.h"
+
+#include <string>
+#include <algorithm>
+
+#include "base/string_piece.h"
+#include "base/sys_string_conversions.h"
+
+namespace base {
+
+SharedMutex::SharedMutex(const std::string& name) : event_(NULL), name_(name) {
+}
+
+bool SharedMutex::TryLock() {
+ std::wstring wname = base::SysUTF8ToWide(name_);
sanjeevr 2010/11/09 06:21:05 Please use string16 instead of wstring.
dmac 2010/11/11 21:47:59 Done.
+ std::replace(wname.begin(), wname.end(), '\\', '!');
sanjeevr 2010/11/09 06:21:05 Not sure whether the escaping belongs here or outs
dmac 2010/11/11 21:47:59 Pulled escaping out.
+ wname = L"Global\\" + wname;
sanjeevr 2010/11/09 06:21:05 You should not add the "Global\\". We want the eve
dmac 2010/11/11 21:47:59 removed, and added comment in header about it.
+ event_ = CreateEvent(NULL, FALSE, FALSE, wname.c_str());
+ return event_ != NULL;
+}
+
+void SharedMutex::Unlock() {
+ if (event_) {
Mark Mentovai 2010/11/09 17:43:14 Don’t we have a ScopedHandle you could use?
dmac 2010/11/11 21:47:59 Done.
+ CloseHandle(event_);
+ event_ = NULL;
+ }
+}
+
+} // namespace base
« base/shared_mutex_unittest.cc ('K') | « base/shared_mutex_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698