Bug 950241 - Add process running helpers to CEHHelpers. r=bbondy, a=lsblakk
authorJim Mathies <jmathies@mozilla.com>
Thu, 30 Jan 2014 13:32:48 -0600
changeset 176258 07c25785ec6745593845ec758aa7a854abf25289
parent 176257 5e595adf2d9e5793f41466e997bf5ac6ffc6316f
child 176259 dddf11dc7526f5bdc1b26dd94ccb6f25de58c8d0
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy, lsblakk
bugs950241
milestone28.0
Bug 950241 - Add process running helpers to CEHHelpers. r=bbondy, a=lsblakk
browser/metro/shell/commandexecutehandler/CEHHelper.cpp
browser/metro/shell/commandexecutehandler/CEHHelper.h
--- a/browser/metro/shell/commandexecutehandler/CEHHelper.cpp
+++ b/browser/metro/shell/commandexecutehandler/CEHHelper.cpp
@@ -8,46 +8,49 @@
 
 #ifdef SHOW_CONSOLE
 #include <io.h> // _open_osfhandle
 #endif
 
 HANDLE sCon;
 LPCWSTR metroDX10Available = L"MetroD3DAvailable";
 LPCWSTR metroLastAHE = L"MetroLastAHE";
+LPCWSTR cehDumpDebugStrings = L"CEHDump";
+extern const WCHAR* kFirefoxExe;
 
 typedef HRESULT (WINAPI*D3D10CreateDevice1Func)
   (IDXGIAdapter *, D3D10_DRIVER_TYPE, HMODULE, UINT,
    D3D10_FEATURE_LEVEL1, UINT, ID3D10Device1 **);
 typedef HRESULT(WINAPI*CreateDXGIFactory1Func)(REFIID , void **);
 
 void
 Log(const wchar_t *fmt, ...)
 {
 #if !defined(SHOW_CONSOLE)
-  return;
+  DWORD dwRes = 0;
+  if (!GetDWORDRegKey(cehDumpDebugStrings, dwRes) || !dwRes) {
+    return;
+  }
 #endif
   va_list a = nullptr;
   wchar_t szDebugString[1024];
   if(!lstrlenW(fmt))
     return;
   va_start(a,fmt);
   vswprintf(szDebugString, 1024, fmt, a);
   va_end(a);
   if(!lstrlenW(szDebugString))
     return;
 
   DWORD len;
   WriteConsoleW(sCon, szDebugString, lstrlenW(szDebugString), &len, nullptr);
   WriteConsoleW(sCon, L"\n", 1, &len, nullptr);
 
-  if (IsDebuggerPresent()) {  
-    OutputDebugStringW(szDebugString);
-    OutputDebugStringW(L"\n");
-  }
+  OutputDebugStringW(szDebugString);
+  OutputDebugStringW(L"\n");
 }
 
 #if defined(SHOW_CONSOLE)
 void
 SetupConsole()
 {
   FILE *fp;
   AllocConsole();
@@ -103,16 +106,28 @@ IsProcessRunning(const wchar_t *processN
       }
     }
   }
 
   CloseHandle(snapshot);
   return exists;
 }
 
+bool
+IsMetroProcessRunning()
+{
+  return IsProcessRunning(kFirefoxExe, true);
+}
+
+bool
+IsDesktopProcessRunning()
+{
+  return IsProcessRunning(kFirefoxExe, false);
+}
+
 /*
  * Retrieve the last front end ui we launched so we can target it
  * again. This value is updated down in nsAppRunner when the browser
  * starts up.
  */
 AHE_TYPE
 GetLastAHE()
 {
--- a/browser/metro/shell/commandexecutehandler/CEHHelper.h
+++ b/browser/metro/shell/commandexecutehandler/CEHHelper.h
@@ -26,9 +26,10 @@ void SetupConsole();
 #endif
 
 AHE_TYPE GetLastAHE();
 bool SetLastAHE(AHE_TYPE ahe);
 bool IsDX10Available();
 bool GetDWORDRegKey(LPCWSTR name, DWORD &value);
 bool SetDWORDRegKey(LPCWSTR name, DWORD value);
 bool IsImmersiveProcessDynamic(HANDLE process);
-bool IsProcessRunning(const wchar_t *processName, bool bCheckIfMetro);
+bool IsMetroProcessRunning();
+bool IsDesktopProcessRunning();