2016-11-07 15:51:42 -08:00
|
|
|
// 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 FLUTTER_CONTENT_HANDLER_APPLICATION_IMPL_H_
|
|
|
|
|
#define FLUTTER_CONTENT_HANDLER_APPLICATION_IMPL_H_
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
2017-09-14 22:49:46 -07:00
|
|
|
#include <fdio/namespace.h>
|
2017-09-01 13:17:20 -07:00
|
|
|
|
2017-09-11 14:40:03 -07:00
|
|
|
#include "lib/app/fidl/application_controller.fidl.h"
|
|
|
|
|
#include "lib/app/fidl/application_runner.fidl.h"
|
|
|
|
|
#include "lib/app/fidl/service_provider.fidl.h"
|
2016-11-07 15:51:42 -08:00
|
|
|
#include "lib/fidl/cpp/bindings/binding.h"
|
|
|
|
|
#include "lib/fidl/cpp/bindings/binding_set.h"
|
2017-09-11 15:58:48 -07:00
|
|
|
#include "lib/fxl/macros.h"
|
|
|
|
|
#include "lib/fxl/synchronization/waitable_event.h"
|
2017-09-12 15:36:20 -07:00
|
|
|
#include "lib/svc/cpp/service_provider_bridge.h"
|
|
|
|
|
#include "lib/ui/views/fidl/view_provider.fidl.h"
|
2017-10-19 01:20:38 -07:00
|
|
|
#include "third_party/dart/runtime/include/dart_api.h"
|
2016-11-07 15:51:42 -08:00
|
|
|
|
|
|
|
|
namespace flutter_runner {
|
|
|
|
|
class App;
|
|
|
|
|
class RuntimeHolder;
|
|
|
|
|
|
2017-02-13 14:28:14 -08:00
|
|
|
class ApplicationControllerImpl : public app::ApplicationController,
|
2016-11-07 15:51:42 -08:00
|
|
|
public mozart::ViewProvider {
|
|
|
|
|
public:
|
|
|
|
|
ApplicationControllerImpl(
|
|
|
|
|
App* app,
|
2017-02-13 14:28:14 -08:00
|
|
|
app::ApplicationPackagePtr application,
|
|
|
|
|
app::ApplicationStartupInfoPtr startup_info,
|
|
|
|
|
fidl::InterfaceRequest<app::ApplicationController> controller);
|
2016-11-07 15:51:42 -08:00
|
|
|
|
|
|
|
|
~ApplicationControllerImpl() override;
|
|
|
|
|
|
2017-02-13 14:28:14 -08:00
|
|
|
// |app::ApplicationController| implementation
|
2016-11-07 15:51:42 -08:00
|
|
|
|
2017-02-21 11:03:35 -08:00
|
|
|
void Kill() override;
|
2016-11-07 15:51:42 -08:00
|
|
|
void Detach() override;
|
2017-09-05 12:21:41 -07:00
|
|
|
void Wait(const WaitCallback& callback) override;
|
2016-11-07 15:51:42 -08:00
|
|
|
|
|
|
|
|
// |mozart::ViewProvider| implementation
|
|
|
|
|
|
|
|
|
|
void CreateView(
|
|
|
|
|
fidl::InterfaceRequest<mozart::ViewOwner> view_owner_request,
|
2017-02-13 14:28:14 -08:00
|
|
|
fidl::InterfaceRequest<app::ServiceProvider> services) override;
|
2016-11-07 15:51:42 -08:00
|
|
|
|
2017-03-13 14:46:14 -07:00
|
|
|
Dart_Port GetUIIsolateMainPort();
|
|
|
|
|
std::string GetUIIsolateName();
|
|
|
|
|
|
2016-11-07 15:51:42 -08:00
|
|
|
private:
|
|
|
|
|
void StartRuntimeIfReady();
|
2017-09-05 12:21:41 -07:00
|
|
|
void SendReturnCode(int32_t return_code);
|
2016-11-07 15:51:42 -08:00
|
|
|
|
2017-09-14 22:49:46 -07:00
|
|
|
fdio_ns_t* SetupNamespace(const app::FlatNamespacePtr& flat);
|
2017-09-01 13:17:20 -07:00
|
|
|
|
2016-11-07 15:51:42 -08:00
|
|
|
App* app_;
|
2017-02-13 14:28:14 -08:00
|
|
|
fidl::Binding<app::ApplicationController> binding_;
|
2016-11-07 15:51:42 -08:00
|
|
|
|
2017-06-06 16:05:00 -07:00
|
|
|
app::ServiceProviderBridge service_provider_bridge_;
|
2016-11-10 13:12:32 -08:00
|
|
|
|
2016-11-07 15:51:42 -08:00
|
|
|
fidl::BindingSet<mozart::ViewProvider> view_provider_bindings_;
|
|
|
|
|
|
|
|
|
|
std::string url_;
|
|
|
|
|
std::unique_ptr<RuntimeHolder> runtime_holder_;
|
|
|
|
|
|
2017-09-05 12:21:41 -07:00
|
|
|
std::vector<WaitCallback> wait_callbacks_;
|
|
|
|
|
|
2017-09-11 15:58:48 -07:00
|
|
|
FXL_DISALLOW_COPY_AND_ASSIGN(ApplicationControllerImpl);
|
2016-11-07 15:51:42 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace flutter_runner
|
|
|
|
|
|
|
|
|
|
#endif // FLUTTER_CONTENT_HANDLER_APPLICATION_IMPL_H_
|