Index: chrome/tools/crash_service/caps/process_singleton_win.cc |
diff --git a/chrome/tools/crash_service/caps/process_singleton_win.cc b/chrome/tools/crash_service/caps/process_singleton_win.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3859a6674226f3c955df29e7bf46ecbfd34303a4 |
--- /dev/null |
+++ b/chrome/tools/crash_service/caps/process_singleton_win.cc |
@@ -0,0 +1,29 @@ |
+// Copyright 2015 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 <windows.h> |
+ |
+#include "chrome/tools/crash_service/caps/process_singleton_win.h" |
+ |
+namespace caps { |
+ |
+ProcessSingleton::ProcessSingleton() : mutex_(NULL) { |
scottmg
2015/02/01 19:55:35
NULL -> nullptr
|
+ auto mutex = ::CreateMutexW(nullptr, TRUE, L"CHROME.CAPS.V1"); |
scottmg
2015/02/01 19:55:35
no W (are we not building as _UNICODE properly? if
cpu_(ooo_6.6-7.5)
2015/02/03 02:44:58
afaik we build ok, old habits die hard. changed.
|
+ if (!mutex) |
+ return; |
+ if (::GetLastError() == ERROR_ALREADY_EXISTS) { |
+ ::CloseHandle(mutex); |
+ return; |
+ } |
+ // We are now the single instance. |
+ mutex_ = mutex; |
+} |
+ |
+ProcessSingleton::~ProcessSingleton() { |
+ if (mutex_) |
+ ::CloseHandle(mutex_); |
+} |
+ |
+} // namespace caps |
+ |