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

Unified Diff: chrome/browser/crash_upload_list.cc

Issue 6771021: Implement CrashUploadListWin to enable chrome://crashes on Windows. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Addressing MAD's latest comments. 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
« no previous file with comments | « chrome/browser/crash_upload_list.h ('k') | chrome/browser/crash_upload_list_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/crash_upload_list.cc
diff --git a/chrome/browser/crash_upload_list.cc b/chrome/browser/crash_upload_list.cc
index d10980f6a94c1f7994398596b1ca47969f6eb843..fa0e8ab7964ecb886abe8316db79e0490b618d5c 100644
--- a/chrome/browser/crash_upload_list.cc
+++ b/chrome/browser/crash_upload_list.cc
@@ -9,6 +9,9 @@
#include "base/file_util.h"
#include "base/string_number_conversions.h"
#include "base/string_split.h"
+#if defined(OS_WIN)
+#include "chrome/browser/crash_upload_list_win.h"
+#endif
#include "chrome/common/chrome_paths.h"
#include "content/browser/browser_thread.h"
@@ -17,20 +20,37 @@ CrashUploadList::CrashInfo::CrashInfo(const std::string& c, const base::Time& t)
CrashUploadList::CrashInfo::~CrashInfo() {}
+// static
+CrashUploadList* CrashUploadList::Create(Delegate* delegate) {
+#if defined(OS_WIN)
+ return new CrashUploadListWin(delegate);
+#else
+ return new CrashUploadList(delegate);
+#endif
+}
+
CrashUploadList::CrashUploadList(Delegate* delegate) : delegate_(delegate) {}
CrashUploadList::~CrashUploadList() {}
void CrashUploadList::LoadCrashListAsynchronously() {
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(this, &CrashUploadList::LoadUploadLog));
+ NewRunnableMethod(this,
+ &CrashUploadList::LoadCrashListAndInformDelegateOfCompletion));
}
void CrashUploadList::ClearDelegate() {
delegate_ = NULL;
}
-void CrashUploadList::LoadUploadLog() {
+
+void CrashUploadList::LoadCrashListAndInformDelegateOfCompletion() {
+ LoadCrashList();
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &CrashUploadList::InformDelegateOfCompletion));
+}
+
+void CrashUploadList::LoadCrashList() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
FilePath crash_dir_path;
PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dir_path);
@@ -38,22 +58,16 @@ void CrashUploadList::LoadUploadLog() {
if (file_util::PathExists(upload_log_path)) {
std::string contents;
file_util::ReadFileToString(upload_log_path, &contents);
- base::SplitStringAlongWhitespace(contents, &log_entries_);
+ std::vector<std::string> log_entries;
+ base::SplitStringAlongWhitespace(contents, &log_entries);
+ ParseLogEntries(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) {
+void CrashUploadList::ParseLogEntries(
+ const std::vector<std::string>& log_entries) {
+ std::vector<std::string>::const_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.
@@ -63,6 +77,23 @@ void CrashUploadList::GetUploadedCrashes(unsigned int max_count,
if (!base::StringToDouble(components[0], &seconds_since_epoch))
continue;
CrashInfo info(components[1], base::Time::FromDoubleT(seconds_since_epoch));
- crashes->push_back(info);
+ crashes_.push_back(info);
}
}
+
+void CrashUploadList::InformDelegateOfCompletion() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (delegate_)
+ delegate_->OnCrashListAvailable();
+}
+
+void CrashUploadList::GetUploadedCrashes(unsigned int max_count,
+ std::vector<CrashInfo>* crashes) {
+ std::copy(crashes_.begin(),
+ crashes_.begin() + std::min<size_t>(crashes_.size(), max_count),
+ std::back_inserter(*crashes));
+}
+
+std::vector<CrashUploadList::CrashInfo>& CrashUploadList::crashes() {
+ return crashes_;
+}
« no previous file with comments | « chrome/browser/crash_upload_list.h ('k') | chrome/browser/crash_upload_list_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698