Flutter Engine
The Flutter Engine
platform_message_response_android.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/android/platform_message_response_android.h"
6
7#include <utility>
8
9#include "flutter/fml/make_copyable.h"
10#include "flutter/shell/platform/android/jni/platform_view_android_jni.h"
11
12namespace flutter {
13
14PlatformMessageResponseAndroid::PlatformMessageResponseAndroid(
15 int response_id,
16 std::shared_ptr<PlatformViewAndroidJNI> jni_facade,
17 fml::RefPtr<fml::TaskRunner> platform_task_runner)
18 : response_id_(response_id),
19 jni_facade_(std::move(jni_facade)),
20 platform_task_runner_(std::move(platform_task_runner)) {}
21
22PlatformMessageResponseAndroid::~PlatformMessageResponseAndroid() = default;
23
24// |flutter::PlatformMessageResponse|
25void PlatformMessageResponseAndroid::Complete(
26 std::unique_ptr<fml::Mapping> data) {
27 platform_task_runner_->PostTask(
28 fml::MakeCopyable([response_id = response_id_, //
29 data = std::move(data), //
30 jni_facade = jni_facade_]() mutable {
31 jni_facade->FlutterViewHandlePlatformMessageResponse(response_id,
32 std::move(data));
33 }));
34}
35
36// |flutter::PlatformMessageResponse|
37void PlatformMessageResponseAndroid::CompleteEmpty() {
38 platform_task_runner_->PostTask(
39 fml::MakeCopyable([response_id = response_id_, //
40 jni_facade = jni_facade_ //
41 ]() {
42 // Make the response call into Java.
43 jni_facade->FlutterViewHandlePlatformMessageResponse(response_id,
44 nullptr);
45 }));
46}
47} // namespace flutter
internal::CopyableLambda< T > MakeCopyable(T lambda)
Definition: make_copyable.h:57
Definition: ref_ptr.h:256
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63