mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Teach //flutter/glue to build on Fuchsia (#2898)
This commit is contained in:
parent
a413ef0bb0
commit
4a972e2d52
@ -6,14 +6,9 @@ source_set("glue") {
|
||||
sources = [
|
||||
"data_pipe_utils.cc",
|
||||
"data_pipe_utils.h",
|
||||
"drain_data_pipe_job.cc",
|
||||
"drain_data_pipe_job.h",
|
||||
"movable_wrapper.h",
|
||||
"stack_trace.cc",
|
||||
"stack_trace.h",
|
||||
"task_runner_adaptor.cc",
|
||||
"task_runner_adaptor.h",
|
||||
"thread.cc",
|
||||
"thread.h",
|
||||
"trace_event.h",
|
||||
]
|
||||
@ -24,7 +19,25 @@ source_set("glue") {
|
||||
"//mojo/public/cpp/system",
|
||||
]
|
||||
|
||||
if (!is_fuchsia) {
|
||||
if (is_fuchsia) {
|
||||
sources += [
|
||||
"drain_data_pipe_job_fuchsia.cc",
|
||||
"stack_trace_fuchsia.cc",
|
||||
"thread_fuchsia.cc",
|
||||
]
|
||||
|
||||
deps += [
|
||||
"//lib/mtl",
|
||||
]
|
||||
} else {
|
||||
sources += [
|
||||
"drain_data_pipe_job_base.cc",
|
||||
"stack_trace_base.cc",
|
||||
"task_runner_adaptor.cc",
|
||||
"task_runner_adaptor.h",
|
||||
"thread_base.cc",
|
||||
]
|
||||
|
||||
deps += [
|
||||
"//base",
|
||||
"//mojo/data_pipe_utils",
|
||||
|
||||
@ -29,7 +29,7 @@ class DrainDataPipeJob::JobImpl : public DataPipeDrainer::Client {
|
||||
|
||||
std::vector<char> buffer_;
|
||||
ResultCallback callback_;
|
||||
mojo::common::DataPipeDrainer drainer_;
|
||||
DataPipeDrainer drainer_;
|
||||
|
||||
FTL_DISALLOW_COPY_AND_ASSIGN(JobImpl);
|
||||
};
|
||||
43
glue/drain_data_pipe_job_fuchsia.cc
Normal file
43
glue/drain_data_pipe_job_fuchsia.cc
Normal file
@ -0,0 +1,43 @@
|
||||
// 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/glue/drain_data_pipe_job.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "lib/mtl/data_pipe/data_pipe_drainer.h"
|
||||
|
||||
using mtl::DataPipeDrainer;
|
||||
|
||||
namespace glue {
|
||||
|
||||
class DrainDataPipeJob::JobImpl : public DataPipeDrainer::Client {
|
||||
public:
|
||||
explicit JobImpl(mojo::ScopedDataPipeConsumerHandle handle,
|
||||
const ResultCallback& callback)
|
||||
: callback_(callback), drainer_(this, std::move(handle)) {}
|
||||
|
||||
private:
|
||||
// mojo::common::DataPipeDrainer::Client
|
||||
void OnDataAvailable(const void* data, size_t num_bytes) override {
|
||||
const char* bytes = static_cast<const char*>(data);
|
||||
buffer_.insert(buffer_.end(), bytes, bytes + num_bytes);
|
||||
}
|
||||
|
||||
void OnDataComplete() override { callback_(std::move(buffer_)); }
|
||||
|
||||
std::vector<char> buffer_;
|
||||
ResultCallback callback_;
|
||||
DataPipeDrainer drainer_;
|
||||
|
||||
FTL_DISALLOW_COPY_AND_ASSIGN(JobImpl);
|
||||
};
|
||||
|
||||
DrainDataPipeJob::DrainDataPipeJob(mojo::ScopedDataPipeConsumerHandle handle,
|
||||
const ResultCallback& callback)
|
||||
: impl_(new JobImpl(std::move(handle), callback)) {}
|
||||
|
||||
DrainDataPipeJob::~DrainDataPipeJob() {}
|
||||
|
||||
} // namespace glue
|
||||
11
glue/stack_trace_fuchsia.cc
Normal file
11
glue/stack_trace_fuchsia.cc
Normal file
@ -0,0 +1,11 @@
|
||||
// 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/glue/stack_trace.h"
|
||||
|
||||
namespace glue {
|
||||
|
||||
void PrintStackTrace() {}
|
||||
|
||||
} // namespace glue
|
||||
27
glue/thread_fuchsia.cc
Normal file
27
glue/thread_fuchsia.cc
Normal file
@ -0,0 +1,27 @@
|
||||
// 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/glue/thread.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "lib/mtl/threading/create_thread.h"
|
||||
|
||||
namespace glue {
|
||||
|
||||
class Thread::ThreadImpl {
|
||||
public:
|
||||
std::thread thread_;
|
||||
};
|
||||
|
||||
Thread::Thread(std::string name) : impl_(new ThreadImpl()) {}
|
||||
|
||||
Thread::~Thread() {}
|
||||
|
||||
bool Thread::Start() {
|
||||
impl_->thread_ = mtl::CreateThread(&task_runner_);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace glue
|
||||
Loading…
x
Reference in New Issue
Block a user