]> khamidou — GitHub mirrors - electron.git/commitdiff
win: Writes uploads.log
authorCheng Zhao <zcbenz@gmail.com>
Tue, 11 Nov 2014 08:38:16 +0000 (16:38 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 11 Nov 2014 08:38:16 +0000 (16:38 +0800)
atom/common/crash_reporter/win/crash_service.cc
spec/api-crash-reporter-spec.coffee

index 5cb6f98351389dd1013f4ce7d24d7fd2659c114f..ee77eb07f668e78a3ebb74c2ddf3df24938cca75 100644 (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>";
index 2dd1499edb7d7681570e5e871f6aebe6a22f820d..43f7b2f035084c51c2d1205cb2d3d91606051318 100644 (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', ->