android: enable upload

This patch also updates WorkerThread to execute DoWork() when
DoWorkNow() has been called, which is relevant when DoWorkNow() and
Stop() have both been called. This occurs regularly on Android where
the handler's current normal mode is to dump a single process and exit.
This change ensures the upload thread has a chance to upload the report
before the handler exits.

This change should not affect upload on Chrome/WebView/Chromecast which
don't pass Crashpad a --url option and are still responsible for their
own uploads.

Change-Id: Ie5553eafc13714f0438b4b133a92516f7abec153
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1643710
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Joshua Peraza 2019-06-18 09:48:52 -07:00 committed by Commit Bot
parent de22b8d050
commit d98690a182
6 changed files with 8 additions and 45 deletions

View File

@ -246,12 +246,6 @@ void CrashReportUploadThread::ProcessPendingReport(
CrashReportUploadThread::UploadResult CrashReportUploadThread::UploadReport(
const CrashReportDatabase::UploadReport* report,
std::string* response_body) {
#if defined(OS_ANDROID)
// TODO(jperaza): This method can be enabled on Android after HTTPTransport is
// implemented and Crashpad takes over upload responsibilty on Android.
NOTREACHED();
return UploadResult::kPermanentFailure;
#else
std::map<std::string, std::string> parameters;
FileReader* reader = report->Reader();
@ -338,7 +332,6 @@ CrashReportUploadThread::UploadResult CrashReportUploadThread::UploadReport(
}
return UploadResult::kSuccess;
#endif // OS_ANDROID
}
void CrashReportUploadThread::DoWork(const WorkerThread* thread) {

View File

@ -269,7 +269,7 @@ static_library("util") {
deps = []
if (crashpad_is_linux || crashpad_is_fuchsia) {
if (crashpad_is_linux || crashpad_is_fuchsia || crashpad_is_android) {
sources += [ "net/http_transport_socket.cc" ]
if (crashpad_use_boringssl_for_http_transport_socket) {
defines = [ "CRASHPAD_USE_BORINGSSL" ]
@ -283,8 +283,6 @@ static_library("util") {
]
}
}
} else if (crashpad_is_android) {
sources += [ "net/http_transport_none.cc" ]
}
if (crashpad_is_linux || crashpad_is_android) {

View File

@ -1,26 +0,0 @@
// Copyright 2017 The Crashpad Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "util/net/http_transport.h"
#include "base/logging.h"
namespace crashpad {
std::unique_ptr<HTTPTransport> HTTPTransport::Create() {
NOTREACHED(); // TODO(scottmg): https://crashpad.chromium.org/bug/196
return std::unique_ptr<HTTPTransport>();
}
} // namespace crashpad

View File

@ -33,8 +33,9 @@ class WorkerThreadImpl final : public Thread {
if (initial_work_delay_ > 0)
semaphore_.TimedWait(initial_work_delay_);
while (self_->running_) {
while (self_->running_ || self_->do_work_now_) {
self_->delegate_->DoWork(self_);
self_->do_work_now_ = false;
semaphore_.TimedWait(self_->work_interval_);
}
}
@ -57,7 +58,8 @@ WorkerThread::WorkerThread(double work_interval,
: work_interval_(work_interval),
delegate_(delegate),
impl_(),
running_(false) {}
running_(false),
do_work_now_(false) {}
WorkerThread::~WorkerThread() {
DCHECK(!running_);
@ -88,6 +90,7 @@ void WorkerThread::Stop() {
void WorkerThread::DoWorkNow() {
DCHECK(running_);
do_work_now_ = true;
impl_->SignalSemaphore();
}

View File

@ -92,6 +92,7 @@ class WorkerThread {
Delegate* delegate_; // weak
std::unique_ptr<internal::WorkerThreadImpl> impl_;
bool running_;
bool do_work_now_;
DISALLOW_COPY_AND_ASSIGN(WorkerThread);
};

View File

@ -184,7 +184,6 @@
'net/http_transport.cc',
'net/http_transport.h',
'net/http_transport_mac.mm',
'net/http_transport_none.cc',
'net/http_transport_win.cc',
'net/url.cc',
'net/url.h',
@ -393,7 +392,7 @@
'win/safe_terminate_process.asm',
],
}],
['OS=="linux"', {
['OS=="linux" or OS=="android"', {
'sources': [
'net/http_transport_socket.cc',
],
@ -402,11 +401,6 @@
'misc/capture_context_linux.S',
],
}],
['OS!="android"', {
'sources!': [
'net/http_transport_none.cc',
],
}],
['OS!="linux" and OS!="android"', {
'sources/': [
['exclude', '^process/'],