Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1128)

Unified Diff: chrome/browser/crash_upload_list_win.cc

Issue 6771021: Implement CrashUploadListWin to enable chrome://crashes on Windows. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix max_count logic. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/crash_upload_list_win.cc
diff --git a/chrome/browser/crash_upload_list_win.cc b/chrome/browser/crash_upload_list_win.cc
new file mode 100755
index 0000000000000000000000000000000000000000..693d13de71f3b610a3f2ebf4cfe6e3c6c7e6ae46
--- /dev/null
+++ b/chrome/browser/crash_upload_list_win.cc
@@ -0,0 +1,67 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/crash_upload_list_win.h"
+
+#include "base/stringprintf.h"
+#include "base/string_util.h"
+#include "base/sys_string_conversions.h"
+
+CrashUploadListWin::CrashUploadListWin(Delegate* delegate)
+ : CrashUploadList(delegate) {}
+
+void CrashUploadListWin::LoadUploadLog() {
+ std::vector<uint8> buffer(1024);
+ HANDLE eventLog = OpenEventLog(NULL, L"Application");
+ if (eventLog) {
+ while (true) {
+ DWORD bytesRead;
+ DWORD bytesNeeded;
+ BOOL success =
+ ReadEventLog(eventLog,
+ EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ,
+ 0,
+ &buffer[0],
+ buffer.size(),
+ &bytesRead,
+ &bytesNeeded);
+ if (success) {
+ DWORD recordOffset = 0;
+ while (recordOffset < bytesRead) {
+ uint8* recordPtr = &buffer[recordOffset];
+ EVENTLOGRECORD* record = (EVENTLOGRECORD*)recordPtr;
+ LPWSTR providerName = (LPWSTR)(recordPtr + sizeof(EVENTLOGRECORD));
+ // Check whether the record has the expected values of an Omaha
+ // crash report for Chrome.
+ if (!wcscmp(L"Chrome", providerName) &&
+ record->EventType == EVENTLOG_INFORMATION_TYPE &&
+ record->NumStrings >= 1) {
+ std::string messageString =
+ base::SysWideToUTF8((LPWSTR)(recordPtr + record->StringOffset));
+ // Only handle entries matching the expected message pattern.
+ // NOTE: If the pattern is changed, make sure to change the substr()
+ // parameters below.
+ if (MatchPattern(messageString, "Crash uploaded. Id=*.")) {
+ std::string crashId =
+ messageString.substr(19, crashId.length() - 20);
stuartmorgan 2011/03/29 21:19:57 Can you turn the prefix into a static string, and
Alexei Svitkine (slow) 2011/03/30 15:36:40 Done. The resulting code is unfortunately uglier,
+ log_entries().push_back(base::StringPrintf("%d,%s",
+ record->TimeGenerated,
+ crashId.c_str()));
stuartmorgan 2011/03/29 21:19:57 It's odd that the subclass is serializing the cras
Alexei Svitkine (slow) 2011/03/30 15:36:40 Good point. I've refactored the code to have the b
+ }
+ }
+ recordOffset += record->Length;
+ }
+ } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+ // Resize buffer to the required minimum size.
+ buffer.resize(bytesNeeded);
+ } else {
+ // Stop on any other error, including the expected case
+ // of ERROR_HANDLE_EOF.
+ break;
+ }
+ }
+ CloseEventLog(eventLog);
+ }
+ InformDelegateOfCompletionAsynchronously();
+}

Powered by Google App Engine
This is Rietveld 408576698