Changeset 156911 in webkit


Ignore:
Timestamp:
Oct 4, 2013 1:37:53 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Alex Christensen <achristensen@webkit.org> 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.

Location:
trunk/Tools
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r156899 r156911  
     12013-10-04  Alex Christensen  <achristensen@webkit.org>
     2
     3        Made WinLauncher have better error handling, crash reporting, and modifiability.
     4        https://bugs.webkit.org/show_bug.cgi?id=122319
     5
     6        Reviewed by Brent Fulgham.
     7
     8        * WinLauncher/WinLauncher.cpp:
     9        (WinLauncherWebHost::didFailProvisionalLoadWithError):
     10        Don't display the numerous "Cancelled" messages that are obviously from the user.
     11        (createCrashReport): Added.
     12        (dllLauncherEntryPoint):
     13        Made main loop back into while loop and write a crash report if it crashes.
     14        * WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj:
     15        * WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj.filters:
     16        Added WinLauncherReplace.h.
     17        * WinLauncher/WinLauncher.vcxproj/WinLauncherLibCommon.props:
     18        Added linking to DbgHelp.lib.
     19        * WinLauncher/WinLauncherReplace.h:
     20        Added to make modifying WinLauncher behaviour and appearance easy.
     21        (processCrashDump): Added.
     22
    1232013-10-04  Dirk Pranke  <dpranke@chromium.org>
    224
  • trunk/Tools/WinLauncher/WinLauncher.cpp

    r156662 r156911  
    3434#include "PrintWebUIDelegate.h"
    3535#include "WinLauncherLibResource.h"
     36#include "WinLauncherReplace.h"
    3637#include <WebKit/WebKitCOMAPI.h>
    3738#include <wtf/ExportMacros.h>
     
    4849#include <commdlg.h>
    4950#include <comutil.h>
     51#include <dbghelp.h>
    5052#include <functional>
    5153#include <objbase.h>
    5254#include <shellapi.h>
     55#include <shlobj.h>
    5356#include <shlwapi.h>
    5457#include <string>
     
    181184        errorDescription = L"Failed to load page and to localize error description.";
    182185
    183     ::MessageBoxW(0, static_cast<LPCWSTR>(errorDescription), L"Error", MB_APPLMODAL | MB_OK);
     186    if (_wcsicmp(errorDescription, L"Cancelled"))
     187        ::MessageBoxW(0, static_cast<LPCWSTR>(errorDescription), L"Error", MB_APPLMODAL | MB_OK);
    184188
    185189    return S_OK;
     
    409413}
    410414
    411 
    412 #if USE(CF)
    413 extern "C" void _CFRunLoopSetWindowsMessageQueueMask(CFRunLoopRef, uint32_t, CFStringRef);
     415void createCrashReport(EXCEPTION_POINTERS* exceptionPointers)
     416{
     417    wchar_t appDataDirectory[MAX_PATH];
     418    if (FAILED(SHGetFolderPathW(0, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, 0, 0, appDataDirectory)))
     419        return;
     420
     421    std::wstring directory = std::wstring(appDataDirectory) + L"\\WinLauncher";
     422    if (::SHCreateDirectoryEx(0, directory.c_str(), 0) != ERROR_SUCCESS
     423        && ::GetLastError() != ERROR_FILE_EXISTS
     424        && ::GetLastError() != ERROR_ALREADY_EXISTS)
     425        return;
     426
     427    std::wstring fileName = directory + L"\\CrashReport.dmp";
     428    HANDLE miniDumpFile = ::CreateFile(fileName.c_str(), GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
     429
     430    if (miniDumpFile && miniDumpFile != INVALID_HANDLE_VALUE) {
     431
     432        MINIDUMP_EXCEPTION_INFORMATION mdei;
     433        mdei.ThreadId = ::GetCurrentThreadId();
     434        mdei.ExceptionPointers  = exceptionPointers;
     435        mdei.ClientPointers = 0;
     436
     437#ifdef _DEBUG
     438        MINIDUMP_TYPE dumpType = MiniDumpWithFullMemory;
     439#else
     440        MINIDUMP_TYPE dumpType = MiniDumpNormal;
    414441#endif
     442
     443        ::MiniDumpWriteDump(::GetCurrentProcess(), ::GetCurrentProcessId(), miniDumpFile, dumpType, &mdei, 0, 0);
     444        ::CloseHandle(miniDumpFile);
     445        processCrashReport(fileName.c_str());
     446    }
     447}
    415448
    416449extern "C" __declspec(dllexport) int WINAPI dllLauncherEntryPoint(HINSTANCE, HINSTANCE, LPTSTR, int nCmdShow)
     
    540573            goto exit;
    541574
    542         _bstr_t defaultHTML(L"<p style=\"background-color: #00FF00\">Testing</p><img id=\"webkit logo\" src=\"http://webkit.org/images/icon-gold.png\" alt=\"Face\"><div style=\"border: solid blue; background: white;\" contenteditable=\"true\">div with blue border</div><ul><li>foo<li>bar<li>baz</ul>");
    543         frame->loadHTMLString(defaultHTML.GetBSTR(), 0);
     575        frame->loadHTMLString(_bstr_t(defaultHTML).GetBSTR(), 0);
    544576    }
    545577
     
    569601        loadURL(requestedURL.GetBSTR());
    570602
     603#pragma warning(disable:4509)
     604
    571605    // Main message loop:
     606    __try {
     607        while (GetMessage(&msg, 0, 0, 0)) {
    572608#if USE(CF)
    573     _CFRunLoopSetWindowsMessageQueueMask(CFRunLoopGetMain(), QS_ALLINPUT | QS_ALLPOSTMESSAGE, kCFRunLoopDefaultMode);
    574     CFRunLoopRun();
    575 #else
    576     while (GetMessage(&msg, NULL, 0, 0)) {
    577         if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {
    578             TranslateMessage(&msg);
    579             DispatchMessage(&msg);
     609            CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true);
     610#endif
     611            if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {
     612                TranslateMessage(&msg);
     613                DispatchMessage(&msg);
     614            }
    580615        }
    581     }
    582 #endif
     616    } __except(createCrashReport(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER) { }
    583617
    584618exit:
  • trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj

    r152921 r156911  
    207207    <ClInclude Include="..\stdafx.h" />
    208208    <ClInclude Include="..\WinLauncher.h" />
     209    <ClInclude Include="..\WinLauncherReplace.h" />
    209210    <ClInclude Include="WinLauncherLibResource.h" />
    210211  </ItemGroup>
  • trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj.filters

    r152174 r156911  
    5858      <Filter>Header Files</Filter>
    5959    </ClInclude>
     60    <ClInclude Include="..\WinLauncherReplace.h">
     61      <Filter>Header Files</Filter>
     62    </ClInclude>
    6063  </ItemGroup>
    6164  <ItemGroup>
  • trunk/Tools/WinLauncher/WinLauncher.vcxproj/WinLauncherLibCommon.props

    r155922 r156911  
    1111    </ClCompile>
    1212    <Link>
    13       <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>
     13      <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>
    1414    </Link>
    1515  </ItemDefinitionGroup>
Note: See TracChangeset for help on using the changeset viewer.