Add basic support for CAPS exe
[chromium-blink-merge.git] / chrome / tools / crash_service / caps / process_singleton_win.cc
blobf51acccc6d4a52e5f48463619038b6041a2630db
1 // Copyright 2015 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.
5 #include <windows.h>
7 #include "chrome/tools/crash_service/caps/process_singleton_win.h"
9 namespace caps {
11 ProcessSingleton::ProcessSingleton() : mutex_(nullptr) {
12 auto mutex = ::CreateMutex(nullptr, TRUE, L"CHROME.CAPS.V1");
13 if (!mutex)
14 return;
15 if (::GetLastError() == ERROR_ALREADY_EXISTS) {
16 ::CloseHandle(mutex);
17 return;
19 // We are now the single instance.
20 mutex_ = mutex;
23 ProcessSingleton::~ProcessSingleton() {
24 if (mutex_)
25 ::CloseHandle(mutex_);
28 } // namespace caps