|
@@ -10,52 +10,80 @@ exit codes in some crashing scenarios. To mitigate this, we can rely on
|
|
|
ServiceProcessHost::Observer functions, but we need to pass the exit code to
|
|
|
the observer.
|
|
|
|
|
|
-diff --git a/content/browser/service_process_host_impl.cc b/content/browser/service_process_host_impl.cc
|
|
|
-index f6082bada22c5f4e70af60ea6f555b0f363919c5..f691676a629bf82f81117599ae0bd0a4870c9f61 100644
|
|
|
---- a/content/browser/service_process_host_impl.cc
|
|
|
-+++ b/content/browser/service_process_host_impl.cc
|
|
|
-@@ -73,12 +73,15 @@ class ServiceProcessTracker {
|
|
|
- processes_.erase(iter);
|
|
|
- }
|
|
|
+diff --git a/content/browser/service_host/service_process_tracker.cc b/content/browser/service_host/service_process_tracker.cc
|
|
|
+index 594629e45acd6cac9deba2d02c682a523c80e2fb..61be7804bbf370df3d2925880804866a631d35fa 100644
|
|
|
+--- a/content/browser/service_host/service_process_tracker.cc
|
|
|
++++ b/content/browser/service_host/service_process_tracker.cc
|
|
|
+@@ -48,12 +48,14 @@ void ServiceProcessTracker::NotifyTerminated(ServiceProcessId id) {
|
|
|
+ processes_.erase(iter);
|
|
|
+ }
|
|
|
|
|
|
-- void NotifyCrashed(ServiceProcessId id) {
|
|
|
-+ void NotifyCrashed(ServiceProcessId id, int exit_code) {
|
|
|
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
|
|
- auto iter = processes_.find(id);
|
|
|
- CHECK(iter != processes_.end(), base::NotFatalUntil::M130);
|
|
|
-- for (auto& observer : observers_)
|
|
|
-- observer.OnServiceProcessCrashed(iter->second.Duplicate());
|
|
|
-+ for (auto& observer : observers_) {
|
|
|
-+ auto params = iter->second.Duplicate();
|
|
|
-+ params.set_exit_code(exit_code);
|
|
|
-+ observer.OnServiceProcessCrashed(params);
|
|
|
-+ }
|
|
|
- processes_.erase(iter);
|
|
|
+-void ServiceProcessTracker::NotifyCrashed(ServiceProcessId id) {
|
|
|
++void ServiceProcessTracker::NotifyCrashed(ServiceProcessId id, int exit_code) {
|
|
|
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
|
|
+ auto iter = processes_.find(id);
|
|
|
+ CHECK(iter != processes_.end(), base::NotFatalUntil::M130);
|
|
|
+ for (auto& observer : observers_) {
|
|
|
+- observer.OnServiceProcessCrashed(iter->second.Duplicate());
|
|
|
++ auto params = iter->second.Duplicate();
|
|
|
++ params.set_exit_code(exit_code);
|
|
|
++ observer.OnServiceProcessCrashed(params);
|
|
|
}
|
|
|
+ processes_.erase(iter);
|
|
|
+ }
|
|
|
+diff --git a/content/browser/service_host/service_process_tracker.h b/content/browser/service_host/service_process_tracker.h
|
|
|
+index 8e2b330f59c714db9dac3363df566b6e396fa4ec..47b0b3a944dec09a229fe771813118bbe49b8e28 100644
|
|
|
+--- a/content/browser/service_host/service_process_tracker.h
|
|
|
++++ b/content/browser/service_host/service_process_tracker.h
|
|
|
+@@ -34,7 +34,7 @@ class ServiceProcessTracker {
|
|
|
|
|
|
-@@ -154,7 +157,7 @@ class UtilityProcessClient : public UtilityProcessHost::Client {
|
|
|
- process_info_->service_process_id());
|
|
|
- }
|
|
|
+ void NotifyTerminated(ServiceProcessId id);
|
|
|
+
|
|
|
+- void NotifyCrashed(ServiceProcessId id);
|
|
|
++ void NotifyCrashed(ServiceProcessId id, int exit_code);
|
|
|
|
|
|
-- void OnProcessCrashed() override {
|
|
|
-+ void OnProcessCrashed(int exit_code) override {
|
|
|
- // TODO(crbug.com/40654042): It is unclear how we can observe
|
|
|
- // |OnProcessCrashed()| without observing |OnProcessLaunched()| first, but
|
|
|
- // it can happen on Android. Ignore the notification in this case.
|
|
|
-@@ -162,7 +165,7 @@ class UtilityProcessClient : public UtilityProcessHost::Client {
|
|
|
- return;
|
|
|
+ void AddObserver(ServiceProcessHost::Observer* observer);
|
|
|
|
|
|
- GetServiceProcessTracker().NotifyCrashed(
|
|
|
-- process_info_->service_process_id());
|
|
|
-+ process_info_->service_process_id(), exit_code);
|
|
|
+diff --git a/content/browser/service_host/utility_process_client.cc b/content/browser/service_host/utility_process_client.cc
|
|
|
+index 530d877ab671296ddd6dfd29a528018b3db1ad6f..a64c11f8838b9dc4704a57c96bd9aa8b98bce212 100644
|
|
|
+--- a/content/browser/service_host/utility_process_client.cc
|
|
|
++++ b/content/browser/service_host/utility_process_client.cc
|
|
|
+@@ -40,7 +40,7 @@ void UtilityProcessClient::OnProcessTerminatedNormally() {
|
|
|
+ process_info_->service_process_id());
|
|
|
+ }
|
|
|
+
|
|
|
+-void UtilityProcessClient::OnProcessCrashed() {
|
|
|
++void UtilityProcessClient::OnProcessCrashed(int exit_code) {
|
|
|
+ // TODO(crbug.com/40654042): It is unclear how we can observe
|
|
|
+ // |OnProcessCrashed()| without observing |OnProcessLaunched()| first, but
|
|
|
+ // it can happen on Android. Ignore the notification in this case.
|
|
|
+@@ -48,6 +48,7 @@ void UtilityProcessClient::OnProcessCrashed() {
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
+- GetServiceProcessTracker().NotifyCrashed(process_info_->service_process_id());
|
|
|
++ GetServiceProcessTracker().NotifyCrashed(
|
|
|
++ process_info_->service_process_id(), exit_code);
|
|
|
+ }
|
|
|
+ } // namespace content
|
|
|
+diff --git a/content/browser/service_host/utility_process_client.h b/content/browser/service_host/utility_process_client.h
|
|
|
+index 801db538979ba62facdcf3a472dade56723ca639..7abac9a5b13b393713534ae51664c2e5da3a4c29 100644
|
|
|
+--- a/content/browser/service_host/utility_process_client.h
|
|
|
++++ b/content/browser/service_host/utility_process_client.h
|
|
|
+@@ -36,7 +36,7 @@ class UtilityProcessClient : public UtilityProcessHost::Client {
|
|
|
+
|
|
|
+ void OnProcessTerminatedNormally() override;
|
|
|
+
|
|
|
+- void OnProcessCrashed() override;
|
|
|
++ void OnProcessCrashed(int exit_code) override;
|
|
|
+
|
|
|
private:
|
|
|
-diff --git a/content/browser/utility_process_host.cc b/content/browser/utility_process_host.cc
|
|
|
-index 59319bf14d79c27ef48a37e7463dfb868e412e23..ff6f3ea26f0ccb741cd292bc417a47719de86487 100644
|
|
|
---- a/content/browser/utility_process_host.cc
|
|
|
-+++ b/content/browser/utility_process_host.cc
|
|
|
-@@ -532,7 +532,7 @@ void UtilityProcessHost::OnProcessCrashed(int exit_code) {
|
|
|
+ const std::string service_interface_name_;
|
|
|
+diff --git a/content/browser/service_host/utility_process_host.cc b/content/browser/service_host/utility_process_host.cc
|
|
|
+index b7dfacb25a09b105e982c013119271b8f137e7b9..8c351bb09e5110a2c6692acc37e7187c43eec8ff 100644
|
|
|
+--- a/content/browser/service_host/utility_process_host.cc
|
|
|
++++ b/content/browser/service_host/utility_process_host.cc
|
|
|
+@@ -539,7 +539,7 @@ void UtilityProcessHost::OnProcessCrashed(int exit_code) {
|
|
|
// Take ownership of |client_| so the destructor doesn't notify it of
|
|
|
// termination.
|
|
|
auto client = std::move(client_);
|
|
@@ -64,10 +92,10 @@ index 59319bf14d79c27ef48a37e7463dfb868e412e23..ff6f3ea26f0ccb741cd292bc417a4771
|
|
|
}
|
|
|
|
|
|
std::optional<std::string> UtilityProcessHost::GetServiceName() {
|
|
|
-diff --git a/content/browser/utility_process_host.h b/content/browser/utility_process_host.h
|
|
|
-index 66cbabae31236758eef35bab211d4874f8a5c699..88515741fa08176ba9e952759c3a52e1ae2104d1 100644
|
|
|
---- a/content/browser/utility_process_host.h
|
|
|
-+++ b/content/browser/utility_process_host.h
|
|
|
+diff --git a/content/browser/service_host/utility_process_host.h b/content/browser/service_host/utility_process_host.h
|
|
|
+index ab6b64737245a840a3e2b06d2ab501ef4aaed7a2..9cf85b5fc97cf797965642d9bae5b3b0abf56e80 100644
|
|
|
+--- a/content/browser/service_host/utility_process_host.h
|
|
|
++++ b/content/browser/service_host/utility_process_host.h
|
|
|
@@ -79,7 +79,7 @@ class CONTENT_EXPORT UtilityProcessHost
|
|
|
|
|
|
virtual void OnProcessLaunched(const base::Process& process) {}
|