| 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 ~TaskRunnerWindow();
40
41 private:
42 TaskRunnerWindow();
43
44 void ProcessTasks();
45
46 void SetTimer(std::chrono::nanoseconds when);
47
48 WNDCLASS RegisterWindowClass();
49
50 LRESULT
51 HandleMessage(UINT const message,
52 WPARAM const wparam,
53 LPARAM const lparam) noexcept;
54
55 static LRESULT CALLBACK WndProc(HWND const window,
56 UINT const message,
57 WPARAM const wparam,
58 LPARAM const lparam) noexcept;
59
60 HWND window_handle_;
61 std::wstring window_class_name_;
62 std::vector<Delegate*> delegates_;
63
64 FML_DISALLOW_COPY_AND_ASSIGN(TaskRunnerWindow);
65 };
66 } // namespace flutter
67
68 #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:54
flutter::TaskRunnerWindow::GetSharedInstance
static std::shared_ptr< TaskRunnerWindow > GetSharedInstance()
Definition: task_runner_window.cc:43
flutter::TaskRunnerWindow::AddDelegate
void AddDelegate(Delegate *delegate)
Definition: task_runner_window.cc:60
flutter::TaskRunnerWindow::RemoveDelegate
void RemoveDelegate(Delegate *delegate)
Definition: task_runner_window.cc:65
flutter::TaskRunnerWindow::~TaskRunnerWindow
~TaskRunnerWindow()
Definition: task_runner_window.cc:35
message
Win32Message message
Definition: keyboard_unittests.cc:137
flutter
Definition: accessibility_bridge_windows.cc:11