mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
With the update to HEAD of the Fuchsia buildtools repo, the new clang toolchain picked up caused link-time breakage in android x86_64 libFlutter.so builds. Sample log: https://build.chromium.org/p/client.flutter/builders/Linux%20Engine/builds/1974/steps/build%20android_debug_x64/logs/stdio Sample failure: FAILED: libflutter.so libflutter.so.TOC lib.stripped/libflutter.so ../../third_party/android_tools/ndk/toolchains/x86_64-4.9/prebuilt/linux-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld.gold: error: obj/flutter/shell/platform/android/libflutter/android_context_gl.o: unsupported reloc 42 against global symbol std::__ndk1::num_put<char, std::__ndk1::ostreambuf_iterator<char, std::__ndk1::char_traits<char> > >::id This reverts commit 8ad42f0dae3cb1267c2b9ab99db80e4696ddbc3d.
74 lines
2.3 KiB
C++
74 lines
2.3 KiB
C++
// Copyright 2016 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "flutter/lib/ui/window/platform_message_response_dart.h"
|
|
|
|
#include <utility>
|
|
|
|
#include "flutter/common/threads.h"
|
|
#include "lib/fxl/functional/make_copyable.h"
|
|
#include "lib/tonic/dart_state.h"
|
|
#include "lib/tonic/logging/dart_invoke.h"
|
|
|
|
namespace blink {
|
|
|
|
PlatformMessageResponseDart::PlatformMessageResponseDart(
|
|
tonic::DartPersistentValue callback)
|
|
: callback_(std::move(callback)) {}
|
|
|
|
PlatformMessageResponseDart::~PlatformMessageResponseDart() {
|
|
if (!callback_.is_empty()) {
|
|
Threads::UI()->PostTask(
|
|
fxl::MakeCopyable([callback = std::move(callback_)]() mutable {
|
|
callback.Clear();
|
|
}));
|
|
}
|
|
}
|
|
|
|
void PlatformMessageResponseDart::Complete(std::vector<uint8_t> data) {
|
|
if (callback_.is_empty())
|
|
return;
|
|
FXL_DCHECK(!is_complete_);
|
|
is_complete_ = true;
|
|
Threads::UI()->PostTask(fxl::MakeCopyable(
|
|
[ callback = std::move(callback_), data = std::move(data) ]() mutable {
|
|
tonic::DartState* dart_state = callback.dart_state().get();
|
|
if (!dart_state)
|
|
return;
|
|
tonic::DartState::Scope scope(dart_state);
|
|
|
|
Dart_Handle byte_buffer =
|
|
Dart_NewTypedData(Dart_TypedData_kByteData, data.size());
|
|
DART_CHECK_VALID(byte_buffer);
|
|
|
|
void* buffer;
|
|
intptr_t length;
|
|
Dart_TypedData_Type type;
|
|
DART_CHECK_VALID(
|
|
Dart_TypedDataAcquireData(byte_buffer, &type, &buffer, &length));
|
|
FXL_CHECK(type == Dart_TypedData_kByteData);
|
|
FXL_CHECK(static_cast<size_t>(length) == data.size());
|
|
memcpy(buffer, data.data(), length);
|
|
Dart_TypedDataReleaseData(byte_buffer);
|
|
tonic::DartInvoke(callback.Release(), {byte_buffer});
|
|
}));
|
|
}
|
|
|
|
void PlatformMessageResponseDart::CompleteEmpty() {
|
|
if (callback_.is_empty())
|
|
return;
|
|
FXL_DCHECK(!is_complete_);
|
|
is_complete_ = true;
|
|
Threads::UI()->PostTask(
|
|
fxl::MakeCopyable([callback = std::move(callback_)]() mutable {
|
|
tonic::DartState* dart_state = callback.dart_state().get();
|
|
if (!dart_state)
|
|
return;
|
|
tonic::DartState::Scope scope(dart_state);
|
|
tonic::DartInvoke(callback.Release(), {Dart_Null()});
|
|
}));
|
|
}
|
|
|
|
} // namespace blink
|