Teach //flutter/glue to build on Fuchsia (#2898)

This commit is contained in:
Adam Barth 2016-08-10 12:50:00 -07:00 committed by GitHub
parent a413ef0bb0
commit 4a972e2d52
7 changed files with 101 additions and 7 deletions

View File

@ -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",

View File

@ -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);
};

View 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

View 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
View 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