Title: [156911] trunk/Tools
Revision
156911
Author
[email protected]
Date
2013-10-04 13:37:53 -0700 (Fri, 04 Oct 2013)

Log Message

Made WinLauncher have better error handling, crash reporting, and modifiability.
https://bugs.webkit.org/show_bug.cgi?id=122319

Patch by Alex Christensen <[email protected]> on 2013-10-04
Reviewed by Brent Fulgham.

* WinLauncher/WinLauncher.cpp:
(WinLauncherWebHost::didFailProvisionalLoadWithError):
Don't display the numerous "Cancelled" messages that are obviously from the user.
(createCrashReport): Added.
(dllLauncherEntryPoint):
Made main loop back into while loop and write a crash report if it crashes.
* WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj:
* WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj.filters:
Added WinLauncherReplace.h.
* WinLauncher/WinLauncher.vcxproj/WinLauncherLibCommon.props:
Added linking to DbgHelp.lib.
* WinLauncher/WinLauncherReplace.h:
Added to make modifying WinLauncher behaviour and appearance easy.
(processCrashDump): Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (156910 => 156911)


--- trunk/Tools/ChangeLog	2013-10-04 20:35:24 UTC (rev 156910)
+++ trunk/Tools/ChangeLog	2013-10-04 20:37:53 UTC (rev 156911)
@@ -1,3 +1,25 @@
+2013-10-04  Alex Christensen  <[email protected]>
+
+        Made WinLauncher have better error handling, crash reporting, and modifiability.
+        https://bugs.webkit.org/show_bug.cgi?id=122319
+
+        Reviewed by Brent Fulgham.
+
+        * WinLauncher/WinLauncher.cpp:
+        (WinLauncherWebHost::didFailProvisionalLoadWithError):
+        Don't display the numerous "Cancelled" messages that are obviously from the user.
+        (createCrashReport): Added.
+        (dllLauncherEntryPoint):
+        Made main loop back into while loop and write a crash report if it crashes.
+        * WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj:
+        * WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj.filters:
+        Added WinLauncherReplace.h.
+        * WinLauncher/WinLauncher.vcxproj/WinLauncherLibCommon.props:
+        Added linking to DbgHelp.lib.
+        * WinLauncher/WinLauncherReplace.h:
+        Added to make modifying WinLauncher behaviour and appearance easy.
+        (processCrashDump): Added.
+
 2013-10-04  Dirk Pranke  <[email protected]>
 
         remove dpranke from webkitpy watchlist

Modified: trunk/Tools/WinLauncher/WinLauncher.cpp (156910 => 156911)


--- trunk/Tools/WinLauncher/WinLauncher.cpp	2013-10-04 20:35:24 UTC (rev 156910)
+++ trunk/Tools/WinLauncher/WinLauncher.cpp	2013-10-04 20:37:53 UTC (rev 156911)
@@ -33,6 +33,7 @@
 #include "DOMDefaultImpl.h"
 #include "PrintWebUIDelegate.h"
 #include "WinLauncherLibResource.h"
+#include "WinLauncherReplace.h"
 #include <WebKit/WebKitCOMAPI.h>
 #include <wtf/ExportMacros.h>
 #include <wtf/Platform.h>
@@ -47,9 +48,11 @@
 #include <commctrl.h>
 #include <commdlg.h>
 #include <comutil.h>
+#include <dbghelp.h>
 #include <functional>
 #include <objbase.h>
 #include <shellapi.h>
+#include <shlobj.h>
 #include <shlwapi.h>
 #include <string>
 #include <vector>
@@ -180,7 +183,8 @@
     if (FAILED(hr))
         errorDescription = L"Failed to load page and to localize error description.";
 
-    ::MessageBoxW(0, static_cast<LPCWSTR>(errorDescription), L"Error", MB_APPLMODAL | MB_OK);
+    if (_wcsicmp(errorDescription, L"Cancelled"))
+        ::MessageBoxW(0, static_cast<LPCWSTR>(errorDescription), L"Error", MB_APPLMODAL | MB_OK);
 
     return S_OK;
 }
@@ -408,11 +412,40 @@
     return true;
 }
 
