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

Side by Side 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 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 #include "chrome/common/multi_process_lock.h"
6
7 #include "base/utf_string_conversions.h"
8 #include "base/win/scoped_handle.h"
9
10 class MultiProcessLockWin : public MultiProcessLock {
11 public:
12 explicit MultiProcessLockWin(const std::string& name)
13 : MultiProcessLock(name) { }
14
15 virtual ~MultiProcessLockWin() { Unlock(); }
16
17 virtual bool TryLock() {
18 string16 wname = UTF8ToUTF16(name_);
19 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.
20 return event_.Get() != NULL;
21 }
22
23 virtual void Unlock() {
24 event_.Set(NULL);
25 }
26
27 private:
28 base::win::ScopedHandle event_;
29 DISALLOW_COPY_AND_ASSIGN(MultiProcessLockWin);
30 };
31
32 MultiProcessLock* MultiProcessLock::Create(const std::string &name) {
33 return new MultiProcessLockWin(name);
34 }
OLDNEW
« 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