app.h 1.8 KB
Newer Older
A
Adam Barth 已提交
1 2 3 4 5 6 7 8 9 10
// 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_APP_H_
#define FLUTTER_CONTENT_HANDLER_APP_H_

#include <memory>
#include <unordered_set>

11
#include "flutter/content_handler/application_controller_impl.h"
12
#include "lib/app/cpp/application_context.h"
13
#include <fuchsia/cpp/component.h>
14
#include "lib/fsl/threading/thread.h"
15 16
#include "lib/fxl/macros.h"
#include "lib/fxl/synchronization/waitable_event.h"
A
Adam Barth 已提交
17 18 19

namespace flutter_runner {

20
class App : public component::ApplicationRunner {
A
Adam Barth 已提交
21 22 23 24
 public:
  App();
  ~App();

25 26
  static App& Shared();

27
  // |component::ApplicationRunner| implementation:
A
Adam Barth 已提交
28

29
  void StartApplication(
30 31 32
      component::ApplicationPackage application,
      component::ApplicationStartupInfo startup_info,
      fidl::InterfaceRequest<component::ApplicationController> controller) override;
A
Adam Barth 已提交
33 34 35

  void Destroy(ApplicationControllerImpl* controller);

36 37 38 39 40 41 42 43
  struct PlatformViewInfo {
    uintptr_t view_id;
    int64_t isolate_id;
    std::string isolate_name;
  };

  void WaitForPlatformViewIds(std::vector<PlatformViewInfo>* platform_view_ids);

A
Adam Barth 已提交
44
 private:
45
  void WaitForPlatformViewsIdsUIThread(
46
      std::vector<PlatformViewInfo>* platform_view_ids,
47
      fxl::AutoResetWaitableEvent* latch);
48
  void UpdateProcessLabel();
49

50
  std::unique_ptr<component::ApplicationContext> context_;
G
George Kulakowski 已提交
51 52
  std::unique_ptr<fsl::Thread> gpu_thread_;
  std::unique_ptr<fsl::Thread> io_thread_;
53
  fidl::BindingSet<component::ApplicationRunner> runner_bindings_;
A
Adam Barth 已提交
54 55 56
  std::unordered_map<ApplicationControllerImpl*,
                     std::unique_ptr<ApplicationControllerImpl>>
      controllers_;
57
  std::string base_label_;
A
Adam Barth 已提交
58

59
  FXL_DISALLOW_COPY_AND_ASSIGN(App);
A
Adam Barth 已提交
60 61 62 63 64
};

}  // namespace flutter_runner

#endif  // FLUTTER_CONTENT_HANDLER_APP_H_