summaryrefslogtreecommitdiffstats
path: root/chrome/browser/crash_upload_list.cc
diff options
context:
space:
mode:
authorstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-18 21:07:16 +0000
committerstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-18 21:07:16 +0000
commitc8717adf7ca0e0c3d1ef374a29c1d320018e17af (patch)
tree65c1682a67348252d48b2306fb195368b44a1a29 /chrome/browser/crash_upload_list.cc
parent9e70a1857733240eef9cb2ec6afc0e8079d1e9fe (diff)
downloadchromium_src-c8717adf7ca0e0c3d1ef374a29c1d320018e17af.zip
chromium_src-c8717adf7ca0e0c3d1ef374a29c1d320018e17af.tar.gz
chromium_src-c8717adf7ca0e0c3d1ef374a29c1d320018e17af.tar.bz2
Implement chrome://crashes
Creates a new internal page for listing recent reported crashes, to make it easier for users to report crashes, or get crash IDs when asked in bug reports. Won't yet display any crashes on Windows, since the breakpad side is not yet done on Windows. BUG=41106 TEST=Visit chrome://crashes; depending on the build type, platform, and metric pref state, it should display crashes or an informative message. Review URL: http://codereview.chromium.org/6545001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75433 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/crash_upload_list.cc')
-rw-r--r--chrome/browser/crash_upload_list.cc69
1 files changed, 69 insertions, 0 deletions
diff --git a/chrome/browser/crash_upload_list.cc b/chrome/browser/crash_upload_list.cc
new file mode 100644
index 0000000..44ae936
--- /dev/null
+++ b/chrome/browser/crash_upload_list.cc
@@ -0,0 +1,69 @@
+// 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.h"
+
+#include "base/path_service.h"
+#include "base/file_path.h"
+#include "base/file_util.h"
+#include "base/string_number_conversions.h"
+#include "base/string_split.h"
+#include "chrome/browser/browser_thread.h"
+#include "chrome/common/chrome_paths.h"
+
+
+CrashUploadList::CrashInfo::CrashInfo(const std::string& c, const base::Time& t)
+ : crash_id(c), crash_time(t) {}
+
+CrashUploadList::CrashInfo::~CrashInfo() {}
+
+CrashUploadList::CrashUploadList(Delegate* delegate) : delegate_(delegate) {}
+
+CrashUploadList::~CrashUploadList() {}
+
+void CrashUploadList::LoadCrashListAsynchronously() {
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
+ NewRunnableMethod(this, &CrashUploadList::LoadUploadLog));
+}
+
+void CrashUploadList::ClearDelegate() {
+ delegate_ = NULL;
+}
+
+void CrashUploadList::LoadUploadLog() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ FilePath crash_dir_path;
+ PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dir_path);
+ FilePath upload_log_path = crash_dir_path.AppendASCII("uploads.log");
+ if (file_util::PathExists(upload_log_path)) {
+ std::string contents;
+ file_util::ReadFileToString(upload_log_path, &contents);
+ base::SplitStringAlongWhitespace(contents, &log_entries_);
+ }
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &CrashUploadList::InformDelegateOfCompletion));
+}
+
+void CrashUploadList::InformDelegateOfCompletion() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (delegate_)
+ delegate_->OnCrashListAvailable();
+}
+
+void CrashUploadList::GetUploadedCrashes(unsigned int max_count,
+ std::vector<CrashInfo>* crashes) {
+ std::vector<std::string>::reverse_iterator i;
+ for (i = log_entries_.rbegin(); i != log_entries_.rend(); ++i) {
+ std::vector<std::string> components;
+ base::SplitString(*i, ',', &components);
+ // Skip any blank (or corrupted) lines.
+ if (components.size() != 2)
+ continue;
+ double seconds_since_epoch;
+ if (!base::StringToDouble(components[0], &seconds_since_epoch))
+ continue;
+ CrashInfo info(components[1], base::Time::FromDoubleT(seconds_since_epoch));
+ crashes->push_back(info);
+ }
+}