Flutter Engine
 
Loading...
Searching...
No Matches
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_FLUTTER_RUNNER_H_
6#define FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_RUNNER_H_
7
8#include <memory>
9#include <unordered_map>
10
11#include <fuchsia/component/runner/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_v2.h"
18#include "flutter/fml/macros.h"
19#include "fml/memory/ref_ptr.h"
20#include "fml/task_runner.h"
21#include "lib/fidl/cpp/binding_set.h"
23
24namespace flutter_runner {
25
26/// Publishes the CF v2 runner service.
27///
28/// Each component will be run on a separate thread dedicated to that component.
29///
30/// TODO(fxb/50694): Add unit tests for CF v2.
31class Runner final
32 : public fuchsia::component::runner::ComponentRunner /* CF v2 */ {
33 public:
34 // Does not take ownership of context.
36 sys::ComponentContext* context);
37
38 ~Runner();
39
40 void handle_unknown_method(uint64_t ordinal,
41 bool method_has_response) override;
42
43 private:
44 // CF v2 lifecycle methods.
45
46 // |fuchsia::component::runner::ComponentRunner|
47 void Start(
48 fuchsia::component::runner::ComponentStartInfo start_info,
49 fidl::InterfaceRequest<fuchsia::component::runner::ComponentController>
50 controller) override;
51
52 /// Registers a new CF v2 component with this runner, binding the component
53 /// to this runner.
54 void RegisterComponentV2(
55 fidl::InterfaceRequest<fuchsia::component::runner::ComponentRunner>
56 request);
57
58 /// Callback that should be fired when a registered CF v2 component is
59 /// terminated.
60 void OnComponentV2Terminate(const ComponentV2* component);
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(RunnerTZDataTest, LoadsWithTZDataPresent);
74 FRIEND_TEST(RunnerTZDataTest, LoadsWithoutTZDataPresent);
75#endif // defined(FRIEND_TEST)
76
78
79 sys::ComponentContext* context_;
80
81 // CF v2 component state.
82
83 /// The components that are currently bound to this runner.
84 fidl::BindingSet<fuchsia::component::runner::ComponentRunner>
85 active_components_v2_bindings_;
86
87 /// The components that are currently actively running on threads.
88 std::unordered_map<const ComponentV2*, ActiveComponentV2>
89 active_components_v2_;
90
91#if !defined(DART_PRODUCT)
92 // The connection between the Dart VM service and The Hub.
93 std::unique_ptr<dart_utils::VMServiceObject> vmservice_object_;
94
95 std::unique_ptr<trace::TraceObserver> trace_observer_;
96 trace_prolonged_context_t* prolonged_context_;
97#endif // !defined(DART_PRODUCT)
98
100};
101
102} // namespace flutter_runner
103
104#endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_RUNNER_H_
void handle_unknown_method(uint64_t ordinal, bool method_has_response) override
Definition runner.cc:346
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27