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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« base/shared_mutex_unittest.cc ('K') | « base/shared_mutex_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "base/shared_mutex.h"
6
7 #include <string>
8 #include <algorithm>
9
10 #include "base/string_piece.h"
11 #include "base/sys_string_conversions.h"
12
13 namespace base {
14
15 SharedMutex::SharedMutex(const std::string& name) : event_(NULL), name_(name) {
16 }
17
18 bool SharedMutex::TryLock() {
19 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.
20 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.
21 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.
22 event_ = CreateEvent(NULL, FALSE, FALSE, wname.c_str());
23 return event_ != NULL;
24 }
25
26 void SharedMutex::Unlock() {
27 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.
28 CloseHandle(event_);
29 event_ = NULL;
30 }
31 }
32
33 } // namespace base
OLDNEW
« 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