| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include <windows.h> | |
| 6 | |
| 7 #include "chrome/tools/crash_service/caps/process_singleton_win.h" | |
| 8 | |
| 9 namespace caps { | |
| 10 | |
| 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; | |
| 18 } | |
| 19 // We are now the single instance. | |
| 20 mutex_ = mutex; | |
| 21 } | |
| 22 | |
| 23 ProcessSingleton::~ProcessSingleton() { | |
| 24 if (mutex_) | |
| 25 ::CloseHandle(mutex_); | |
| 26 } | |
| 27 | |
| 28 } // namespace caps | |
| 29 | |
| OLD | NEW |