+void createCrashReport(EXCEPTION_POINTERS* exceptionPointers)
+{
+    wchar_t appDataDirectory[MAX_PATH];
+    if (FAILED(SHGetFolderPathW(0, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, 0, 0, appDataDirectory)))
+        return;
 
-#if USE(CF)
-extern "C" void _CFRunLoopSetWindowsMessageQueueMask(CFRunLoopRef, uint32_t, CFStringRef);
+    std::wstring directory = std::wstring(appDataDirectory) + L"\\WinLauncher";
+    if (::SHCreateDirectoryEx(0, directory.c_str(), 0) != ERROR_SUCCESS
+        && ::GetLastError() != ERROR_FILE_EXISTS
+        && ::GetLastError() != ERROR_ALREADY_EXISTS)
+        return;
+
+    std::wstring fileName = directory + L"\\CrashReport.dmp";
+    HANDLE miniDumpFile = ::CreateFile(fileName.c_str(), GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
+
+    if (miniDumpFile && miniDumpFile != INVALID_HANDLE_VALUE) {
+
+        MINIDUMP_EXCEPTION_INFORMATION mdei;
+        mdei.ThreadId = ::GetCurrentThreadId();
+        mdei.ExceptionPointers  = exceptionPointers;
+        mdei.ClientPointers = 0;
+
+#ifdef _DEBUG
+        MINIDUMP_TYPE dumpType = MiniDumpWithFullMemory;
+#else
+        MINIDUMP_TYPE dumpType = MiniDumpNormal;
 #endif
 
+        ::MiniDumpWriteDump(::GetCurrentProcess(), ::GetCurrentProcessId(), miniDumpFile, dumpType, &mdei, 0, 0);
+        ::CloseHandle(miniDumpFile);
+        processCrashReport(fileName.c_str());
+    }
+}
+
 extern "C" __declspec(dllexport) int WINAPI dllLauncherEntryPoint(HINSTANCE, HINSTANCE, LPTSTR, int nCmdShow)
 {
 #ifdef _CRTDBG_MAP_ALLOC
@@ -539,8 +572,7 @@
         if (FAILED(hr))
             goto exit;
 
-        _bstr_t defaultHTML(L"<p style=\"background-color: #00FF00\">Testing</p><img id=\"webkit logo\" src="" alt=\"Face\"><div style=\"border: solid blue; background: white;\" contenteditable=\"true\">div with blue border</div><ul><li>foo<li>bar<li>baz</ul>");
-        frame->loadHTMLString(defaultHTML.GetBSTR(), 0);
+        frame->loadHTMLString(_bstr_t(defaultHTML).GetBSTR(), 0);
     }
 
     hr = gWebViewPrivate->setTransparent(usesLayeredWebView());
@@ -568,18 +600,20 @@
     if (requestedURL.length())
         loadURL(requestedURL.GetBSTR());
 
+#pragma warning(disable:4509)
+
     // Main message loop:
+    __try {
+        while (GetMessage(&msg, 0, 0, 0)) {
 #if USE(CF)
-    _CFRunLoopSetWindowsMessageQueueMask(CFRunLoopGetMain(), QS_ALLINPUT | QS_ALLPOSTMESSAGE, kCFRunLoopDefaultMode);
-    CFRunLoopRun();
-#else
-    while (GetMessage(&msg, NULL, 0, 0)) {
-        if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {
-            TranslateMessage(&msg);
-            DispatchMessage(&msg);
+            CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true);
+#endif
+            if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {
+                TranslateMessage(&msg);
+                DispatchMessage(&msg);
+            }
         }
-    }
-#endif
+    } __except(createCrashReport(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER) { }
 
 exit:
     gPrintDelegate->Release();

Modified: trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj (156910 => 156911)


--- trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj	2013-10-04 20:35:24 UTC (rev 156910)
+++ trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj	2013-10-04 20:37:53 UTC (rev 156911)
@@ -206,6 +206,7 @@
     <ClInclude Include="..\PrintWebUIDelegate.h" />
     <ClInclude Include="..\stdafx.h" />
     <ClInclude Include="..\WinLauncher.h" />
+    <ClInclude Include="..\WinLauncherReplace.h" />
     <ClInclude Include="WinLauncherLibResource.h" />
   </ItemGroup>
   <ItemGroup>

Modified: trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj.filters (156910 => 156911)


--- trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj.filters	2013-10-04 20:35:24 UTC (rev 156910)
+++ trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj.filters	2013-10-04 20:37:53 UTC (rev 156911)
@@ -57,6 +57,9 @@
     <ClInclude Include="..\AccessibilityDelegate.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\WinLauncherReplace.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="WinLauncherLib.rc">

Modified: trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLibCommon.props (156910 => 156911)


--- trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLibCommon.props	2013-10-04 20:35:24 UTC (rev 156910)
+++ trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLibCommon.props	2013-10-04 20:37:53 UTC (rev 156911)
@@ -10,7 +10,7 @@
       <PrecompiledHeaderFile>StdAfx.h</PrecompiledHeaderFile>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>comdlg32.lib;comsuppw.lib;gdi32.lib;comctl32.lib;shlwapi.lib;user32.lib;ole32.lib;oleaut32.lib;WebKitGUID$(DebugSuffix).lib;WebKit$(DebugSuffix).lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>DbgHelp.lib;comdlg32.lib;comsuppw.lib;gdi32.lib;comctl32.lib;shlwapi.lib;user32.lib;ole32.lib;oleaut32.lib;WebKitGUID$(DebugSuffix).lib;WebKit$(DebugSuffix).lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
 </Project>
\ No newline at end of file

Added: trunk/Tools/WinLauncher/WinLauncherReplace.h (0 => 156911)


--- trunk/Tools/WinLauncher/WinLauncherReplace.h	                        (rev 0)
+++ trunk/Tools/WinLauncher/WinLauncherReplace.h	2013-10-04 20:37:53 UTC (rev 156911)
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2013 Alex Christensen. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// This file is to make it easier for users to manage changes to the internals of WinLauncher
+
+const wchar_t* defaultHTML = L"<p style=\"background-color: #00FF00\">Testing</p><img id=\"webkit logo\" src="" alt=\"Face\"><div style=\"border: solid blue; background: white;\" contenteditable=\"true\">div with blue border</div><ul><li>foo<li>bar<li>baz</ul>";
+
+void processCrashReport(const wchar_t* fileName) { ::MessageBox(0, fileName, L"Crash Report", MB_OK); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to