win: Writes uploads.log

This commit is contained in:
Cheng Zhao 2014-11-11 16:38:16 +08:00
parent 02bcdc1c19
commit 9a825c5cbd
2 changed files with 28 additions and 1 deletions

View file

@ -13,6 +13,8 @@
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
#include "base/win/windows_version.h"
#include "vendor/breakpad/src/client/windows/crash_generation/client_info.h"
#include "vendor/breakpad/src/client/windows/crash_generation/crash_generation_server.h"
@ -66,6 +68,30 @@ bool WriteCustomInfoToFile(const std::wstring& dump_path, const CrashMap& map) {
return true;
}
bool WriteReportIDToFile(const std::wstring& dump_path,
const std::wstring& report_id) {
std::wstring file_path(dump_path);
size_t last_slash = file_path.rfind(L'\\');
if (last_slash == std::wstring::npos)
return false;
file_path.resize(last_slash);
file_path += L"\\uploads.log";
std::wofstream file(file_path.c_str(),
std::ios_base::out | std::ios_base::app | std::ios::binary);
if (!file.is_open())
return false;
int64 seconds_since_epoch =
(base::Time::Now() - base::Time::UnixEpoch()).InSeconds();
std::wstring line = base::Int64ToString16(seconds_since_epoch);
line += L',';
line += report_id;
line += L'\n';
file.write(line.c_str(), static_cast<std::streamsize>(line.length()));
return true;
}
// The window procedure task is to handle when a) the user logs off.
// b) the system shuts down or c) when the user closes the window.
LRESULT __stdcall CrashSvcWndProc(HWND hwnd, UINT message,
@ -422,6 +448,7 @@ DWORD CrashService::AsyncSendDump(void* context) {
++info->self->requests_sent_;
++info->self->requests_handled_;
retry_round = 0;
WriteReportIDToFile(info->dump_path, report_id);
break;
case google_breakpad::RESULT_THROTTLED:
report_id = L"<throttled>";

View file

@ -32,7 +32,7 @@ describe 'crash-reporter module', ->
assert.equal fields['_version'], require('remote').require('app').getVersion()
assert files['upload_file_minidump']['name']?
res.end()
res.end('abc-123-def')
server.close()
done()
server.listen 0, '127.0.0.1', ->