Flutter Engine
runner.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_RUNNER_H_
6 #define FLUTTER_SHELL_PLATFORM_FUCHSIA_RUNNER_H_
7 
8 #include <memory>
9 #include <unordered_map>
10 
11 #include <fuchsia/sys/cpp/fidl.h>
12 #include <lib/async-loop/cpp/loop.h>
13 #include <lib/sys/cpp/component_context.h>
14 #include <lib/trace-engine/instrumentation.h>
15 #include <lib/trace/observer.h>
16 
17 #include "component.h"
18 #include "flutter/fml/macros.h"
19 #include "lib/fidl/cpp/binding_set.h"
21 
22 namespace flutter_runner {
23 
24 // Publishes the |fuchsia::sys::Runner| service and runs applications on
25 // their own threads.
26 class Runner final : public fuchsia::sys::Runner {
27  public:
28  // Does not take ownership of loop or context.
29  Runner(async::Loop* loop, sys::ComponentContext* context);
30 
31  ~Runner();
32 
33  private:
34  async::Loop* loop_;
35 
36  sys::ComponentContext* context_;
37  fidl::BindingSet<fuchsia::sys::Runner> active_applications_bindings_;
38  std::unordered_map<const Application*, ActiveApplication>
39  active_applications_;
40 
41 #if !defined(DART_PRODUCT)
42  // The connection between the Dart VM service and The Hub.
43  std::unique_ptr<dart_utils::VMServiceObject> vmservice_object_;
44 
45  std::unique_ptr<trace::TraceObserver> trace_observer_;
46  trace_prolonged_context_t* prolonged_context_;
47 #endif // !defined(DART_PRODUCT)
48 
49  // |fuchsia::sys::Runner|
50  void StartComponent(fuchsia::sys::Package package,
51  fuchsia::sys::StartupInfo startup_info,
52  fidl::InterfaceRequest<fuchsia::sys::ComponentController>
53  controller) override;
54 
55  void RegisterApplication(
56  fidl::InterfaceRequest<fuchsia::sys::Runner> request);
57 
58  void UnregisterApplication(const Application* application);
59 
60  void OnApplicationTerminate(const Application* application);
61 
62  void SetupICU();
63 
64 #if !defined(DART_PRODUCT)
65  void SetupTraceObserver();
66 #endif // !defined(DART_PRODUCT)
67 
68  // Called from SetupICU, for testing only. Returns false on error.
69  static bool SetupICUInternal();
70  // Called from SetupICU, for testing only. Returns false on error.
71  static bool SetupTZDataInternal();
72 #if defined(FRIEND_TEST)
73  FRIEND_TEST(RunnerTest, TZData);
74  FRIEND_TEST(RunnerTZDataTest, LoadsWithoutTZDataPresent);
75 #endif // defined(FRIEND_TEST)
76 
77  FML_DISALLOW_COPY_AND_ASSIGN(Runner);
78 };
79 
80 } // namespace flutter_runner
81 
82 #endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_RUNNER_H_
Runner(async::Loop *loop, sys::ComponentContext *context)
Definition: runner.cc:149