| Flutter Windows Embedder |

task_runner_window.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_WINDOWS_TASK_RUNNER_WINDOW_H_
6 #define FLUTTER_SHELL_PLATFORM_WINDOWS_TASK_RUNNER_WINDOW_H_
7
8 #include <windows.h>
9
10 #include <chrono>
11 #include <memory>
12 #include <string>
13 #include <vector>
14
15 #include "flutter/fml/macros.h"
16
17 namespace flutter {
18
19 // Hidden HWND responsible for processing flutter tasks on main thread
20 class TaskRunnerWindow {
21 public:
22 class Delegate {
23 public:
24 // Executes expired task, and returns the duration until the next task
25 // deadline if exists, otherwise returns `std::chrono::nanoseconds::max()`.
26 //
27 // Each platform implementation must call this to schedule the tasks.
28 virtual std::chrono::nanoseconds ProcessTasks() = 0;
29 };
30
31 static std::shared_ptr<TaskRunnerWindow> GetSharedInstance();
32
33 // Triggers processing delegate tasks on main thread
34 void WakeUp();
35
36 void AddDelegate(Delegate* delegate);
37 void RemoveDelegate(Delegate* delegate);
38
39 void PollOnce(std::chrono::milliseconds timeout);
40
41 ~TaskRunnerWindow();
42
43 private:
44 TaskRunnerWindow();
45
46 void ProcessTasks();
47
48 void SetTimer(std::chrono::nanoseconds when);
49
50 WNDCLASS RegisterWindowClass();
51
52 LRESULT
53 HandleMessage(UINT const message,
54 WPARAM const wparam,
55 LPARAM const lparam) noexcept;
56
57 static LRESULT CALLBACK WndProc(HWND const window,
58 UINT const message,
59 WPARAM const wparam,
60 LPARAM const lparam) noexcept;
61
62 HWND window_handle_;
63 std::wstring window_class_name_;
64 std::vector<Delegate*> delegates_;
65
66 FML_DISALLOW_COPY_AND_ASSIGN(TaskRunnerWindow);
67 };
68 } // namespace flutter
69
70 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_TASK_RUNNER_WINDOW_H_
flutter::TaskRunnerWindow::Delegate
Definition: task_runner_window.h:22
flutter::TaskRunnerWindow::Delegate::ProcessTasks
virtual std::chrono::nanoseconds ProcessTasks()=0
flutter::TaskRunnerWindow
Definition: task_runner_window.h:20
flutter::TaskRunnerWindow::WakeUp
void WakeUp()
Definition: task_runner_window.cc:59
flutter::TaskRunnerWindow::PollOnce
void PollOnce(std::chrono::milliseconds timeout)
Definition: task_runner_window.cc:77
flutter::TaskRunnerWindow::GetSharedInstance
static std::shared_ptr< TaskRunnerWindow > GetSharedInstance()
Definition: task_runner_window.cc:48
flutter::TaskRunnerWindow::AddDelegate
void AddDelegate(Delegate *delegate)
Definition: task_runner_window.cc:65
flutter::TaskRunnerWindow::RemoveDelegate
void RemoveDelegate(Delegate *delegate)
Definition: task_runner_window.cc:70
flutter::TaskRunnerWindow::~TaskRunnerWindow
~TaskRunnerWindow()
Definition: task_runner_window.cc:40
message
Win32Message message
Definition: keyboard_unittests.cc:137
flutter
Definition: accessibility_bridge_windows.cc:11