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 12
#include "application/lib/app/application_context.h"
#include "application/services/application_runner.fidl.h"
A
Adam Barth 已提交
13
#include "flutter/content_handler/application_controller_impl.h"
14
#include "flutter/content_handler/content_handler_thread.h"
A
Adam Barth 已提交
15
#include "lib/ftl/macros.h"
16
#include "lib/ftl/synchronization/waitable_event.h"
A
Adam Barth 已提交
17 18 19

namespace flutter_runner {

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

25 26
  static App& Shared();

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

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

  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 46 47 48
  void WaitForPlatformViewsIdsUIThread(
    std::vector<PlatformViewInfo>* platform_view_ids,
    ftl::AutoResetWaitableEvent* latch);

49
  std::unique_ptr<app::ApplicationContext> context_;
50 51
  std::unique_ptr<Thread> gpu_thread_;
  std::unique_ptr<Thread> io_thread_;
52
  fidl::BindingSet<app::ApplicationRunner> runner_bindings_;
A
Adam Barth 已提交
53 54 55 56 57 58 59 60 61 62
  std::unordered_map<ApplicationControllerImpl*,
                     std::unique_ptr<ApplicationControllerImpl>>
      controllers_;

  FTL_DISALLOW_COPY_AND_ASSIGN(App);
};

}  // namespace flutter_runner

#endif  // FLUTTER_CONTENT_HANDLER_APP_H_