Flutter Engine
The Flutter Engine
embedder_platform_message_response.cc
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#include "flutter/shell/platform/embedder/embedder_platform_message_response.h"
6
7#include "flutter/fml/make_copyable.h"
8
9namespace flutter {
10
13 const Callback& callback)
14 : runner_(std::move(runner)), callback_(callback) {}
15
17
18// |PlatformMessageResponse|
19void EmbedderPlatformMessageResponse::Complete(
20 std::unique_ptr<fml::Mapping> data) {
21 if (!data) {
22 CompleteEmpty();
23 return;
24 }
25
26 runner_->PostTask(
27 // The static leak checker gets confused by the use of fml::MakeCopyable.
28 // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
29 fml::MakeCopyable([data = std::move(data), callback = callback_]() {
30 callback(data->GetMapping(), data->GetSize());
31 }));
32}
33
34// |PlatformMessageResponse|
35void EmbedderPlatformMessageResponse::CompleteEmpty() {
36 Complete(std::make_unique<fml::NonOwnedMapping>(nullptr, 0u));
37}
38
39} // namespace flutter
~EmbedderPlatformMessageResponse() override
Destroys the message response. Can be called on any thread. Does not execute unfulfilled callbacks.
std::function< void(const uint8_t *data, size_t size)> Callback
EmbedderPlatformMessageResponse(fml::RefPtr< fml::TaskRunner > runner, const Callback &callback)
virtual void PostTask(const fml::closure &task) override
Definition: task_runner.cc:24
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition: switches.h:41
internal::CopyableLambda< T > MakeCopyable(T lambda)
Definition: make_copyable.h:57
Definition: ref_ptr.h:256