Commit 2da65731 authored by gayane's avatar gayane Committed by Commit bot

Show not uploaded crashes for Android.

In order to allow on-demand crash report uploads for Android
users, first show not uploaded or skipped crash reports.

BUG=641628

Review-Url: https://codereview.chromium.org/2301943003
Cr-Commit-Position: refs/heads/master@{#417089}
parent f4d002d1
......@@ -264,6 +264,8 @@ split_static_library("browser") {
"content_settings/web_site_settings_uma_util.h",
"crash_upload_list/crash_upload_list.cc",
"crash_upload_list/crash_upload_list.h",
"crash_upload_list/crash_upload_list_android.cc",
"crash_upload_list/crash_upload_list_android.h",
"custom_handlers/protocol_handler_registry.cc",
"custom_handlers/protocol_handler_registry.h",
"custom_handlers/protocol_handler_registry_factory.cc",
......
......@@ -15,6 +15,10 @@
#include "chrome/browser/crash_upload_list/crash_upload_list_crashpad.h"
#endif
#if defined(OS_ANDROID)
#include "chrome/browser/crash_upload_list/crash_upload_list_android.h"
#endif
scoped_refptr<CrashUploadList> CreateCrashUploadList(
UploadList::Delegate* delegate) {
#if defined(OS_MACOSX) || defined(OS_WIN)
......@@ -25,7 +29,12 @@ scoped_refptr<CrashUploadList> CreateCrashUploadList(
PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dir_path);
base::FilePath upload_log_path =
crash_dir_path.AppendASCII(CrashUploadList::kReporterLogFilename);
#if defined(OS_ANDROID)
return new CrashUploadListAndroid(delegate, upload_log_path,
content::BrowserThread::GetBlockingPool());
#else
return new CrashUploadList(delegate, upload_log_path,
content::BrowserThread::GetBlockingPool());
#endif
#endif // defined(OS_ANDROID)
#endif // defined(OS_MACOSX) || defined(OS_WIN)
}
// Copyright 2016 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/crash_upload_list_android.h"
#include "base/files/file.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
#include "base/threading/sequenced_worker_pool.h"
CrashUploadListAndroid::CrashUploadListAndroid(
Delegate* delegate,
const base::FilePath& upload_log_path,
const scoped_refptr<base::SequencedWorkerPool>& worker_pool)
: CrashUploadList(delegate, upload_log_path, worker_pool) {}
CrashUploadListAndroid::~CrashUploadListAndroid() {}
void CrashUploadListAndroid::LoadUploadList(
std::vector<UploadList::UploadInfo>* uploads) {
// This will load the list of successfully uploaded logs.
CrashUploadList::LoadUploadList(uploads);
LoadUnsuccessfulUploadList(uploads);
}
void CrashUploadListAndroid::LoadUnsuccessfulUploadList(
std::vector<UploadInfo>* uploads) {
const char unsuccessful_uploads[] = ".dmp";
const char skipped_uploads[] = ".skipped";
base::FileEnumerator files(upload_log_path().DirName(), false,
base::FileEnumerator::FILES);
for (base::FilePath file = files.Next(); !file.empty(); file = files.Next()) {
if (file.value().find(unsuccessful_uploads) == std::string::npos &&
file.value().find(skipped_uploads) == std::string::npos)
continue;
base::File::Info info;
if (!base::GetFileInfo(file, &info))
continue;
// Crash reports can have multiple extensions (e.g. foo.dmp, foo.dmp.try1,
// foo.skipped.try0).
file = file.BaseName();
while (file != file.RemoveExtension())
file = file.RemoveExtension();
// ID is the last part of the file name. e.g.
// chromium-renderer-minidump-f297dbcba7a2d0bb.
std::string id = file.value();
std::size_t pos = id.find_last_of("-");
if (pos == std::string::npos)
continue;
id = id.substr(pos + 1);
UploadList::UploadInfo upload(std::string(), base::Time(), id,
info.creation_time,
UploadList::UploadInfo::State::NotUploaded);
uploads->push_back(upload);
}
}
// Copyright 2016 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.
#ifndef CHROME_BROWSER_CRASH_UPLOAD_LIST_CRASH_UPLOAD_LIST_ANDROID_H_
#define CHROME_BROWSER_CRASH_UPLOAD_LIST_CRASH_UPLOAD_LIST_ANDROID_H_
#include "base/macros.h"
#include "components/upload_list/crash_upload_list.h"
namespace base {
class FilePath;
class SequencedWorkerPool;
}
// A CrashUploadList that retrieves the list of uploaded reports from the
// Android crash reporter.
class CrashUploadListAndroid : public CrashUploadList {
public:
CrashUploadListAndroid(
Delegate* delegate,
const base::FilePath& upload_log_path,
const scoped_refptr<base::SequencedWorkerPool>& worker_pool);
protected:
~CrashUploadListAndroid() override;
// Called on a blocking pool thread.
void LoadUploadList(std::vector<UploadInfo>* uploads) override;
private:
void LoadUnsuccessfulUploadList(std::vector<UploadInfo>* uploads);
DISALLOW_COPY_AND_ASSIGN(CrashUploadListAndroid);
};
#endif // CHROME_BROWSER_CRASH_UPLOAD_LIST_CRASH_UPLOAD_LIST_ANDROID_H_
......@@ -78,6 +78,10 @@ void UploadList::LoadUploadList(std::vector<UploadInfo>* uploads) {
}
}
const base::FilePath& UploadList::upload_log_path() const {
return upload_log_path_;
}
void UploadList::ParseLogEntries(
const std::vector<std::string>& log_entries,
std::vector<UploadInfo>* uploads) {
......
......@@ -102,6 +102,8 @@ class UploadList : public base::RefCountedThreadSafe<UploadList> {
// Requests a user triggered upload for a crash report with a given id.
virtual void RequestSingleCrashUpload(const std::string& local_id);
const base::FilePath& upload_log_path() const;
private:
friend class base::RefCountedThreadSafe<UploadList>;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment