提交 79332e5c 编写于 作者: I Ian McKellar 提交者: GitHub

Support the ApplicationController::Wait interface. (#4061)

This only operates correctly when the application is killed using the
Kill() method. Flutter applications on Fuchsia currently don't have any
way to shut themselves down, see:
https://github.com/flutter/flutter/issues/11934
上级 0765df75
......@@ -104,6 +104,7 @@ mxio_ns_t* ApplicationControllerImpl::SetupNamespace(
}
void ApplicationControllerImpl::Kill() {
SendReturnCode(runtime_holder_->return_code());
runtime_holder_.reset();
app_->Destroy(this);
// |this| has been deleted at this point.
......@@ -113,6 +114,17 @@ void ApplicationControllerImpl::Detach() {
binding_.set_connection_error_handler(ftl::Closure());
}
void ApplicationControllerImpl::Wait(const WaitCallback& callback) {
wait_callbacks_.push_back(callback);
}
void ApplicationControllerImpl::SendReturnCode(int32_t return_code) {
for (const auto& iter : wait_callbacks_) {
iter(return_code);
}
wait_callbacks_.clear();
}
void ApplicationControllerImpl::CreateView(
fidl::InterfaceRequest<mozart::ViewOwner> view_owner_request,
fidl::InterfaceRequest<app::ServiceProvider> services) {
......
......@@ -39,6 +39,7 @@ class ApplicationControllerImpl : public app::ApplicationController,
void Kill() override;
void Detach() override;
void Wait(const WaitCallback& callback) override;
// |mozart::ViewProvider| implementation
......@@ -51,6 +52,7 @@ class ApplicationControllerImpl : public app::ApplicationController,
private:
void StartRuntimeIfReady();
void SendReturnCode(int32_t return_code);
mxio_ns_t* SetupNamespace(const app::FlatNamespacePtr& flat);
......@@ -64,6 +66,8 @@ class ApplicationControllerImpl : public app::ApplicationController,
std::string url_;
std::unique_ptr<RuntimeHolder> runtime_holder_;
std::vector<WaitCallback> wait_callbacks_;
FTL_DISALLOW_COPY_AND_ASSIGN(ApplicationControllerImpl);
};
......
......@@ -267,6 +267,9 @@ void RuntimeHolder::CreateView(
runtime_->dart_controller()->RunFromScriptSnapshot(snapshot.data(),
snapshot.size());
}
runtime_->dart_controller()->dart_state()->SetReturnCodeCallback(
[this](int32_t return_code) { return_code_ = return_code; });
}
Dart_Port RuntimeHolder::GetUIIsolateMainPort() {
......
......@@ -51,6 +51,8 @@ class RuntimeHolder : public blink::RuntimeDelegate,
Dart_Port GetUIIsolateMainPort();
std::string GetUIIsolateName();
int32_t return_code() { return return_code_; }
private:
// |blink::RuntimeDelegate| implementation:
std::string DefaultRouteName() override;
......@@ -117,6 +119,7 @@ class RuntimeHolder : public blink::RuntimeDelegate,
bool frame_outstanding_ = false;
bool frame_scheduled_ = false;
bool frame_rendering_ = false;
int32_t return_code_ = 0;
ftl::WeakPtrFactory<RuntimeHolder> weak_factory_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册