Commit c8194d70 authored by Kevin Marshall's avatar Kevin Marshall Committed by Commit Bot

[fuchsia] Adapt to breaking change in ComponentController events.

Fixes SDK breakage by moving from using ComponentController:Wait()
to the OnTerminated event instead.

Roll SDK to 019ae3dbfc4384f2e656f41490d7a735fc117ab4.


Bug: 707030
Change-Id: I2d29299e7454087e388e4f6b499b4803fde8c625
Reviewed-on: https://chromium-review.googlesource.com/1205570
Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Reviewed-by: default avatarKevin Marshall <kmarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#588737}
parent fb27bcf1
c0d648376520e0745f77bc396d6c6209f04ab109
\ No newline at end of file
019ae3dbfc4384f2e656f41490d7a735fc117ab4
cc76fdce4c3d1b61db2e860c38ba6faba7708ad4
\ No newline at end of file
35a0dcb16f7895a22ebfe56b51c91a8ec310fab5
......@@ -41,9 +41,9 @@ ComponentControllerImpl::ComponentControllerImpl(WebContentRunner* runner)
}
ComponentControllerImpl::~ComponentControllerImpl() {
for (WaitCallback& next_callback : termination_wait_callbacks_) {
next_callback(did_terminate_abnormally_ ? 1 : 0);
}
// Send process termination details to the client.
controller_binding_.events().OnTerminated(termination_exit_code_,
termination_reason_);
}
bool ComponentControllerImpl::BindToRequest(
......@@ -62,8 +62,10 @@ bool ComponentControllerImpl::BindToRequest(
if (controller_request.is_valid()) {
controller_binding_.Bind(std::move(controller_request));
controller_binding_.set_error_handler(
fit::bind_member(this, &ComponentControllerImpl::Kill));
controller_binding_.set_error_handler([this] {
// Signal graceful process termination.
RequestTermination(0, fuchsia::sys::TerminationReason::EXITED);
});
}
runner_->context()->CreateFrame(frame_.NewRequest());
......@@ -85,18 +87,14 @@ bool ComponentControllerImpl::BindToRequest(
}
void ComponentControllerImpl::Kill() {
did_terminate_abnormally_ = true;
runner_->DestroyComponent(this);
// Signal abnormal process termination.
RequestTermination(1, fuchsia::sys::TerminationReason::RUNNER_TERMINATED);
}
void ComponentControllerImpl::Detach() {
controller_binding_.set_error_handler(nullptr);
}
void ComponentControllerImpl::Wait(WaitCallback callback) {
termination_wait_callbacks_.push_back(std::move(callback));
}
void ComponentControllerImpl::CreateView(
fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner> view_owner,
fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> services) {
......@@ -107,4 +105,12 @@ void ComponentControllerImpl::CreateView(
view_is_bound_ = true;
}
void ComponentControllerImpl::RequestTermination(
int termination_exit_code,
fuchsia::sys::TerminationReason reason) {
termination_reason_ = reason;
termination_exit_code_ = termination_exit_code;
runner_->DestroyComponent(this);
}
} // namespace webrunner
......@@ -43,7 +43,6 @@ class ComponentControllerImpl : public fuchsia::sys::ComponentController,
// fuchsia::sys::ComponentController implementation.
void Kill() override;
void Detach() override;
void Wait(WaitCallback callback) override;
// fuchsia::ui::viewsv1::ViewProvider implementation.
void CreateView(
......@@ -54,6 +53,11 @@ class ComponentControllerImpl : public fuchsia::sys::ComponentController,
private:
explicit ComponentControllerImpl(WebContentRunner* runner);
// Registers the termination reason for this Component and requests its
// termination from the parent WebContentRunner.
void RequestTermination(int termination_exit_code,
fuchsia::sys::TerminationReason reason);
// Binds |this| to a Runner::StartComponent() call. Returns false on failure
// (e.g. when the URL in |startup_info| is invalid).
bool BindToRequest(fuchsia::sys::Package package,
......@@ -75,9 +79,12 @@ class ComponentControllerImpl : public fuchsia::sys::ComponentController,
base::fuchsia::ScopedServiceBinding<fuchsia::ui::viewsv1::ViewProvider>>
view_provider_binding_;
std::vector<WaitCallback> termination_wait_callbacks_;
// Termination reason and exit-code to be reported via the
// sys::ComponentController::OnTerminated event.
fuchsia::sys::TerminationReason termination_reason_ =
fuchsia::sys::TerminationReason::UNKNOWN;
int termination_exit_code_ = 0;
bool did_terminate_abnormally_ = false;
bool view_is_bound_ = false;
DISALLOW_COPY_AND_ASSIGN(ComponentControllerImpl);
......
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