Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/plugin/PluginMutex.cpp

Issue 6523237609504768: Issue #276 - eliminate CString from CPluginMutex (Closed)
Patch Set: Created July 30, 2014, 5:56 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/plugin/PluginMutex.cpp
===================================================================
--- a/src/plugin/PluginMutex.cpp
+++ b/src/plugin/PluginMutex.cpp
@@ -5,25 +5,26 @@
#include "sddl.h"
-CPluginMutex::CPluginMutex(const CString& name, int errorSubidBase) : m_isLocked(false), m_errorSubidBase(errorSubidBase), m_name(name)
+CPluginMutex::CPluginMutex(const std::wstring& name, int errorSubidBase)
+ : m_isLocked(false), m_errorSubidBase(errorSubidBase), system_name(L"Global\\AdblockPlus" + name)
{
if (m_errorSubidBase != PLUGIN_ERROR_MUTEX_DEBUG_FILE)
{
- DEBUG_MUTEX("Mutex::Create name:" + name)
+ DEBUG_MUTEX(L"Mutex::Create name:" + name)
}
-
- m_hMutex = ::CreateMutex(NULL, FALSE, "Global\\AdblockPlus" + name);
+ m_hMutex = CreateMutexW(NULL, FALSE, system_name.c_str());
if (m_hMutex == NULL)
{
DWORD error = GetLastError();
- m_hMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, "Global\\AdblockPlus" + name);
+ m_hMutex = OpenMutexW(MUTEX_ALL_ACCESS, FALSE, system_name.c_str());
if (m_hMutex == NULL)
{
- m_hMutex = ::CreateMutex(NULL, FALSE, "Local\\AdblockPlus" + name);
+ system_name = L"Local\\AdblockPlus" + name;
+ m_hMutex = CreateMutexW(NULL, FALSE, system_name.c_str());
if (m_hMutex == NULL)
{
- m_hMutex = OpenMutex(NULL, FALSE, "Local\\AdblockPlus" + name);
+ m_hMutex = OpenMutexW(NULL, FALSE, system_name.c_str());
if (m_hMutex == NULL)
{
DWORD error = GetLastError();
@@ -31,6 +32,7 @@
}
}
else
+ // TODO: Combine this block with identical one below.
{
switch (::WaitForSingleObject(m_hMutex, 3000))
{
@@ -53,6 +55,7 @@
}
}
else
+ // TODO: Combine this block with identical one above.
{
switch (::WaitForSingleObject(m_hMutex, 3000))
{
@@ -77,7 +80,7 @@
{
if (m_errorSubidBase != PLUGIN_ERROR_MUTEX_DEBUG_FILE)
{
- DEBUG_MUTEX("Mutex::Release name:" + m_name)
+ DEBUG_MUTEX(L"Mutex::Release name:" + system_name)
}
if (m_isLocked)

Powered by Google App Engine
This is Rietveld