Revert "[garnet] Reland "Remove MakeCopyable dependencies""
This reverts commit 91ad810ecba010b25eda2e38e868a0f7ddead853.
Reason for revert: CQ didn't re-run tests after merge (due to new conflicts). Merged prematurely.
Original change's description:
> [garnet] Reland "Remove MakeCopyable dependencies"
>
> This reverts commit 077444b5ce477a01a0d268f82e0a0cb123b2c20b.
>
> Reason for revert: relanding (revert revert) after resolving build error with merge of https://fuchsia-review.googlesource.com/c/peridot/+/245012
>
> Original change's description:
> > Revert "[garnet] Remove MakeCopyable dependencies"
> >
> > This reverts commit e5dee7e7d47a9d28092ad00c45f50192af4b18a5.
> >
> > Reason for revert: this CL breaks peridot (fxl::Closure no longer has
> > the same semantics), which prevents garnet from rolling.
> >
> > Original change's description:
> > > [garnet] Remove MakeCopyable dependencies
> > >
> > > [Confirmed this compiles under both x64 and arm64]
> > >
> > > This change replaces many std::function references with
> > > the new fit::function, allowing functions to be passed with
> > > move-only semantics, which is more efficient than "copy",
> > > and safer than pass-by-reference. It also allows lambdas to
> > > include move-only objects without requiring the MakeCopyable
> > > workaround.
> > >
> > > Note that this covers all of garnet (except for eventually
> > > removing MakeCopyable itself). Changes are forthcoming in
> > > topaz and peridot.
> > >
> > > Issue: ZX-3289
> > > Test: No behavior change
> > > Change-Id: I3fbc402e37652f0dac807441b00ba935cf403a93
> >
> > TBR=abarth@google.com,richkadel@google.com
> >
> > Change-Id: Idce39513309f4dd84d2abfbb63891b74030ee43f
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Issue: ZX-3289
>
> TBR=kulakowski@google.com,vardhan@google.com,abarth@google.com,richkadel@google.com
>
> Change-Id: Ia310a86b059ee1789ce6950ab19e7344b378c34e
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Issue: ZX-3289
TBR=kulakowski@google.com,vardhan@google.com,abarth@google.com,richkadel@google.com
Change-Id: I7a223180650e11c0942af35573437402124fa624
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Issue: ZX-3289
diff --git a/bin/appmgr/realm.cc b/bin/appmgr/realm.cc
index 2d66598..b284dfa 100644
--- a/bin/appmgr/realm.cc
+++ b/bin/appmgr/realm.cc
@@ -34,6 +34,7 @@
#include "lib/fsl/vmo/strings.h"
#include "lib/fxl/files/directory.h"
#include "lib/fxl/files/file.h"
+#include "lib/fxl/functional/make_copyable.h"
#include "lib/fxl/strings/concatenate.h"
#include "lib/fxl/strings/string_printf.h"
#include "lib/fxl/strings/substitute.h"
@@ -407,35 +408,37 @@
return;
}
- loader_->LoadUrl(canon_url, [this, callback = std::move(callback)](
- fuchsia::sys::PackagePtr package) mutable {
- zx::vmo binary;
- fidl::InterfaceHandle<fuchsia::ldsvc::Loader> loader;
- if (!package) {
- callback(ZX_ERR_NOT_FOUND, std::move(binary), std::move(loader));
- return;
- }
- if (!package->data) {
- callback(ZX_ERR_NOT_FOUND, std::move(binary), std::move(loader));
- return;
- }
- binary.swap(package->data->vmo);
+ loader_->LoadUrl(
+ canon_url,
+ fxl::MakeCopyable([this, callback = std::move(callback)](
+ fuchsia::sys::PackagePtr package) mutable {
+ zx::vmo binary;
+ fidl::InterfaceHandle<fuchsia::ldsvc::Loader> loader;
+ if (!package) {
+ callback(ZX_ERR_NOT_FOUND, std::move(binary), std::move(loader));
+ return;
+ }
+ if (!package->data) {
+ callback(ZX_ERR_NOT_FOUND, std::move(binary), std::move(loader));
+ return;
+ }
+ binary.swap(package->data->vmo);
- if (!package->directory) {
- callback(ZX_ERR_NOT_FOUND, std::move(binary), std::move(loader));
- return;
- }
- fxl::UniqueFD dirfd =
- fsl::OpenChannelAsFileDescriptor(std::move(package->directory));
+ if (!package->directory) {
+ callback(ZX_ERR_NOT_FOUND, std::move(binary), std::move(loader));
+ return;
+ }
+ fxl::UniqueFD dirfd =
+ fsl::OpenChannelAsFileDescriptor(std::move(package->directory));
- zx::channel chan;
- if (DynamicLibraryLoader::Start(std::move(dirfd), &chan) != ZX_OK) {
- callback(ZX_ERR_INTERNAL, std::move(binary), std::move(loader));
- return;
- }
- loader.set_channel(std::move(chan));
- callback(ZX_OK, std::move(binary), std::move(loader));
- });
+ zx::channel chan;
+ if (DynamicLibraryLoader::Start(std::move(dirfd), &chan) != ZX_OK) {
+ callback(ZX_ERR_INTERNAL, std::move(binary), std::move(loader));
+ return;
+ }
+ loader.set_channel(std::move(chan));
+ callback(ZX_OK, std::move(binary), std::move(loader));
+ }));
}
void Realm::CreateComponent(
@@ -481,19 +484,21 @@
// launch_info is moved before LoadUrl() gets at its first argument.
fidl::StringPtr url = launch_info.url;
- loader_->LoadUrl(url, [this, launch_info = std::move(launch_info),
+ loader_->LoadUrl(
+ url,
+ fxl::MakeCopyable([this, launch_info = std::move(launch_info),
component_request = std::move(component_request),
callback = std::move(callback)](
fuchsia::sys::PackagePtr package) mutable {
- if (package && package->directory) {
- CreateComponentFromPackage(std::move(package), std::move(launch_info),
- std::move(component_request),
- std::move(callback));
- } else {
- component_request.SetReturnValues(kComponentCreationFailed,
- TerminationReason::PACKAGE_NOT_FOUND);
- }
- });
+ if (package && package->directory) {
+ CreateComponentFromPackage(
+ std::move(package), std::move(launch_info),
+ std::move(component_request), std::move(callback));
+ } else {
+ component_request.SetReturnValues(
+ kComponentCreationFailed, TerminationReason::PACKAGE_NOT_FOUND);
+ }
+ }));
} else {
// Component from scheme that maps to a runner.
CreateComponentWithRunnerForScheme(launcher_type, std::move(launch_info),
diff --git a/bin/appmgr/runner_holder.cc b/bin/appmgr/runner_holder.cc
index 4a7c417..d762b5f 100644
--- a/bin/appmgr/runner_holder.cc
+++ b/bin/appmgr/runner_holder.cc
@@ -7,9 +7,8 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include <utility>
-#include <lib/fit/function.h>
+#include <utility>
#include "garnet/bin/appmgr/component_controller_impl.h"
#include "garnet/bin/appmgr/realm.h"
@@ -23,11 +22,11 @@
RunnerHolder::RunnerHolder(Services services,
fuchsia::sys::ComponentControllerPtr controller,
fuchsia::sys::LaunchInfo launch_info, Realm* realm,
- fit::function<void()> error_handler)
+ std::function<void()> error_handler)
: services_(std::move(services)),
controller_(std::move(controller)),
impl_object_(nullptr),
- error_handler_(std::move(error_handler)),
+ error_handler_(error_handler),
component_id_counter_(0) {
realm->CreateComponent(std::move(launch_info), controller_.NewRequest(),
[this](ComponentControllerImpl* component) {
diff --git a/bin/appmgr/runner_holder.h b/bin/appmgr/runner_holder.h
index 9441fb3..c8cd556 100644
--- a/bin/appmgr/runner_holder.h
+++ b/bin/appmgr/runner_holder.h
@@ -5,7 +5,6 @@
#ifndef GARNET_BIN_APPMGR_RUNNER_HOLDER_H_
#define GARNET_BIN_APPMGR_RUNNER_HOLDER_H_
-#include <lib/fit/function.h>
#include <lib/zx/vmo.h>
#include <fuchsia/sys/cpp/fidl.h>
@@ -26,7 +25,7 @@
RunnerHolder(Services services,
fuchsia::sys::ComponentControllerPtr controller,
fuchsia::sys::LaunchInfo launch_info, Realm* realm,
- fit::function<void()> error_handler = nullptr);
+ std::function<void()> error_handler = nullptr);
~RunnerHolder();
void StartComponent(
@@ -46,7 +45,7 @@
fuchsia::sys::ComponentControllerPtr controller_;
fuchsia::sys::RunnerPtr runner_;
ComponentControllerImpl* impl_object_;
- fit::function<void()> error_handler_;
+ std::function<void()> error_handler_;
std::unordered_map<ComponentBridge*, std::unique_ptr<ComponentBridge>>
components_;
uint64_t component_id_counter_;
diff --git a/bin/cobalt/app/cobalt_controller_impl.cc b/bin/cobalt/app/cobalt_controller_impl.cc
index 0d35fa7..48b7c6d 100644
--- a/bin/cobalt/app/cobalt_controller_impl.cc
+++ b/bin/cobalt/app/cobalt_controller_impl.cc
@@ -8,6 +8,8 @@
#include <mutex>
#include <vector>
+#include "lib/fxl/functional/make_copyable.h"
+
namespace cobalt {
using encoder::ShippingManager;
diff --git a/bin/guest/manager/environment_controller_impl.cc b/bin/guest/manager/environment_controller_impl.cc
index 966b2f0..aad49e8 100644
--- a/bin/guest/manager/environment_controller_impl.cc
+++ b/bin/guest/manager/environment_controller_impl.cc
@@ -4,7 +4,6 @@
#include "garnet/bin/guest/manager/environment_controller_impl.h"
-#include <lib/fit/function.h>
#include <lib/fxl/logging.h>
#include "garnet/bin/guest/manager/guest_services.h"
@@ -29,7 +28,7 @@
}
void EnvironmentControllerImpl::set_unbound_handler(
- fit::function<void()> handler) {
+ std::function<void()> handler) {
bindings_.set_empty_set_handler(std::move(handler));
}
@@ -49,8 +48,7 @@
info.arguments = std::move(launch_info.args);
info.directory_request = services.NewRequest();
info.flat_namespace = std::move(launch_info.flat_namespace);
- std::string label =
- launch_info.label ? launch_info.label.get() : launch_info.url;
+ std::string label = launch_info.label ? launch_info.label.get() : launch_info.url;
auto guest_services = std::make_unique<GuestServices>(std::move(launch_info));
info.additional_services = guest_services->ServeDirectory();
launcher_->CreateComponent(std::move(info),
diff --git a/bin/guest/manager/environment_controller_impl.h b/bin/guest/manager/environment_controller_impl.h
index f96174c..ebac225 100644
--- a/bin/guest/manager/environment_controller_impl.h
+++ b/bin/guest/manager/environment_controller_impl.h
@@ -11,7 +11,6 @@
#include <fuchsia/sys/cpp/fidl.h>
#include <lib/component/cpp/startup_context.h>
#include <lib/fidl/cpp/binding_set.h>
-#include <lib/fit/function.h>
#include "garnet/bin/guest/manager/guest_component.h"
#include "garnet/bin/guest/manager/host_vsock_endpoint.h"
@@ -35,7 +34,7 @@
const std::string& label() const { return label_; }
// Invoked once all bindings have been removed and this environment has been
// orphaned.
- void set_unbound_handler(fit::function<void()> handler);
+ void set_unbound_handler(std::function<void()> handler);
void AddBinding(fidl::InterfaceRequest<EnvironmentController> request);
fidl::VectorPtr<fuchsia::guest::InstanceInfo> ListGuests();
diff --git a/bin/http/http_url_loader_impl.cc b/bin/http/http_url_loader_impl.cc
index 5f96235..9338720 100644
--- a/bin/http/http_url_loader_impl.cc
+++ b/bin/http/http_url_loader_impl.cc
@@ -13,6 +13,7 @@
#include "garnet/bin/http/http_adapters.h"
#include "garnet/bin/http/http_client.h"
#include "garnet/bin/http/http_errors.h"
+#include "lib/fxl/functional/make_copyable.h"
#include "lib/fxl/logging.h"
#include "lib/url/gurl.h"
@@ -31,11 +32,11 @@
void URLLoaderImpl::Start(oldhttp::URLRequest request, Callback callback) {
callback_ = std::move(callback);
- coordinator_->RequestNetworkSlot(
+ coordinator_->RequestNetworkSlot(fxl::MakeCopyable(
[this, request = std::move(request)](fit::closure on_inactive) mutable {
StartInternal(std::move(request));
on_inactive();
- });
+ }));
}
void URLLoaderImpl::FollowRedirect(Callback callback) {
@@ -60,8 +61,7 @@
SendResponse(std::move(response));
}
-void URLLoaderImpl::FollowRedirectInternal() { /* TODO(toshik) */
-}
+void URLLoaderImpl::FollowRedirectInternal() { /* TODO(toshik) */ }
void URLLoaderImpl::SendResponse(oldhttp::URLResponse response) {
Callback callback;
diff --git a/bin/mdns/service/mdns_service_impl.cc b/bin/mdns/service/mdns_service_impl.cc
index 8194ab3..3fb98cb 100644
--- a/bin/mdns/service/mdns_service_impl.cc
+++ b/bin/mdns/service/mdns_service_impl.cc
@@ -11,6 +11,7 @@
#include "garnet/bin/mdns/service/mdns_names.h"
#include "lib/component/cpp/startup_context.h"
#include "lib/fsl/types/type_converters.h"
+#include "lib/fxl/functional/make_copyable.h"
#include "lib/fxl/logging.h"
#include "lib/fxl/type_converter.h"
@@ -53,9 +54,8 @@
if (host_name == kUnsetHostName) {
// Host name not set. Try again soon.
- async::PostDelayedTask(
- async_get_default_dispatcher(), [this]() { Start(); },
- kReadyPollingInterval);
+ async::PostDelayedTask(async_get_default_dispatcher(),
+ [this]() { Start(); }, kReadyPollingInterval);
return;
}
@@ -65,14 +65,15 @@
// Publish this device as "_fuchsia._udp.".
// TODO(dalesat): Make this a config item or delegate to another party.
- PublishServiceInstance(
- kPublishAs, host_name, kPublishPort, fidl::VectorPtr<std::string>(),
- [this](fuchsia::mdns::MdnsResult result) {
- if (result != fuchsia::mdns::MdnsResult::OK) {
- FXL_LOG(ERROR) << "Failed to publish as " << kPublishAs << ", result "
- << static_cast<uint32_t>(result);
- }
- });
+ PublishServiceInstance(kPublishAs, host_name, kPublishPort,
+ fidl::VectorPtr<std::string>(),
+ [this](fuchsia::mdns::MdnsResult result) {
+ if (result != fuchsia::mdns::MdnsResult::OK) {
+ FXL_LOG(ERROR) << "Failed to publish as "
+ << kPublishAs << ", result "
+ << static_cast<uint32_t>(result);
+ }
+ });
}
void MdnsServiceImpl::ResolveHostName(std::string host_name,
@@ -351,10 +352,10 @@
FXL_DCHECK(responder_);
responder_->GetPublication(
query, subtype,
- [callback = std::move(callback)](
- fuchsia::mdns::MdnsPublicationPtr publication_ptr) {
+ fxl::MakeCopyable([callback = std::move(callback)](
+ fuchsia::mdns::MdnsPublicationPtr publication_ptr) {
callback(MdnsFidlUtil::Convert(publication_ptr));
- });
+ }));
}
} // namespace mdns
diff --git a/bin/media/codecs/sw/omx/codec_runner_sw_omx/local_codec_factory.h b/bin/media/codecs/sw/omx/codec_runner_sw_omx/local_codec_factory.h
index ce2b6a7..1576dca 100644
--- a/bin/media/codecs/sw/omx/codec_runner_sw_omx/local_codec_factory.h
+++ b/bin/media/codecs/sw/omx/codec_runner_sw_omx/local_codec_factory.h
@@ -10,7 +10,6 @@
#include <functional>
#include <fuchsia/mediacodec/cpp/fidl.h>
-#include <lib/fit/function.h>
#include "lib/fidl/cpp/binding.h"
@@ -46,7 +45,7 @@
class LocalCodecFactory : public fuchsia::mediacodec::CodecFactory {
public:
- using BindAudioDecoderCallback = fit::function<void(
+ using BindAudioDecoderCallback = std::function<void(
fidl::InterfaceRequest<fuchsia::mediacodec::Codec>,
fuchsia::mediacodec::CreateDecoder_Params audio_params)>;
@@ -93,7 +92,7 @@
fuchsia::mediacodec::CodecType codec_type;
std::string_view mime_type;
std::string_view lib_filename;
- fit::function<std::unique_ptr<codec_runner::CodecRunner>(
+ std::function<std::unique_ptr<codec_runner::CodecRunner>(
async_dispatcher_t* dispatcher, thrd_t fidl_thread,
const CodecStrategy& codec_strategy)>
create_runner;
diff --git a/bin/mediaplayer/fidl/fidl_audio_renderer.cc b/bin/mediaplayer/fidl/fidl_audio_renderer.cc
index b564d5f..22a0c50 100644
--- a/bin/mediaplayer/fidl/fidl_audio_renderer.cc
+++ b/bin/mediaplayer/fidl/fidl_audio_renderer.cc
@@ -8,6 +8,7 @@
#include "garnet/bin/mediaplayer/fidl/fidl_type_conversions.h"
#include "garnet/bin/mediaplayer/graph/formatting.h"
+#include "lib/fxl/functional/make_copyable.h"
#include "lib/fxl/logging.h"
#include "lib/media/timeline/timeline.h"
#include "lib/media/timeline/timeline_rate.h"
@@ -128,11 +129,12 @@
SetEndOfStreamPts(fuchsia::media::NO_TIMESTAMP);
input_packet_request_outstanding_ = false;
- audio_renderer_->DiscardAllPackets([this, callback = std::move(callback)]() {
- last_supplied_pts_ns_ = 0;
- last_departed_pts_ns_ = fuchsia::media::NO_TIMESTAMP;
- callback();
- });
+ audio_renderer_->DiscardAllPackets(
+ fxl::MakeCopyable([this, callback = std::move(callback)]() {
+ last_supplied_pts_ns_ = 0;
+ last_departed_pts_ns_ = fuchsia::media::NO_TIMESTAMP;
+ callback();
+ }));
}
void FidlAudioRenderer::PutInputPacket(PacketPtr packet, size_t input_index) {
diff --git a/bin/netconnector/listener.cc b/bin/netconnector/listener.cc
index 961db03..b5f6104 100644
--- a/bin/netconnector/listener.cc
+++ b/bin/netconnector/listener.cc
@@ -12,6 +12,7 @@
#include "garnet/lib/inet/ip_port.h"
#include "lib/fxl/files/unique_fd.h"
+#include "lib/fxl/functional/make_copyable.h"
#include "lib/fxl/logging.h"
namespace netconnector {
@@ -86,10 +87,11 @@
break;
}
- async::PostTask(dispatcher_,
- [this, fd = std::move(connection_fd)]() mutable {
- new_connection_callback_(std::move(fd));
- });
+ async::PostTask(
+ dispatcher_,
+ fxl::MakeCopyable([this, fd = std::move(connection_fd)]() mutable {
+ new_connection_callback_(std::move(fd));
+ }));
}
}
diff --git a/bin/netconnector/responding_service_host.cc b/bin/netconnector/responding_service_host.cc
index 67964b9..d319a26 100644
--- a/bin/netconnector/responding_service_host.cc
+++ b/bin/netconnector/responding_service_host.cc
@@ -6,6 +6,7 @@
#include "lib/component/cpp/connect.h"
#include "lib/fidl/cpp/clone.h"
+#include "lib/fxl/functional/make_copyable.h"
#include "lib/fxl/logging.h"
namespace netconnector {
@@ -21,8 +22,9 @@
void RespondingServiceHost::RegisterSingleton(
const std::string& service_name, fuchsia::sys::LaunchInfoPtr launch_info) {
service_namespace_.AddServiceForName(
- [this, service_name, launch_info = std::move(launch_info)](
- zx::channel client_handle) mutable {
+ fxl::MakeCopyable([this, service_name,
+ launch_info = std::move(launch_info)](
+ zx::channel client_handle) mutable {
FXL_VLOG(2) << "Handling request for service " << service_name;
auto iter = service_providers_by_name_.find(service_name);
@@ -59,7 +61,7 @@
}
iter->second.ConnectToService(service_name, std::move(client_handle));
- },
+ }),
service_name);
}
diff --git a/bin/sysmgr/delegating_loader.cc b/bin/sysmgr/delegating_loader.cc
index 599c296..62950aa 100644
--- a/bin/sysmgr/delegating_loader.cc
+++ b/bin/sysmgr/delegating_loader.cc
@@ -77,9 +77,9 @@
}
if (package_updating_fallback_) {
- package_updating_fallback_->LoadUrl(url, std::move(callback));
+ package_updating_fallback_->LoadUrl(url, callback);
} else {
- parent_fallback_->LoadUrl(url, std::move(callback));
+ parent_fallback_->LoadUrl(url, callback);
}
}
diff --git a/bin/sysmgr/package_updating_loader.cc b/bin/sysmgr/package_updating_loader.cc
index 9aff206..f6784f6 100644
--- a/bin/sysmgr/package_updating_loader.cc
+++ b/bin/sysmgr/package_updating_loader.cc
@@ -38,7 +38,8 @@
PackageUpdatingLoader::~PackageUpdatingLoader() = default;
-void PackageUpdatingLoader::LoadUrl(std::string url, LoadUrlCallback callback) {
+void PackageUpdatingLoader::LoadUrl(std::string url,
+ LoadUrlCallback callback) {
EnsureConnectedToResolver();
// The updating loader can only update fuchsia-pkg URLs.
@@ -51,7 +52,7 @@
component::GetPathFromURL(url));
}
if (!parsed) {
- PackageLoader::LoadUrl(url, std::move(callback));
+ PackageLoader::LoadUrl(url, callback);
return;
}
@@ -61,21 +62,21 @@
// here.
if (std::find(update_dependency_urls_.begin(), update_dependency_urls_.end(),
url) != std::end(update_dependency_urls_)) {
- PackageLoader::LoadUrl(url, std::move(callback));
+ PackageLoader::LoadUrl(url, callback);
return;
}
fuchsia::io::DirectoryPtr dir;
auto dir_request = dir.NewRequest(dispatcher_);
auto done_cb = [this, url, dir = std::move(dir),
- callback = std::move(callback)](zx_status_t status) mutable {
+ callback](zx_status_t status) mutable {
// TODO: only fail soft on NOT_FOUND?
if (status != ZX_OK) {
FXL_VLOG(1) << "Package update failed with "
<< zx_status_get_string(status)
<< ". Loading package without update: " << url;
}
- PackageLoader::LoadUrl(url, std::move(callback));
+ PackageLoader::LoadUrl(url, callback);
};
fuchsia::pkg::UpdatePolicy update_policy;
diff --git a/bin/tts/tts_speaker.cc b/bin/tts/tts_speaker.cc
index dee29ed..365633f 100644
--- a/bin/tts/tts_speaker.cc
+++ b/bin/tts/tts_speaker.cc
@@ -5,6 +5,7 @@
#include <lib/async/cpp/task.h>
#include "garnet/bin/tts/tts_speaker.h"
+#include "lib/fxl/functional/make_copyable.h"
namespace tts {
@@ -140,10 +141,10 @@
if (eos && (todo == bytes_to_send)) {
audio_renderer_->SendPacket(
- std::move(pkt),
- [speak_complete_cbk = std::move(speak_complete_cbk_)]() {
+ std::move(pkt), fxl::MakeCopyable([speak_complete_cbk = std::move(
+ speak_complete_cbk_)]() {
speak_complete_cbk();
- });
+ }));
} else if (todo == bytes_till_low_water) {
audio_renderer_->SendPacket(
std::move(pkt), [thiz = shared_from_this(), new_rd_pos = tx_ptr_]() {
diff --git a/bin/ui/root_presenter/app.cc b/bin/ui/root_presenter/app.cc
index f67ae84..e6d916a 100644
--- a/bin/ui/root_presenter/app.cc
+++ b/bin/ui/root_presenter/app.cc
@@ -13,6 +13,7 @@
#include "lib/component/cpp/connect.h"
#include "lib/fidl/cpp/clone.h"
#include "lib/fxl/files/file.h"
+#include "lib/fxl/functional/make_copyable.h"
#include "lib/fxl/logging.h"
#include "lib/ui/input/cpp/formatting.h"
@@ -36,18 +37,18 @@
App::~App() {}
Presentation::YieldCallback App::GetYieldCallback() {
- return [this](bool yield_to_next) {
+ return fxl::MakeCopyable([this](bool yield_to_next) {
if (yield_to_next) {
SwitchToNextPresentation();
} else {
SwitchToPreviousPresentation();
}
- };
+ });
}
Presentation::ShutdownCallback App::GetShutdownCallback(
Presentation* presentation) {
- return [this, presentation] {
+ return fxl::MakeCopyable([this, presentation] {
size_t idx;
for (idx = 0; idx < presentations_.size(); ++idx) {
if (presentations_[idx].get() == presentation) {
@@ -73,7 +74,7 @@
layer_stack_->RemoveAllLayers();
active_presentation_idx_ = std::numeric_limits<size_t>::max();
}
- };
+ });
}
void App::Present2(zx::eventpair view_holder_token,
diff --git a/bin/ui/root_presenter/presentation1.cc b/bin/ui/root_presenter/presentation1.cc
index 35ae1d4..dfe1a80 100644
--- a/bin/ui/root_presenter/presentation1.cc
+++ b/bin/ui/root_presenter/presentation1.cc
@@ -22,6 +22,7 @@
#include <glm/gtc/type_ptr.hpp>
#include "lib/component/cpp/connect.h"
+#include "lib/fxl/functional/make_copyable.h"
#include "lib/fxl/logging.h"
#include "lib/ui/input/cpp/formatting.h"
#include "lib/ui/views/cpp/formatting.h"
@@ -198,7 +199,7 @@
yield_callback_ = std::move(yield_callback);
shutdown_callback_ = std::move(shutdown_callback);
- scenic_->GetDisplayInfo(
+ scenic_->GetDisplayInfo(fxl::MakeCopyable(
[weak = weak_factory_.GetWeakPtr(),
presentation_request = std::move(presentation_request)](
fuchsia::ui::gfx::DisplayInfo display_info) mutable {
@@ -209,7 +210,7 @@
weak->InitializeDisplayModel(std::move(display_info));
weak->PresentScene();
}
- });
+ }));
}
void Presentation1::InitializeDisplayModel(
diff --git a/bin/ui/root_presenter/presentation2.cc b/bin/ui/root_presenter/presentation2.cc
index d4ce71a..8a0cdc4 100644
--- a/bin/ui/root_presenter/presentation2.cc
+++ b/bin/ui/root_presenter/presentation2.cc
@@ -22,6 +22,7 @@
#include <glm/gtc/type_ptr.hpp>
#include "lib/component/cpp/connect.h"
+#include "lib/fxl/functional/make_copyable.h"
#include "lib/fxl/logging.h"
#include "lib/ui/input/cpp/formatting.h"
#include "lib/ui/scenic/cpp/id.h"
@@ -132,7 +133,7 @@
yield_callback_ = std::move(yield_callback);
shutdown_callback_ = std::move(shutdown_callback);
- scenic_->GetDisplayInfo(
+ scenic_->GetDisplayInfo(fxl::MakeCopyable(
[weak = weak_factory_.GetWeakPtr(),
presentation_request = std::move(presentation_request)](
fuchsia::ui::gfx::DisplayInfo display_info) mutable {
@@ -146,7 +147,7 @@
weak->PresentScene();
}
- });
+ }));
}
void Presentation2::InitializeDisplayModel(
diff --git a/bin/ui/view_manager/view_registry.cc b/bin/ui/view_manager/view_registry.cc
index 74a0fe1..f166088 100644
--- a/bin/ui/view_manager/view_registry.cc
+++ b/bin/ui/view_manager/view_registry.cc
@@ -17,6 +17,7 @@
#include "garnet/bin/ui/view_manager/view_tree_impl.h"
#include "garnet/public/lib/escher/util/type_utils.h"
#include "lib/component/cpp/connect.h"
+#include "lib/fxl/functional/make_copyable.h"
#include "lib/fxl/logging.h"
#include "lib/fxl/memory/weak_ptr.h"
#include "lib/fxl/strings/string_printf.h"
diff --git a/drivers/bluetooth/host/fidl/gatt_server_server.cc b/drivers/bluetooth/host/fidl/gatt_server_server.cc
index 2d3e974..5b29049 100644
--- a/drivers/bluetooth/host/fidl/gatt_server_server.cc
+++ b/drivers/bluetooth/host/fidl/gatt_server_server.cc
@@ -13,6 +13,8 @@
#include "helpers.h"
+#include "lib/fxl/functional/make_copyable.h"
+
using fuchsia::bluetooth::ErrorCode;
using fuchsia::bluetooth::Status;
using GattErrorCode = fuchsia::bluetooth::gatt::ErrorCode;
@@ -338,7 +340,7 @@
auto* delegate = iter->second->delegate();
ZX_DEBUG_ASSERT(delegate);
- delegate->OnReadValue(id, offset, std::move(cb));
+ delegate->OnReadValue(id, offset, fxl::MakeCopyable(std::move(cb)));
}
void GattServerServer::OnWriteRequest(::btlib::gatt::IdType service_id,
@@ -364,7 +366,8 @@
responder(GattErrorCodeFromFidl(error_code, false /* is_read */));
};
- delegate->OnWriteValue(id, offset, std::move(fidl_value), std::move(cb));
+ delegate->OnWriteValue(id, offset, std::move(fidl_value),
+ fxl::MakeCopyable(std::move(cb)));
}
void GattServerServer::OnCharacteristicConfig(::btlib::gatt::IdType service_id,
diff --git a/drivers/bluetooth/lib/gap/bredr_interrogator.cc b/drivers/bluetooth/lib/gap/bredr_interrogator.cc
index 3c20657..cefa918 100644
--- a/drivers/bluetooth/lib/gap/bredr_interrogator.cc
+++ b/drivers/bluetooth/lib/gap/bredr_interrogator.cc
@@ -163,40 +163,42 @@
auto it = pending_.find(device_id);
ZX_DEBUG_ASSERT(it != pending_.end());
- it->second->callbacks.emplace_back([device_id,
- self = weak_ptr_factory_.GetWeakPtr()](
- auto, const auto& event) {
- if (hci_is_error(event, WARN, "gap-bredr", "remote name request failed")) {
- self->Complete(device_id, event.ToStatus());
- return;
- }
+ it->second->callbacks.emplace_back(
+ [device_id, self = weak_ptr_factory_.GetWeakPtr()](auto,
+ const auto& event) {
+ if (hci_is_error(event, WARN, "gap-bredr",
+ "remote name request failed")) {
+ self->Complete(device_id, event.ToStatus());
+ return;
+ }
- if (event.event_code() == hci::kCommandStatusEventCode) {
- return;
- }
+ if (event.event_code() == hci::kCommandStatusEventCode) {
+ return;
+ }
- ZX_DEBUG_ASSERT(event.event_code() ==
- hci::kRemoteNameRequestCompleteEventCode);
+ ZX_DEBUG_ASSERT(event.event_code() ==
+ hci::kRemoteNameRequestCompleteEventCode);
- const auto& params =
- event.view()
- .template payload<hci::RemoteNameRequestCompleteEventParams>();
+ const auto& params =
+ event.view()
+ .template payload<hci::RemoteNameRequestCompleteEventParams>();
- size_t len = 0;
- for (; len < hci::kMaxNameLength; len++) {
- if (params.remote_name[len] == 0) {
- break;
- }
- }
- RemoteDevice* device = self->cache_->FindDeviceById(device_id);
- if (!device) {
- self->Complete(device_id, hci::Status(common::HostError::kFailed));
- return;
- }
- device->SetName(std::string(params.remote_name, params.remote_name + len));
+ size_t len = 0;
+ for (; len < hci::kMaxNameLength; len++) {
+ if (params.remote_name[len] == 0) {
+ break;
+ }
+ }
+ RemoteDevice* device = self->cache_->FindDeviceById(device_id);
+ if (!device) {
+ self->Complete(device_id, hci::Status(common::HostError::kFailed));
+ return;
+ }
+ device->SetName(
+ std::string(params.remote_name, params.remote_name + len));
- self->MaybeComplete(device_id);
- });
+ self->MaybeComplete(device_id);
+ });
bt_log(SPEW, "gap-bredr", "name request %s",
device->address().ToString().c_str());
@@ -323,48 +325,49 @@
auto it = pending_.find(device_id);
ZX_DEBUG_ASSERT(it != pending_.end());
- it->second->callbacks.emplace_back([device_id, handle, page,
- self = weak_ptr_factory_.GetWeakPtr()](
- auto, const auto& event) {
- if (hci_is_error(event, WARN, "gap-bredr",
- "read remote extended features failed")) {
- self->Complete(device_id, event.ToStatus());
- return;
- }
+ it->second->callbacks.emplace_back(
+ [device_id, handle, page, self = weak_ptr_factory_.GetWeakPtr()](
+ auto, const auto& event) {
+ if (hci_is_error(event, WARN, "gap-bredr",
+ "read remote extended features failed")) {
+ self->Complete(device_id, event.ToStatus());
+ return;
+ }
- if (event.event_code() == hci::kCommandStatusEventCode) {
- return;
- }
+ if (event.event_code() == hci::kCommandStatusEventCode) {
+ return;
+ }
- ZX_DEBUG_ASSERT(event.event_code() ==
- hci::kReadRemoteExtendedFeaturesCompleteEventCode);
+ ZX_DEBUG_ASSERT(event.event_code() ==
+ hci::kReadRemoteExtendedFeaturesCompleteEventCode);
- const auto& params =
- event.view()
- .template payload<
- hci::ReadRemoteExtendedFeaturesCompleteEventParams>();
+ const auto& params =
+ event.view()
+ .template payload<
+ hci::ReadRemoteExtendedFeaturesCompleteEventParams>();
- RemoteDevice* device = self->cache_->FindDeviceById(device_id);
- if (!device) {
- self->Complete(device_id, hci::Status(common::HostError::kFailed));
- return;
- }
- device->SetFeaturePage(params.page_number, le64toh(params.lmp_features));
- if (params.page_number != page) {
- bt_log(INFO, "gap-bredr",
- "requested page %u and received page %u, giving up", page,
- params.page_number);
- device->set_last_page_number(0);
- } else {
- device->set_last_page_number(params.max_page_number);
- }
+ RemoteDevice* device = self->cache_->FindDeviceById(device_id);
+ if (!device) {
+ self->Complete(device_id, hci::Status(common::HostError::kFailed));
+ return;
+ }
+ device->SetFeaturePage(params.page_number,
+ le64toh(params.lmp_features));
+ if (params.page_number != page) {
+ bt_log(INFO, "gap-bredr",
+ "requested page %u and received page %u, giving up", page,
+ params.page_number);
+ device->set_last_page_number(0);
+ } else {
+ device->set_last_page_number(params.max_page_number);
+ }
- if (params.page_number < device->features().last_page_number()) {
- self->ReadRemoteExtendedFeatures(device_id, handle,
- params.page_number + 1);
- }
- self->MaybeComplete(device_id);
- });
+ if (params.page_number < device->features().last_page_number()) {
+ self->ReadRemoteExtendedFeatures(device_id, handle,
+ params.page_number + 1);
+ }
+ self->MaybeComplete(device_id);
+ });
bt_log(SPEW, "gap-bredr", "get ext page %u", page);
hci_->command_channel()->SendCommand(
diff --git a/drivers/bluetooth/lib/gap/bredr_interrogator.h b/drivers/bluetooth/lib/gap/bredr_interrogator.h
index 427574a..0ad1362 100644
--- a/drivers/bluetooth/lib/gap/bredr_interrogator.h
+++ b/drivers/bluetooth/lib/gap/bredr_interrogator.h
@@ -9,7 +9,6 @@
#include <lib/async/cpp/task.h>
#include <lib/async/dispatcher.h>
-#include <lib/fit/function.h>
#include "garnet/drivers/bluetooth/lib/common/device_address.h"
#include "garnet/drivers/bluetooth/lib/gap/remote_device_cache.h"
@@ -52,7 +51,7 @@
// Starts interrogation. Calls |callback| when the sequence is completed or
// abandoned.
using ResultCallback =
- fit::function<void(hci::Status status, hci::ConnectionPtr conn_ptr)>;
+ std::function<void(hci::Status status, hci::ConnectionPtr conn_ptr)>;
void Start(const std::string& device_id, hci::ConnectionPtr conn_ptr,
ResultCallback callback);
diff --git a/drivers/bluetooth/lib/testing/fake_controller.cc b/drivers/bluetooth/lib/testing/fake_controller.cc
index 44e2a54..061532e 100644
--- a/drivers/bluetooth/lib/testing/fake_controller.cc
+++ b/drivers/bluetooth/lib/testing/fake_controller.cc
@@ -199,8 +199,9 @@
devices_.push_back(std::move(device));
}
-void FakeController::SetScanStateCallback(ScanStateCallback callback,
- async_dispatcher_t* dispatcher) {
+void FakeController::SetScanStateCallback(
+ ScanStateCallback callback,
+ async_dispatcher_t* dispatcher) {
ZX_DEBUG_ASSERT(callback);
ZX_DEBUG_ASSERT(dispatcher);
@@ -209,7 +210,8 @@
}
void FakeController::SetAdvertisingStateCallback(
- fit::closure callback, async_dispatcher_t* dispatcher) {
+ fit::closure callback,
+ async_dispatcher_t* dispatcher) {
ZX_DEBUG_ASSERT(callback);
ZX_DEBUG_ASSERT(dispatcher);
@@ -218,7 +220,8 @@
}
void FakeController::SetConnectionStateCallback(
- ConnectionStateCallback callback, async_dispatcher_t* dispatcher) {
+ ConnectionStateCallback callback,
+ async_dispatcher_t* dispatcher) {
ZX_DEBUG_ASSERT(callback);
ZX_DEBUG_ASSERT(dispatcher);
@@ -227,7 +230,8 @@
}
void FakeController::SetLEConnectionParametersCallback(
- LEConnectionParametersCallback callback, async_dispatcher_t* dispatcher) {
+ LEConnectionParametersCallback callback,
+ async_dispatcher_t* dispatcher) {
ZX_DEBUG_ASSERT(callback);
ZX_DEBUG_ASSERT(dispatcher);
@@ -430,34 +434,34 @@
void FakeController::L2CAPConnectionParameterUpdate(
const common::DeviceAddress& addr,
const hci::LEPreferredConnectionParameters& params) {
- async::PostTask(dispatcher(), [addr, params, this] {
- FakeDevice* dev = FindDeviceByAddress(addr);
- if (!dev) {
- bt_log(WARN, "fake-hci", "no device found with address: %s",
- addr.ToString().c_str());
- return;
- }
+ async::PostTask(dispatcher(), [addr, params, this] {
+ FakeDevice* dev = FindDeviceByAddress(addr);
+ if (!dev) {
+ bt_log(WARN, "fake-hci", "no device found with address: %s",
+ addr.ToString().c_str());
+ return;
+ }
- if (!dev->connected()) {
- bt_log(WARN, "fake-hci", "device not connected");
- return;
- }
+ if (!dev->connected()) {
+ bt_log(WARN, "fake-hci", "device not connected");
+ return;
+ }
- ZX_DEBUG_ASSERT(!dev->logical_links().empty());
+ ZX_DEBUG_ASSERT(!dev->logical_links().empty());
- l2cap::ConnectionParameterUpdateRequestPayload payload;
- payload.interval_min = htole16(params.min_interval());
- payload.interval_max = htole16(params.max_interval());
- payload.slave_latency = htole16(params.max_latency());
- payload.timeout_multiplier = htole16(params.supervision_timeout());
+ l2cap::ConnectionParameterUpdateRequestPayload payload;
+ payload.interval_min = htole16(params.min_interval());
+ payload.interval_max = htole16(params.max_interval());
+ payload.slave_latency = htole16(params.max_latency());
+ payload.timeout_multiplier = htole16(params.supervision_timeout());
- // TODO(armansito): Instead of picking the first handle we should pick
- // the handle that matches the current LE-U link.
- SendL2CAPCFrame(*dev->logical_links().begin(), true,
- l2cap::kConnectionParameterUpdateRequest,
- NextL2CAPCommandId(),
- BufferView(&payload, sizeof(payload)));
- });
+ // TODO(armansito): Instead of picking the first handle we should pick
+ // the handle that matches the current LE-U link.
+ SendL2CAPCFrame(*dev->logical_links().begin(), true,
+ l2cap::kConnectionParameterUpdateRequest,
+ NextL2CAPCommandId(),
+ BufferView(&payload, sizeof(payload)));
+ });
}
void FakeController::Disconnect(const common::DeviceAddress& addr) {
@@ -552,20 +556,19 @@
}
ZX_DEBUG_ASSERT(advertising_state_cb_dispatcher_);
- async::PostTask(advertising_state_cb_dispatcher_,
- advertising_state_cb_.share());
+ async::PostTask(advertising_state_cb_dispatcher_, advertising_state_cb_.share());
}
void FakeController::NotifyConnectionState(const common::DeviceAddress& addr,
- bool connected, bool canceled) {
+ bool connected,
+ bool canceled) {
if (!conn_state_cb_)
return;
ZX_DEBUG_ASSERT(conn_state_cb_dispatcher_);
- async::PostTask(conn_state_cb_dispatcher_,
- [addr, connected, canceled, cb = conn_state_cb_.share()] {
- cb(addr, connected, canceled);
- });
+ async::PostTask(conn_state_cb_dispatcher_, [
+ addr, connected, canceled, cb = conn_state_cb_.share()
+ ] { cb(addr, connected, canceled); });
}
void FakeController::NotifyLEConnectionParameters(
@@ -575,8 +578,7 @@
return;
ZX_DEBUG_ASSERT(le_conn_params_cb_dispatcher_);
- async::PostTask(
- le_conn_params_cb_dispatcher_,
+ async::PostTask(le_conn_params_cb_dispatcher_,
[addr, params, cb = le_conn_params_cb_.share()] { cb(addr, params); });
}
@@ -677,7 +679,7 @@
BufferView(&response, sizeof(response)));
});
async::PostTask(dispatcher(),
- [cb = pending_le_connect_rsp_.callback()] { cb(); });
+ [cb = pending_le_connect_rsp_.callback()] { cb(); });
}
void FakeController::OnLEConnectionUpdateCommandReceived(
@@ -1144,9 +1146,9 @@
// state update BEFORE the HCI command sequence terminates.
if (scan_state_cb_) {
ZX_DEBUG_ASSERT(scan_state_cb_dispatcher_);
- async::PostTask(scan_state_cb_dispatcher_,
- [cb = scan_state_cb_.share(),
- enabled = le_scan_state_.enabled] { cb(enabled); });
+ async::PostTask(scan_state_cb_dispatcher_, [
+ cb = scan_state_cb_.share(), enabled = le_scan_state_.enabled
+ ] { cb(enabled); });
}
RespondWithSuccess(opcode);
diff --git a/drivers/gpu/msd-intel-gen/tests/unit_tests/BUILD.gn b/drivers/gpu/msd-intel-gen/tests/unit_tests/BUILD.gn
index d1b9726..0f4ecab 100644
--- a/drivers/gpu/msd-intel-gen/tests/unit_tests/BUILD.gn
+++ b/drivers/gpu/msd-intel-gen/tests/unit_tests/BUILD.gn
@@ -70,11 +70,10 @@
"$magma_build_root/src/magma_util/platform:semaphore",
"$magma_build_root/tests/helper:command_buffer_helper",
"$magma_build_root/tests/helper:platform_device_helper",
- "$magma_build_root/tests/mock:bus_mapper",
"$magma_build_root/tests/mock:mmio",
+ "$magma_build_root/tests/mock:bus_mapper",
"$msd_intel_gen_build_root/src",
"$msd_intel_gen_build_root/tests/mock",
"//third_party/googletest:gtest",
- "//zircon/public/lib/fit",
]
}
diff --git a/drivers/video/amlogic-decoder/h264_decoder.cc b/drivers/video/amlogic-decoder/h264_decoder.cc
index f3a30f6..d747013 100644
--- a/drivers/video/amlogic-decoder/h264_decoder.cc
+++ b/drivers/video/amlogic-decoder/h264_decoder.cc
@@ -375,11 +375,11 @@
}
void H264Decoder::SetFrameReadyNotifier(FrameReadyNotifier notifier) {
- notifier_ = std::move(notifier);
+ notifier_ = notifier;
}
void H264Decoder::SetInitializeFramesHandler(InitializeFramesHandler handler) {
- initialize_frames_handler_ = std::move(handler);
+ initialize_frames_handler_ = handler;
}
void H264Decoder::SetErrorHandler(fit::closure error_handler) {
diff --git a/drivers/video/amlogic-decoder/local_codec_factory.cc b/drivers/video/amlogic-decoder/local_codec_factory.cc
index b5e04f2..438e6e9 100644
--- a/drivers/video/amlogic-decoder/local_codec_factory.cc
+++ b/drivers/video/amlogic-decoder/local_codec_factory.cc
@@ -11,7 +11,6 @@
#include "codec_adapter_vp9.h"
#include <lib/fidl/cpp/clone.h>
-#include <lib/fit/function.h>
#include <lib/media/codec_impl/codec_admission_control.h>
#include <optional>
@@ -22,7 +21,7 @@
// This typedef is just for local readability here, not for use outside this
// struct.
- using CreateFunction = fit::function<std::unique_ptr<CodecAdapter>(
+ using CreateFunction = std::function<std::unique_ptr<CodecAdapter>(
std::mutex& lock, CodecAdapterEvents*, DeviceCtx*)>;
bool multi_instance;
diff --git a/drivers/video/amlogic-decoder/mpeg12_decoder.cc b/drivers/video/amlogic-decoder/mpeg12_decoder.cc
index 346de67..be70dce 100644
--- a/drivers/video/amlogic-decoder/mpeg12_decoder.cc
+++ b/drivers/video/amlogic-decoder/mpeg12_decoder.cc
@@ -42,7 +42,7 @@
}
void Mpeg12Decoder::SetFrameReadyNotifier(FrameReadyNotifier notifier) {
- notifier_ = std::move(notifier);
+ notifier_ = notifier;
}
void Mpeg12Decoder::ResetHardware() {
diff --git a/drivers/video/amlogic-decoder/video_decoder.h b/drivers/video/amlogic-decoder/video_decoder.h
index fdb29a1..3a5de31 100644
--- a/drivers/video/amlogic-decoder/video_decoder.h
+++ b/drivers/video/amlogic-decoder/video_decoder.h
@@ -10,7 +10,6 @@
#include <ddk/device.h>
#include <ddk/driver.h>
#include <fuchsia/mediacodec/cpp/fidl.h>
-#include <lib/fit/function.h>
#include <lib/media/codec_impl/codec_frame.h>
#include <lib/zx/bti.h>
#include <zircon/assert.h>
@@ -64,9 +63,9 @@
// In actual operation, the FrameReadyNotifier must not keep a reference on
// the frame shared_ptr<>, as that would interfere with muting calls to
// ReturnFrame(). See comment on Vp9Decoder::Frame::frame field.
- using FrameReadyNotifier = fit::function<void(std::shared_ptr<VideoFrame>)>;
+ using FrameReadyNotifier = std::function<void(std::shared_ptr<VideoFrame>)>;
using InitializeFramesHandler =
- fit::function<zx_status_t(::zx::bti,
+ std::function<zx_status_t(::zx::bti,
uint32_t, // frame_count
uint32_t, // width
uint32_t, // height
diff --git a/drivers/video/amlogic-decoder/vp9_decoder.cc b/drivers/video/amlogic-decoder/vp9_decoder.cc
index 6bb87b7..9adfe6a 100644
--- a/drivers/video/amlogic-decoder/vp9_decoder.cc
+++ b/drivers/video/amlogic-decoder/vp9_decoder.cc
@@ -984,7 +984,7 @@
}
void Vp9Decoder::SetFrameReadyNotifier(FrameReadyNotifier notifier) {
- notifier_ = std::move(notifier);
+ notifier_ = notifier;
}
void Vp9Decoder::SetCheckOutputReady(CheckOutputReady check_output_ready) {
@@ -1289,7 +1289,7 @@
}
void Vp9Decoder::SetInitializeFramesHandler(InitializeFramesHandler handler) {
- initialize_frames_handler_ = std::move(handler);
+ initialize_frames_handler_ = handler;
}
void Vp9Decoder::SetErrorHandler(fit::closure error_handler) {
diff --git a/examples/media/fx/fx.cpp b/examples/media/fx/fx.cpp
index c06ee37..b47e0d8 100644
--- a/examples/media/fx/fx.cpp
+++ b/examples/media/fx/fx.cpp
@@ -16,12 +16,12 @@
#include <lib/zx/time.h>
#include <lib/zx/vmar.h>
#include <lib/zx/vmo.h>
+#include <limits>
#include <stdio.h>
+#include <utility>
#include <zircon/compiler.h>
#include <zircon/errors.h>
#include <zircon/types.h>
-#include <limits>
-#include <utility>
#include "lib/component/cpp/connect.h"
#include "lib/component/cpp/startup_context.h"
@@ -328,8 +328,7 @@
}
void FxProcessor::RequestKeystrokeMessage() {
- keystroke_waiter_.Wait(std::move(handle_keystroke_thunk_), STDIN_FILENO,
- POLLIN);
+ keystroke_waiter_.Wait(handle_keystroke_thunk_, STDIN_FILENO, POLLIN);
}
void FxProcessor::HandleKeystroke(zx_status_t status, uint32_t events) {
@@ -480,9 +479,9 @@
}
// Schedule our next processing callback.
- async::PostDelayedTask(
- async_get_default_dispatcher(), [this]() { ProcessInput(); },
- zx::nsec(PROCESS_CHUNK_TIME));
+ async::PostDelayedTask(async_get_default_dispatcher(),
+ [this]() { ProcessInput(); },
+ zx::nsec(PROCESS_CHUNK_TIME));
}
void FxProcessor::ProduceOutputPackets(fuchsia::media::StreamPacket* out_pkt1,
diff --git a/examples/ui/hello_views/example_view_provider_service.cc b/examples/ui/hello_views/example_view_provider_service.cc
index cfcde6b..5368144 100644
--- a/examples/ui/hello_views/example_view_provider_service.cc
+++ b/examples/ui/hello_views/example_view_provider_service.cc
@@ -9,30 +9,26 @@
#include <lib/zx/eventpair.h>
#include "lib/component/cpp/startup_context.h"
-#include "lib/fxl/logging.h"
#include "lib/ui/scenic/cpp/resources.h"
#include "lib/ui/scenic/cpp/session.h"
+#include "lib/fxl/logging.h"
namespace hello_views {
ExampleViewProviderService::ExampleViewProviderService(
component::StartupContext* startup_ctx, ViewFactory factory)
- : startup_ctx_(startup_ctx), view_factory_fn_(std::move(factory)) {
+ : startup_ctx_(startup_ctx), view_factory_fn_(factory) {
FXL_DCHECK(startup_ctx_);
- startup_ctx->outgoing()
- .deprecated_services()
- ->AddService<fuchsia::ui::app::ViewProvider>(
- [this](
- fidl::InterfaceRequest<fuchsia::ui::app::ViewProvider> request) {
- bindings_.AddBinding(this, std::move(request));
- },
- "view_provider");
+ startup_ctx->outgoing().deprecated_services()->AddService<fuchsia::ui::app::ViewProvider>(
+ [this](fidl::InterfaceRequest<fuchsia::ui::app::ViewProvider> request) {
+ bindings_.AddBinding(this, std::move(request));
+ },
+ "view_provider");
}
ExampleViewProviderService::~ExampleViewProviderService() {
- startup_ctx_->outgoing()
- .deprecated_services()
+ startup_ctx_->outgoing().deprecated_services()
->RemoveService<fuchsia::ui::app::ViewProvider>();
}
diff --git a/examples/ui/hello_views/example_view_provider_service.h b/examples/ui/hello_views/example_view_provider_service.h
index db775e5..68522de 100644
--- a/examples/ui/hello_views/example_view_provider_service.h
+++ b/examples/ui/hello_views/example_view_provider_service.h
@@ -2,12 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef GARNET_EXAMPLES_UI_HELLO_VIEWS_EXAMPLE_VIEW_PROVIDER_SERVICE_H_
-#define GARNET_EXAMPLES_UI_HELLO_VIEWS_EXAMPLE_VIEW_PROVIDER_SERVICE_H_
+#ifndef GARNET_EXAMPLES_UI_HELLO_VIEWS_VIEW_PROVIDER_SERVICE_H_
+#define GARNET_EXAMPLES_UI_HELLO_VIEWS_VIEW_PROVIDER_SERVICE_H_
#include <fuchsia/sys/cpp/fidl.h>
#include <fuchsia/ui/app/cpp/fidl.h>
-#include <lib/fit/function.h>
#include <lib/zx/eventpair.h>
#include "lib/component/cpp/startup_context.h"
@@ -26,7 +25,7 @@
// A callback to create a view in response to a call to
// |ViewProvider.CreateView()|.
-using ViewFactory = fit::function<void(ViewContext context)>;
+using ViewFactory = std::function<void(ViewContext context)>;
// A basic implementation of the |ViewProvider| interface which Scenic clients
// can use to create and expose custom Views to other Scenic clients.
@@ -57,4 +56,4 @@
} // namespace hello_views
-#endif // GARNET_EXAMPLES_UI_HELLO_VIEWS_EXAMPLE_VIEW_PROVIDER_SERVICE_H_
+#endif // GARNET_EXAMPLES_UI_HELLO_VIEWS_VIEW_PROVIDER_SERVICE_H_
diff --git a/lib/cpuperf/file_reader.h b/lib/cpuperf/file_reader.h
index 4e67cc9..57e3ba8 100644
--- a/lib/cpuperf/file_reader.h
+++ b/lib/cpuperf/file_reader.h
@@ -10,7 +10,6 @@
#include <functional>
#include <string>
-#include <lib/fit/function.h>
#include <lib/fxl/files/unique_fd.h>
#include <lib/fxl/macros.h>
#include <lib/zircon-internal/device/cpu-trace/cpu-perf.h>
@@ -22,7 +21,7 @@
class FileReader final : public Reader {
public:
- using FileNameProducer = fit::function<std::string(uint32_t trace_num)>;
+ using FileNameProducer = std::function<std::string(uint32_t trace_num)>;
static bool Create(FileNameProducer file_name_producer, uint32_t num_traces,
std::unique_ptr<FileReader>* out_reader);
diff --git a/lib/magma/src/magma_util/BUILD.gn b/lib/magma/src/magma_util/BUILD.gn
index b5f2a6d..36b009c 100644
--- a/lib/magma/src/magma_util/BUILD.gn
+++ b/lib/magma/src/magma_util/BUILD.gn
@@ -85,9 +85,7 @@
}
group("system") {
- public_deps = [
- ":allocator",
- ]
+ public_deps = [ ":allocator" ]
}
source_set("allocator") {
@@ -106,7 +104,6 @@
public_deps = [
":common",
- "//zircon/public/lib/fit",
]
}
diff --git a/lib/magma/src/magma_util/platform/BUILD.gn b/lib/magma/src/magma_util/platform/BUILD.gn
index 81a8c57..c5d5bba 100644
--- a/lib/magma/src/magma_util/platform/BUILD.gn
+++ b/lib/magma/src/magma_util/platform/BUILD.gn
@@ -297,7 +297,6 @@
public_deps = [
"zircon:trace",
- "//zircon/public/lib/fit",
]
allow_circular_includes_from = [ "zircon:trace" ]
diff --git a/lib/magma/src/magma_util/platform/platform_trace.h b/lib/magma/src/magma_util/platform/platform_trace.h
index 04fddb1..e2e4d64 100644
--- a/lib/magma/src/magma_util/platform/platform_trace.h
+++ b/lib/magma/src/magma_util/platform/platform_trace.h
@@ -7,8 +7,6 @@
#include <functional>
-#include <lib/fit/function.h>
-
#if MAGMA_ENABLE_TRACING
#include "trace-vthread/event_vthread.h"
#include <trace/event.h>
@@ -54,7 +52,7 @@
virtual bool Initialize() = 0;
// Invokes the given |callback| (on a different thread) when the tracing state changes.
- virtual void SetObserver(fit::function<void(bool trace_enabled)> callback) = 0;
+ virtual void SetObserver(std::function<void(bool trace_enabled)> callback) = 0;
};
} // namespace magma
diff --git a/lib/magma/src/magma_util/platform/zircon/BUILD.gn b/lib/magma/src/magma_util/platform/zircon/BUILD.gn
index 60ed4a6..42f257a 100644
--- a/lib/magma/src/magma_util/platform/zircon/BUILD.gn
+++ b/lib/magma/src/magma_util/platform/zircon/BUILD.gn
@@ -250,7 +250,6 @@
deps = [
"$magma_build_root/src/magma_util",
- "$zircon_build_root/public/lib/fit",
"$zircon_build_root/public/lib/zx",
]
}
@@ -270,12 +269,8 @@
"$magma_build_root/src/magma_util",
]
- public_deps = [
- "//zircon/public/lib/fit",
- ]
-
if (magma_enable_tracing) {
- public_deps += [
+ public_deps = [
"$zircon_build_root/public/lib/async-cpp",
"$zircon_build_root/public/lib/async-loop-cpp",
"$zircon_build_root/public/lib/trace",
diff --git a/lib/magma/src/magma_util/platform/zircon/zircon_platform_trace.cc b/lib/magma/src/magma_util/platform/zircon/zircon_platform_trace.cc
index 627874f..82076ae 100644
--- a/lib/magma/src/magma_util/platform/zircon/zircon_platform_trace.cc
+++ b/lib/magma/src/magma_util/platform/zircon/zircon_platform_trace.cc
@@ -6,8 +6,6 @@
#include <memory>
-#include <lib/fit/function.h>
-
#include "magma_util/dlog.h"
#include "magma_util/macros.h"
@@ -50,12 +48,12 @@
return true;
}
-void ZirconPlatformTraceObserver::SetObserver(fit::function<void(bool)> callback)
+void ZirconPlatformTraceObserver::SetObserver(std::function<void(bool)> callback)
{
observer_.Stop();
enabled_ = false;
- observer_.Start(loop_.dispatcher(), [this, callback = std::move(callback)] {
+ observer_.Start(loop_.dispatcher(), [this, callback] {
bool enabled = trace_state() == TRACE_STARTED;
if (this->enabled_ != enabled) {
this->enabled_ = enabled;
diff --git a/lib/magma/src/magma_util/platform/zircon/zircon_platform_trace.h b/lib/magma/src/magma_util/platform/zircon/zircon_platform_trace.h
index b264bf9..519b570 100644
--- a/lib/magma/src/magma_util/platform/zircon/zircon_platform_trace.h
+++ b/lib/magma/src/magma_util/platform/zircon/zircon_platform_trace.h
@@ -5,8 +5,6 @@
#ifndef ZIRCON_PLATFORM_TRACE_H
#define ZIRCON_PLATFORM_TRACE_H
-#include <lib/fit/function.h>
-
#if MAGMA_ENABLE_TRACING
#include <lib/async-loop/cpp/loop.h>
#include <trace-provider/provider.h>
@@ -38,7 +36,7 @@
bool Initialize() override;
// Can only have one observer
- void SetObserver(fit::function<void(bool)> callback) override;
+ void SetObserver(std::function<void(bool)> callback) override;
private:
async::Loop loop_;
diff --git a/lib/magma/src/magma_util/retry_allocator.h b/lib/magma/src/magma_util/retry_allocator.h
index 4dff428..0b72c93 100644
--- a/lib/magma/src/magma_util/retry_allocator.h
+++ b/lib/magma/src/magma_util/retry_allocator.h
@@ -7,8 +7,6 @@
#include <map>
-#include <lib/fit/function.h>
-
#include "macros.h"
namespace magma {
@@ -18,7 +16,7 @@
// space.
class RetryAllocator final {
public:
- using AllocationFunction = fit::function<bool(uint64_t)>;
+ using AllocationFunction = std::function<bool(uint64_t)>;
static std::unique_ptr<RetryAllocator> Create(uint64_t base, uint64_t size);
diff --git a/lib/magma/src/sys_driver/BUILD.gn b/lib/magma/src/sys_driver/BUILD.gn
index eadf3c2..2dd361e 100644
--- a/lib/magma/src/sys_driver/BUILD.gn
+++ b/lib/magma/src/sys_driver/BUILD.gn
@@ -10,7 +10,6 @@
"$magma_build_root/include:msd_abi",
"$magma_build_root/src/magma_util",
"$magma_build_root/src/magma_util/platform:buffer",
- "//zircon/public/lib/fit",
]
sources = [
diff --git a/lib/magma/src/sys_driver/magma_driver.h b/lib/magma/src/sys_driver/magma_driver.h
index c5c92f3..b574a72 100644
--- a/lib/magma/src/sys_driver/magma_driver.h
+++ b/lib/magma/src/sys_driver/magma_driver.h
@@ -5,15 +5,13 @@
#ifndef GARNET_LIB_MAGMA_SRC_SYS_DRIVER_MAGMA_DRIVER_H_
#define GARNET_LIB_MAGMA_SRC_SYS_DRIVER_MAGMA_DRIVER_H_
-#include <lib/fit/function.h>
-
#include "magma_util/dlog.h"
#include "magma_util/macros.h"
#include "msd.h"
#include "magma_system_device.h"
-using msd_driver_unique_ptr_t = std::unique_ptr<msd_driver_t, fit::function<void(msd_driver_t*)>>;
+using msd_driver_unique_ptr_t = std::unique_ptr<msd_driver_t, std::function<void(msd_driver_t*)>>;
static inline msd_driver_unique_ptr_t MsdDriverUniquePtr(msd_driver_t* driver)
{
diff --git a/lib/magma/tests/unit_tests/BUILD.gn b/lib/magma/tests/unit_tests/BUILD.gn
index cd56b36..47cf1b7 100644
--- a/lib/magma/tests/unit_tests/BUILD.gn
+++ b/lib/magma/tests/unit_tests/BUILD.gn
@@ -38,7 +38,6 @@
"$magma_build_root/tests/helper:platform_device_helper",
"$magma_build_root/tests/mock:msd",
"//third_party/googletest:gtest",
- "//zircon/public/lib/fit",
]
}
diff --git a/lib/ui/gfx/resources/snapshot/snapshotter.cc b/lib/ui/gfx/resources/snapshot/snapshotter.cc
index a53444d..b492853 100644
--- a/lib/ui/gfx/resources/snapshot/snapshotter.cc
+++ b/lib/ui/gfx/resources/snapshot/snapshotter.cc
@@ -4,9 +4,7 @@
#include "garnet/lib/ui/gfx/resources/snapshot/snapshotter.h"
-#include <lib/fit/function.h>
#include <lib/zx/vmo.h>
-
#include "garnet/lib/ui/gfx/resources/buffer.h"
#include "garnet/lib/ui/gfx/resources/camera.h"
#include "garnet/lib/ui/gfx/resources/compositor/display_compositor.h"
@@ -36,6 +34,7 @@
#include "lib/escher/vk/image.h"
#include "lib/fsl/vmo/sized_vmo.h"
#include "lib/fsl/vmo/vector.h"
+#include "lib/fxl/functional/make_copyable.h"
#include "lib/fxl/logging.h"
namespace scenic_impl {
@@ -88,21 +87,22 @@
resource->Accept(this);
// Submit all images/buffers to be read from GPU.
- gpu_uploader_->Submit([node_serializer = current_node_serializer_,
+ gpu_uploader_->Submit(
+ fxl::MakeCopyable([node_serializer = current_node_serializer_,
callback = std::move(callback)]() {
- TRACE_DURATION("gfx", "Snapshotter::Serialize");
- auto builder = std::make_shared<flatbuffers::FlatBufferBuilder>();
- builder->Finish(node_serializer->serialize(*builder));
+ TRACE_DURATION("gfx", "Snapshotter::Serialize");
+ auto builder = std::make_shared<flatbuffers::FlatBufferBuilder>();
+ builder->Finish(node_serializer->serialize(*builder));
- fsl::SizedVmo sized_vmo;
- if (!VmoFromBytes(builder->GetBufferPointer(), builder->GetSize(),
- SnapshotData::SnapshotType::kFlatBuffer,
- SnapshotData::SnapshotVersion::v1_0, &sized_vmo)) {
- return callback(fuchsia::mem::Buffer{});
- } else {
- return callback(std::move(sized_vmo).ToTransport());
- }
- });
+ fsl::SizedVmo sized_vmo;
+ if (!VmoFromBytes(builder->GetBufferPointer(), builder->GetSize(),
+ SnapshotData::SnapshotType::kFlatBuffer,
+ SnapshotData::SnapshotVersion::v1_0, &sized_vmo)) {
+ return callback(fuchsia::mem::Buffer{});
+ } else {
+ return callback(std::move(sized_vmo).ToTransport());
+ }
+ }));
}
void Snapshotter::Visit(EntityNode* r) { VisitNode(r); }
@@ -333,7 +333,7 @@
void Snapshotter::ReadImage(
escher::ImagePtr image,
- fit::function<void(escher::BufferPtr buffer)> callback) {
+ std::function<void(escher::BufferPtr buffer)> callback) {
vk::BufferImageCopy region;
region.imageSubresource.aspectMask = vk::ImageAspectFlagBits::eColor;
region.imageSubresource.mipLevel = 0;
@@ -351,7 +351,7 @@
void Snapshotter::ReadBuffer(
escher::BufferPtr buffer,
- fit::function<void(escher::BufferPtr buffer)> callback) {
+ std::function<void(escher::BufferPtr buffer)> callback) {
auto reader = gpu_uploader_->AcquireReader(buffer->size());
reader->ReadBuffer(buffer, {0, 0, buffer->size()});
gpu_uploader_->PostReader(std::move(reader), std::move(callback));
diff --git a/lib/ui/gfx/resources/snapshot/snapshotter.h b/lib/ui/gfx/resources/snapshot/snapshotter.h
index 105c77a..66aab6b 100644
--- a/lib/ui/gfx/resources/snapshot/snapshotter.h
+++ b/lib/ui/gfx/resources/snapshot/snapshotter.h
@@ -5,8 +5,6 @@
#ifndef GARNET_LIB_UI_GFX_RESOURCES_SNAPSHOT_SNAPSHOTTER_H_
#define GARNET_LIB_UI_GFX_RESOURCES_SNAPSHOT_SNAPSHOTTER_H_
-#include <lib/fit/function.h>
-
#include "garnet/lib/ui/gfx/resources/resource_visitor.h"
#include "garnet/lib/ui/gfx/resources/snapshot/serializer.h"
#include "garnet/lib/ui/scenic/scenic.h"
@@ -68,9 +66,9 @@
void VisitImage(escher::ImagePtr i);
void ReadImage(escher::ImagePtr image,
- fit::function<void(escher::BufferPtr buffer)> callback);
+ std::function<void(escher::BufferPtr buffer)> callback);
void ReadBuffer(escher::BufferPtr buffer,
- fit::function<void(escher::BufferPtr buffer)> callback);
+ std::function<void(escher::BufferPtr buffer)> callback);
escher::BatchGpuUploaderPtr gpu_uploader_;
diff --git a/lib/ui/gfx/screenshotter.cc b/lib/ui/gfx/screenshotter.cc
index 7d6de0a..bc566b8 100644
--- a/lib/ui/gfx/screenshotter.cc
+++ b/lib/ui/gfx/screenshotter.cc
@@ -20,6 +20,7 @@
#include "lib/escher/impl/image_cache.h"
#include "lib/fsl/vmo/sized_vmo.h"
#include "lib/fsl/vmo/vector.h"
+#include "lib/fxl/functional/make_copyable.h"
namespace scenic_impl {
namespace gfx {
@@ -114,12 +115,13 @@
vk::Queue queue = escher->command_buffer_pool()->queue();
auto* command_buffer = escher->command_buffer_pool()->GetCommandBuffer();
- command_buffer->Submit(queue,
- [image, width, height, device = escher->vk_device(),
- done_callback = std::move(done_callback)]() mutable {
- OnCommandBufferDone(image, width, height, device,
- std::move(done_callback));
- });
+ command_buffer->Submit(
+ queue,
+ fxl::MakeCopyable([image, width, height, device = escher->vk_device(),
+ done_callback = std::move(done_callback)]() mutable {
+ OnCommandBufferDone(image, width, height, device,
+ std::move(done_callback));
+ }));
// Force the command buffer to retire to guarantee that |done_callback| will
// be called in a timely fashion.
diff --git a/lib/ui/gfx/tests/resource_linker_unittest.cc b/lib/ui/gfx/tests/resource_linker_unittest.cc
index ce0dab2..1d57f64 100644
--- a/lib/ui/gfx/tests/resource_linker_unittest.cc
+++ b/lib/ui/gfx/tests/resource_linker_unittest.cc
@@ -10,6 +10,7 @@
#include "garnet/lib/ui/gfx/tests/util.h"
#include "lib/fsl/handles/object_info.h"
+#include "lib/fxl/functional/make_copyable.h"
#include "lib/ui/scenic/cpp/commands.h"
namespace scenic_impl {
@@ -170,37 +171,39 @@
bool expiry_cb_called = false;
bool did_resolve = false;
- async::PostTask(dispatcher(), [this, &import, &resource, linker,
- &expiry_cb_called, &did_resolve,
- destination =
- std::move(destination)]() mutable {
- // Set an expiry callback that checks the resource expired for the right
- // reason and signal the latch.
- linker->SetOnExpiredCallback(
- [&linker, &expiry_cb_called](Resource*,
- ResourceLinker::ExpirationCause cause) {
- ASSERT_EQ(ResourceLinker::ExpirationCause::kExportTokenClosed, cause);
- ASSERT_EQ(0u, linker->NumUnresolvedImports());
- ASSERT_EQ(0u, linker->NumExports());
- expiry_cb_called = true;
- });
+ async::PostTask(
+ dispatcher(),
+ fxl::MakeCopyable([this, &import, &resource, linker, &expiry_cb_called,
+ &did_resolve,
+ destination = std::move(destination)]() mutable {
+ // Set an expiry callback that checks the resource expired for the right
+ // reason and signal the latch.
+ linker->SetOnExpiredCallback(
+ [&linker, &expiry_cb_called](
+ Resource*, ResourceLinker::ExpirationCause cause) {
+ ASSERT_EQ(ResourceLinker::ExpirationCause::kExportTokenClosed,
+ cause);
+ ASSERT_EQ(0u, linker->NumUnresolvedImports());
+ ASSERT_EQ(0u, linker->NumExports());
+ expiry_cb_called = true;
+ });
- linker->SetOnImportResolvedCallback(
- [&did_resolve](Import* import, Resource* resource,
- ImportResolutionResult cause) -> void {
- did_resolve = true;
- });
- import = fxl::MakeRefCounted<Import>(session_.get(), 1,
- ::fuchsia::ui::gfx::ImportSpec::NODE,
- linker->GetWeakPtr());
- ASSERT_TRUE(linker->ImportResource(
- import.get(),
- ::fuchsia::ui::gfx::ImportSpec::NODE, // import spec
- std::move(destination))); // import handle
+ linker->SetOnImportResolvedCallback(
+ [&did_resolve](Import* import, Resource* resource,
+ ImportResolutionResult cause) -> void {
+ did_resolve = true;
+ });
+ import = fxl::MakeRefCounted<Import>(
+ session_.get(), 1, ::fuchsia::ui::gfx::ImportSpec::NODE,
+ linker->GetWeakPtr());
+ ASSERT_TRUE(linker->ImportResource(
+ import.get(),
+ ::fuchsia::ui::gfx::ImportSpec::NODE, // import spec
+ std::move(destination))); // import handle
- ASSERT_EQ(1u, linker->NumUnresolvedImports());
- ASSERT_FALSE(did_resolve);
- });
+ ASSERT_EQ(1u, linker->NumUnresolvedImports());
+ ASSERT_FALSE(did_resolve);
+ }));
EXPECT_TRUE(RunLoopUntilIdle());
ASSERT_TRUE(expiry_cb_called);
@@ -258,25 +261,28 @@
scenic_impl::gfx::ResourcePtr resource;
bool called = false;
- async::PostTask(dispatcher(), [this, &resource, linker,
- source = std::move(source),
- &called]() mutable {
- resource =
- fxl::MakeRefCounted<EntityNode>(session_.get(), 1 /* resource id */);
+ async::PostTask(
+ dispatcher(),
+ fxl::MakeCopyable([this, &resource, linker, source = std::move(source),
+ &called]() mutable {
+ resource = fxl::MakeRefCounted<EntityNode>(session_.get(),
+ 1 /* resource id */);
- ASSERT_TRUE(linker->ExportResource(resource.get(), std::move(source)));
- ASSERT_EQ(1u, linker->NumExports());
+ ASSERT_TRUE(linker->ExportResource(resource.get(), std::move(source)));
+ ASSERT_EQ(1u, linker->NumExports());
- // Set an expiry callback that checks the resource expired for the right
- // reason and signal the latch.
- linker->SetOnExpiredCallback(
- [linker, &called](Resource*, ResourceLinker::ExpirationCause cause) {
- ASSERT_EQ(ResourceLinker::ExpirationCause::kNoImportsBound, cause);
- ASSERT_EQ(0u, linker->NumUnresolvedImports());
- ASSERT_EQ(0u, linker->NumExports());
- called = true;
- });
- });
+ // Set an expiry callback that checks the resource expired for the right
+ // reason and signal the latch.
+ linker->SetOnExpiredCallback(
+ [linker, &called](Resource*,
+ ResourceLinker::ExpirationCause cause) {
+ ASSERT_EQ(ResourceLinker::ExpirationCause::kNoImportsBound,
+ cause);
+ ASSERT_EQ(0u, linker->NumUnresolvedImports());
+ ASSERT_EQ(0u, linker->NumExports());
+ called = true;
+ });
+ }));
EXPECT_TRUE(RunLoopUntilIdle());
ASSERT_TRUE(called);
}
@@ -290,28 +296,31 @@
scenic_impl::gfx::ResourcePtr resource;
bool called = false;
- async::PostTask(dispatcher(), [this, &resource, linker,
- source = std::move(source), &destination,
- &called]() mutable {
- // Register the resource.
- resource =
- fxl::MakeRefCounted<EntityNode>(session_.get(), 1 /* resource id */);
+ async::PostTask(
+ dispatcher(),
+ fxl::MakeCopyable([this, &resource, linker, source = std::move(source),
+ &destination, &called]() mutable {
+ // Register the resource.
+ resource = fxl::MakeRefCounted<EntityNode>(session_.get(),
+ 1 /* resource id */);
- ASSERT_TRUE(linker->ExportResource(resource.get(), std::move(source)));
- ASSERT_EQ(1u, linker->NumExports());
+ ASSERT_TRUE(linker->ExportResource(resource.get(), std::move(source)));
+ ASSERT_EQ(1u, linker->NumExports());
- // Set an expiry callback that checks the resource expired for the right
- // reason and signal the latch.
- linker->SetOnExpiredCallback(
- [linker, &called](Resource*, ResourceLinker::ExpirationCause cause) {
- ASSERT_EQ(ResourceLinker::ExpirationCause::kNoImportsBound, cause);
- ASSERT_EQ(0u, linker->NumExports());
- called = true;
- });
+ // Set an expiry callback that checks the resource expired for the right
+ // reason and signal the latch.
+ linker->SetOnExpiredCallback(
+ [linker, &called](Resource*,
+ ResourceLinker::ExpirationCause cause) {
+ ASSERT_EQ(ResourceLinker::ExpirationCause::kNoImportsBound,
+ cause);
+ ASSERT_EQ(0u, linker->NumExports());
+ called = true;
+ });
- // Release the destination handle.
- destination.reset();
- });
+ // Release the destination handle.
+ destination.reset();
+ }));
EXPECT_TRUE(RunLoopUntilIdle());
ASSERT_TRUE(called);
@@ -327,36 +336,39 @@
ImportPtr import;
bool did_resolve = false;
- async::PostTask(dispatcher(), [this, &import, &resource, linker,
- source = std::move(source), &destination,
- &did_resolve]() mutable {
- // Register the resource.
- resource =
- fxl::MakeRefCounted<EntityNode>(session_.get(), 1 /* resource id */);
+ async::PostTask(
+ dispatcher(), fxl::MakeCopyable([this, &import, &resource, linker,
+ source = std::move(source), &destination,
+ &did_resolve]() mutable {
+ // Register the resource.
+ resource = fxl::MakeRefCounted<EntityNode>(session_.get(),
+ 1 /* resource id */);
- // Import.
- linker->SetOnImportResolvedCallback(
- [&did_resolve, linker](Import* import, Resource* resource,
- ImportResolutionResult cause) -> void {
- did_resolve = true;
- ASSERT_FALSE(resource);
- ASSERT_EQ(ImportResolutionResult::kExportHandleDiedBeforeBind, cause);
- ASSERT_EQ(0u, linker->NumUnresolvedImports());
- });
+ // Import.
+ linker->SetOnImportResolvedCallback(
+ [&did_resolve, linker](Import* import, Resource* resource,
+ ImportResolutionResult cause) -> void {
+ did_resolve = true;
+ ASSERT_FALSE(resource);
+ ASSERT_EQ(ImportResolutionResult::kExportHandleDiedBeforeBind,
+ cause);
+ ASSERT_EQ(0u, linker->NumUnresolvedImports());
+ });
- import = fxl::MakeRefCounted<Import>(session_.get(), 2,
- ::fuchsia::ui::gfx::ImportSpec::NODE,
- linker->GetWeakPtr());
- linker->ImportResource(import.get(),
- ::fuchsia::ui::gfx::ImportSpec::NODE, // import spec
- CopyEventPair(destination)); // import handle
+ import = fxl::MakeRefCounted<Import>(
+ session_.get(), 2, ::fuchsia::ui::gfx::ImportSpec::NODE,
+ linker->GetWeakPtr());
+ linker->ImportResource(
+ import.get(),
+ ::fuchsia::ui::gfx::ImportSpec::NODE, // import spec
+ CopyEventPair(destination)); // import handle
- ASSERT_EQ(1u, linker->NumUnresolvedImports());
+ ASSERT_EQ(1u, linker->NumUnresolvedImports());
- // Release both destination and source handles.
- destination.reset();
- source.reset();
- });
+ // Release both destination and source handles.
+ destination.reset();
+ source.reset();
+ }));
EXPECT_TRUE(RunLoopUntilIdle());
ASSERT_TRUE(did_resolve);
@@ -369,25 +381,28 @@
ResourceLinker* linker = resource_linker_.get();
bool called = false;
- async::PostTask(dispatcher(), [this, linker, source = std::move(source),
- &destination, &called]() mutable {
- // Register the resource.
- auto resource =
- fxl::MakeRefCounted<EntityNode>(session_.get(), 1 /* resource id */);
- ASSERT_TRUE(linker->ExportResource(resource.get(), std::move(source)));
- ASSERT_EQ(1u, linker->NumExports());
+ async::PostTask(
+ dispatcher(), fxl::MakeCopyable([this, linker, source = std::move(source),
+ &destination, &called]() mutable {
+ // Register the resource.
+ auto resource = fxl::MakeRefCounted<EntityNode>(session_.get(),
+ 1 /* resource id */);
+ ASSERT_TRUE(linker->ExportResource(resource.get(), std::move(source)));
+ ASSERT_EQ(1u, linker->NumExports());
- // Set an expiry callback that checks the resource expired for the right
- // reason and signal the latch.
- linker->SetOnExpiredCallback(
- [linker, &called](Resource*, ResourceLinker::ExpirationCause cause) {
- ASSERT_EQ(ResourceLinker::ExpirationCause::kResourceDestroyed, cause);
- ASSERT_EQ(0u, linker->NumExports());
- called = true;
- });
+ // Set an expiry callback that checks the resource expired for the right
+ // reason and signal the latch.
+ linker->SetOnExpiredCallback(
+ [linker, &called](Resource*,
+ ResourceLinker::ExpirationCause cause) {
+ ASSERT_EQ(ResourceLinker::ExpirationCause::kResourceDestroyed,
+ cause);
+ ASSERT_EQ(0u, linker->NumExports());
+ called = true;
+ });
- // |resource| gets destroyed now since its out of scope.
- });
+ // |resource| gets destroyed now since its out of scope.
+ }));
EXPECT_TRUE(RunLoopUntilIdle());
ASSERT_TRUE(called);
diff --git a/lib/wlan/mlme/include/wlan/mlme/mac_frame.h b/lib/wlan/mlme/include/wlan/mlme/mac_frame.h
index 9e2d711..2a6930f 100644
--- a/lib/wlan/mlme/include/wlan/mlme/mac_frame.h
+++ b/lib/wlan/mlme/include/wlan/mlme/mac_frame.h
@@ -5,15 +5,15 @@
#ifndef GARNET_LIB_WLAN_MLME_INCLUDE_WLAN_MLME_MAC_FRAME_H_
#define GARNET_LIB_WLAN_MLME_INCLUDE_WLAN_MLME_MAC_FRAME_H_
+#include <wlan/mlme/sequence.h>
+
#include <fbl/unique_ptr.h>
-#include <lib/fit/function.h>
#include <lib/zx/time.h>
#include <wlan/common/bitfield.h>
#include <wlan/common/mac_frame.h>
#include <wlan/common/macaddr.h>
#include <wlan/mlme/frame_validation.h>
#include <wlan/mlme/packet.h>
-#include <wlan/mlme/sequence.h>
#include <zircon/compiler.h>
#include <zircon/types.h>
@@ -274,7 +274,7 @@
void SetSeqNo(MgmtFrameHeader* hdr, uint8_t aci, Sequence* seq);
void SetSeqNo(DataFrameHeader* hdr, Sequence* seq);
-using MsduCallback = fit::function<void(FrameView<LlcHeader>, size_t)>;
+using MsduCallback = std::function<void(FrameView<LlcHeader>, size_t)>;
// Returns a list of all LLC frames carried in an AMSDU data frame.
zx_status_t DeaggregateAmsdu(const DataFrameView<AmsduSubframeHeader>&, MsduCallback);
diff --git a/public/fidl/fuchsia.sys/BUILD.gn b/public/fidl/fuchsia.sys/BUILD.gn
index 90384593..0962cb0 100644
--- a/public/fidl/fuchsia.sys/BUILD.gn
+++ b/public/fidl/fuchsia.sys/BUILD.gn
@@ -5,6 +5,8 @@
import("//build/fidl/fidl.gni")
fidl("fuchsia.sys") {
+ cpp_legacy_callbacks = true
+
sdk_category = "partner"
sources = [
diff --git a/public/lib/cobalt/cpp/cobalt_logger_impl.h b/public/lib/cobalt/cpp/cobalt_logger_impl.h
index 3f10a6b..95da378 100644
--- a/public/lib/cobalt/cpp/cobalt_logger_impl.h
+++ b/public/lib/cobalt/cpp/cobalt_logger_impl.h
@@ -34,11 +34,7 @@
: Event(metric_id), event_code_(event_code) {}
void Log(fuchsia::cobalt::LoggerPtr* logger,
fit::function<void(fuchsia::cobalt::Status)> callback) {
- (*logger)->LogEvent(
- metric_id(), event_code_,
- [callback = callback.share()](fuchsia::cobalt::Status status) {
- callback(status);
- });
+ (*logger)->LogEvent(metric_id(), event_code_, std::move(callback));
}
uint32_t event_code() const { return event_code_; }
@@ -58,11 +54,9 @@
count_(count) {}
void Log(fuchsia::cobalt::LoggerPtr* logger,
fit::function<void(fuchsia::cobalt::Status)> callback) {
- (*logger)->LogEventCount(
- metric_id(), event_code_, component_, period_duration_micros_, count_,
- [callback = callback.share()](fuchsia::cobalt::Status status) {
- callback(status);
- });
+ (*logger)->LogEventCount(metric_id(), event_code_, component_,
+ period_duration_micros_, count_,
+ std::move(callback));
}
uint32_t event_code() const { return event_code_; }
const std::string& component() const { return component_; }
@@ -86,11 +80,8 @@
elapsed_micros_(elapsed_micros) {}
void Log(fuchsia::cobalt::LoggerPtr* logger,
fit::function<void(fuchsia::cobalt::Status)> callback) {
- (*logger)->LogElapsedTime(
- metric_id(), event_code_, component_, elapsed_micros_,
- [callback = callback.share()](fuchsia::cobalt::Status status) {
- callback(status);
- });
+ (*logger)->LogElapsedTime(metric_id(), event_code_, component_,
+ elapsed_micros_, std::move(callback));
}
uint32_t event_code() const { return event_code_; }
const std::string& component() const { return component_; }
@@ -112,11 +103,8 @@
fps_(fps) {}
void Log(fuchsia::cobalt::LoggerPtr* logger,
fit::function<void(fuchsia::cobalt::Status)> callback) {
- (*logger)->LogFrameRate(
- metric_id(), event_code_, component_, fps_,
- [callback = callback.share()](fuchsia::cobalt::Status status) {
- callback(status);
- });
+ (*logger)->LogFrameRate(metric_id(), event_code_, component_, fps_,
+ std::move(callback));
}
uint32_t event_code() const { return event_code_; }
const std::string& component() const { return component_; }
@@ -138,11 +126,8 @@
bytes_(bytes) {}
void Log(fuchsia::cobalt::LoggerPtr* logger,
fit::function<void(fuchsia::cobalt::Status)> callback) {
- (*logger)->LogMemoryUsage(
- metric_id(), event_code_, component_, bytes_,
- [callback = callback.share()](fuchsia::cobalt::Status status) {
- callback(status);
- });
+ (*logger)->LogMemoryUsage(metric_id(), event_code_, component_, bytes_,
+ std::move(callback));
}
uint32_t event_code() const { return event_code_; }
const std::string& component() const { return component_; }
@@ -160,11 +145,7 @@
: Event(metric_id), s_(s) {}
void Log(fuchsia::cobalt::LoggerPtr* logger,
fit::function<void(fuchsia::cobalt::Status)> callback) {
- (*logger)->LogString(
- metric_id(), s_,
- [callback = callback.share()](fuchsia::cobalt::Status status) {
- callback(status);
- });
+ (*logger)->LogString(metric_id(), s_, std::move(callback));
}
const std::string& s() const { return s_; }
@@ -185,11 +166,8 @@
timeout_s_(timeout_s) {}
void Log(fuchsia::cobalt::LoggerPtr* logger,
fit::function<void(fuchsia::cobalt::Status)> callback) {
- (*logger)->StartTimer(
- metric_id(), event_code_, component_, timer_id_, timestamp_, timeout_s_,
- [callback = callback.share()](fuchsia::cobalt::Status status) {
- callback(status);
- });
+ (*logger)->StartTimer(metric_id(), event_code_, component_, timer_id_,
+ timestamp_, timeout_s_, std::move(callback));
}
uint32_t event_code() const { return event_code_; }
const std::string& component() const { return component_; }
@@ -215,11 +193,7 @@
timeout_s_(timeout_s) {}
void Log(fuchsia::cobalt::LoggerPtr* logger,
fit::function<void(fuchsia::cobalt::Status)> callback) {
- (*logger)->EndTimer(
- timer_id_, timestamp_, timeout_s_,
- [callback = callback.share()](fuchsia::cobalt::Status status) {
- callback(status);
- });
+ (*logger)->EndTimer(timer_id_, timestamp_, timeout_s_, std::move(callback));
}
const std::string& timer_id() const { return timer_id_; }
uint64_t timestamp() const { return timestamp_; }
@@ -244,11 +218,8 @@
fit::function<void(fuchsia::cobalt::Status)> callback) {
std::vector<fuchsia::cobalt::HistogramBucket> histogram;
FXL_CHECK(fidl::Clone(histogram_, &histogram) == ZX_OK);
- (*logger)->LogIntHistogram(
- metric_id(), event_code_, component_, std::move(histogram),
- [callback = callback.share()](fuchsia::cobalt::Status status) {
- callback(status);
- });
+ (*logger)->LogIntHistogram(metric_id(), event_code_, component_,
+ std::move(histogram), std::move(callback));
}
uint32_t event_code() const { return event_code_; }
const std::string& component() const { return component_; }
@@ -271,13 +242,11 @@
fit::function<void(fuchsia::cobalt::Status)> callback) {
std::vector<fuchsia::cobalt::CustomEventValue> event_values;
FXL_CHECK(fidl::Clone(event_values_, &event_values) == ZX_OK);
- (*logger)->LogCustomEvent(
- metric_id(), std::move(event_values),
- [callback = callback.share()](fuchsia::cobalt::Status status) {
- callback(status);
- });
+ (*logger)->LogCustomEvent(metric_id(), std::move(event_values),
+ std::move(callback));
}
- const std::vector<fuchsia::cobalt::CustomEventValue>& event_values() const {
+ const std::vector<fuchsia::cobalt::CustomEventValue>& event_values()
+ const {
return event_values_;
}
diff --git a/public/lib/component/cpp/testing/enclosing_environment.cc b/public/lib/component/cpp/testing/enclosing_environment.cc
index 73371a6..b75716a 100644
--- a/public/lib/component/cpp/testing/enclosing_environment.cc
+++ b/public/lib/component/cpp/testing/enclosing_environment.cc
@@ -5,8 +5,6 @@
#include "lib/component/cpp/testing/enclosing_environment.h"
#include <fuchsia/sys/cpp/fidl.h>
-#include <lib/fit/function.h>
-
#include "lib/component/cpp/testing/test_util.h"
#include "lib/fidl/cpp/clone.h"
#include "lib/fxl/logging.h"
@@ -160,7 +158,7 @@
}
}
-void EnclosingEnvironment::Kill(fit::function<void()> callback) {
+void EnclosingEnvironment::Kill(std::function<void()> callback) {
env_controller_->Kill([this, callback = std::move(callback)]() {
if (callback) {
callback();
diff --git a/public/lib/component/cpp/testing/enclosing_environment.h b/public/lib/component/cpp/testing/enclosing_environment.h
index b45b47c..c6db7c8 100644
--- a/public/lib/component/cpp/testing/enclosing_environment.h
+++ b/public/lib/component/cpp/testing/enclosing_environment.h
@@ -14,8 +14,6 @@
#include <fs/synchronous-vfs.h>
#include <fuchsia/sys/cpp/fidl.h>
#include <lib/async/default.h>
-#include <lib/fit/function.h>
-
#include "lib/component/cpp/testing/launcher_impl.h"
#include "lib/fxl/logging.h"
#include "lib/svc/cpp/services.h"
@@ -162,7 +160,7 @@
bool is_running() const { return running_; }
// Kills the underlying environment.
- void Kill(fit::function<void()> callback = nullptr);
+ void Kill(std::function<void()> callback = nullptr);
// Creates a real component from |launch_info| in underlying environment.
//
diff --git a/public/lib/component/cpp/testing/fake_launcher.h b/public/lib/component/cpp/testing/fake_launcher.h
index 7736b73..8717f0a 100644
--- a/public/lib/component/cpp/testing/fake_launcher.h
+++ b/public/lib/component/cpp/testing/fake_launcher.h
@@ -2,12 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef LIB_COMPONENT_CPP_TESTING_FAKE_LAUNCHER_H_
-#define LIB_COMPONENT_CPP_TESTING_FAKE_LAUNCHER_H_
+#ifndef LIB_APP_CPP_TESTING_FAKE_LAUNCHER_H_
+#define LIB_APP_CPP_TESTING_FAKE_LAUNCHER_H_
#include <fs/service.h>
#include <fuchsia/sys/cpp/fidl.h>
-#include <lib/fit/function.h>
#include "lib/fidl/cpp/binding.h"
@@ -25,7 +24,7 @@
FakeLauncher(const FakeLauncher&) = delete;
FakeLauncher& operator=(const FakeLauncher&) = delete;
- using ComponentConnector = fit::function<void(
+ using ComponentConnector = std::function<void(
fuchsia::sys::LaunchInfo,
fidl::InterfaceRequest<fuchsia::sys::ComponentController>)>;
@@ -56,4 +55,4 @@
} // namespace testing
} // namespace component
-#endif // LIB_COMPONENT_CPP_TESTING_FAKE_LAUNCHER_H_
+#endif // LIB_APP_CPP_TESTING_FAKE_LAUNCHER_H_
\ No newline at end of file
diff --git a/public/lib/escher/fs/hack_filesystem.h b/public/lib/escher/fs/hack_filesystem.h
index 4576516..9088ed0 100644
--- a/public/lib/escher/fs/hack_filesystem.h
+++ b/public/lib/escher/fs/hack_filesystem.h
@@ -10,8 +10,6 @@
#include <unordered_set>
#include <vector>
-#include <lib/fit/function.h>
-
#include "lib/fxl/memory/ref_counted.h"
#ifdef __Fuchsia__
@@ -29,7 +27,7 @@
using HackFilePath = std::string;
using HackFilePathSet = std::unordered_set<HackFilePath>;
class HackFilesystemWatcher;
-using HackFilesystemWatcherFunc = fit::function<void(HackFilePath)>;
+using HackFilesystemWatcherFunc = std::function<void(HackFilePath)>;
// An in-memory file system that could be watched for content change.
class HackFilesystem : public fxl::RefCountedThreadSafe<HackFilesystem> {
diff --git a/public/lib/escher/impl/command_buffer.h b/public/lib/escher/impl/command_buffer.h
index 481b24a..f4f2c84 100644
--- a/public/lib/escher/impl/command_buffer.h
+++ b/public/lib/escher/impl/command_buffer.h
@@ -8,16 +8,15 @@
#include <functional>
#include <vector>
-#include <lib/fit/function.h>
-
#include "lib/escher/forward_declarations.h"
#include "lib/escher/renderer/semaphore.h"
#include "lib/escher/scene/camera.h"
#include "lib/escher/vk/vulkan_context.h"
+
#include "lib/fxl/macros.h"
namespace escher {
-typedef fit::function<void()> CommandBufferFinishedCallback;
+typedef std::function<void()> CommandBufferFinishedCallback;
namespace impl {
diff --git a/public/lib/escher/paper/paper_shape_cache.h b/public/lib/escher/paper/paper_shape_cache.h
index 32a7e04..4d86f56 100644
--- a/public/lib/escher/paper/paper_shape_cache.h
+++ b/public/lib/escher/paper/paper_shape_cache.h
@@ -8,8 +8,6 @@
#include <functional>
#include <vector>
-#include <lib/fit/function.h>
-
#include "lib/escher/forward_declarations.h"
#include "lib/escher/geometry/types.h"
#include "lib/escher/paper/paper_renderer_config.h"
@@ -78,7 +76,7 @@
enum class ShapeType { kRect, kRoundedRect, kCircle };
// Args: array of planes to clip the generated mesh, and size of the array.
- using CacheMissMeshGenerator = fit::function<PaperShapeCacheEntry(
+ using CacheMissMeshGenerator = std::function<PaperShapeCacheEntry(
const plane3* planes, size_t num_planes)>;
// Computes a lookup key by starting with |shape_hash| and then hashing the
diff --git a/public/lib/escher/renderer/batch_gpu_uploader.cc b/public/lib/escher/renderer/batch_gpu_uploader.cc
index add9ae5..be6b237 100644
--- a/public/lib/escher/renderer/batch_gpu_uploader.cc
+++ b/public/lib/escher/renderer/batch_gpu_uploader.cc
@@ -4,8 +4,6 @@
#include "lib/escher/renderer/batch_gpu_uploader.h"
-#include <lib/fit/function.h>
-
#include "lib/escher/util/trace_macros.h"
#include "lib/escher/vk/gpu_mem.h"
#include "lib/fxl/logging.h"
@@ -259,7 +257,7 @@
void BatchGpuUploader::PostReader(
std::unique_ptr<BatchGpuUploader::Reader> reader,
- fit::function<void(escher::BufferPtr buffer)> callback) {
+ std::function<void(escher::BufferPtr buffer)> callback) {
FXL_DCHECK(frame_);
if (!reader) {
return;
@@ -278,7 +276,7 @@
reader.reset();
}
-void BatchGpuUploader::Submit(fit::function<void()> callback) {
+void BatchGpuUploader::Submit(const std::function<void()>& callback) {
if (dummy_for_tests_) {
FXL_LOG(WARNING) << "Dummy BatchGpuUploader for tests, skip submit";
return;
@@ -300,7 +298,8 @@
[callback, read_callbacks = std::move(read_callbacks_)]() {
for (auto& pair : read_callbacks) {
auto buffer = pair.first;
- pair.second(buffer);
+ auto read_callback = pair.second;
+ read_callback(buffer);
}
if (callback) {
callback();
diff --git a/public/lib/escher/renderer/batch_gpu_uploader.h b/public/lib/escher/renderer/batch_gpu_uploader.h
index 69c16a7..dc64c92 100644
--- a/public/lib/escher/renderer/batch_gpu_uploader.h
+++ b/public/lib/escher/renderer/batch_gpu_uploader.h
@@ -7,8 +7,6 @@
#include <vulkan/vulkan.hpp>
-#include <lib/fit/function.h>
-
#include "lib/escher/base/reffable.h"
#include "lib/escher/escher.h"
#include "lib/escher/forward_declarations.h"
@@ -126,7 +124,7 @@
// the host on Submit(). After submit, the callback will be called with the
// buffer read from the GPU.
void PostReader(std::unique_ptr<Reader> reader,
- fit::function<void(escher::BufferPtr buffer)> callback);
+ std::function<void(escher::BufferPtr buffer)> callback);
// The "BatchDone" Semaphore that is signaled when all posted batches are
// complete. This is non-null after the first Reader or Writer is acquired,
@@ -137,7 +135,7 @@
// Submits all Writers' and Reader's work to the GPU. No Writers or Readers
// can be posted once Submit is called.
- void Submit(fit::function<void()> callback = nullptr);
+ void Submit(const std::function<void()>& callback = nullptr);
private:
BatchGpuUploader(EscherWeakPtr weak_escher, int64_t frame_trace_number);
@@ -167,7 +165,7 @@
// provide any dummy functionality.
bool dummy_for_tests_ = false;
- std::vector<std::pair<BufferPtr, fit::function<void(BufferPtr)>>>
+ std::vector<std::pair<BufferPtr, std::function<void(BufferPtr)>>>
read_callbacks_;
FXL_DISALLOW_COPY_AND_ASSIGN(BatchGpuUploader);
diff --git a/public/lib/escher/renderer/frame.h b/public/lib/escher/renderer/frame.h
index ad4c1a4..0a6cc56 100644
--- a/public/lib/escher/renderer/frame.h
+++ b/public/lib/escher/renderer/frame.h
@@ -9,8 +9,6 @@
#include <functional>
#include <vulkan/vulkan.hpp>
-#include <lib/fit/function.h>
-
#include "lib/escher/base/reffable.h"
#include "lib/escher/forward_declarations.h"
#include "lib/escher/impl/command_buffer.h"
@@ -21,7 +19,7 @@
namespace escher {
-typedef fit::function<void()> FrameRetiredCallback;
+typedef std::function<void()> FrameRetiredCallback;
class Frame;
using FramePtr = fxl::RefPtr<Frame>;
diff --git a/public/lib/escher/util/image_utils.h b/public/lib/escher/util/image_utils.h
index 48785d0..370011d 100644
--- a/public/lib/escher/util/image_utils.h
+++ b/public/lib/escher/util/image_utils.h
@@ -27,7 +27,7 @@
fit::function<void(void*, void*, uint32_t, uint32_t)>;
#else
using ImageConversionFunction =
- fit::function<void(void*, void*, uint32_t, uint32_t)>;
+ std::function<void(void*, void*, uint32_t, uint32_t)>;
#endif
// Returns the number of bytes per pixel for the given format.
diff --git a/public/lib/escher/vk/vulkan_swapchain_helper.h b/public/lib/escher/vk/vulkan_swapchain_helper.h
index be0971a..93075da 100644
--- a/public/lib/escher/vk/vulkan_swapchain_helper.h
+++ b/public/lib/escher/vk/vulkan_swapchain_helper.h
@@ -5,8 +5,6 @@
#ifndef LIB_ESCHER_VK_VULKAN_SWAPCHAIN_HELPER_H_
#define LIB_ESCHER_VK_VULKAN_SWAPCHAIN_HELPER_H_
-#include <lib/fit/function.h>
-
#include "lib/escher/forward_declarations.h"
#include "lib/escher/vk/vulkan_swapchain.h"
@@ -14,7 +12,7 @@
class VulkanSwapchainHelper {
public:
- using DrawFrameCallback = fit::function<void(
+ using DrawFrameCallback = std::function<void(
const ImagePtr& output_image, const SemaphorePtr& render_finished)>;
VulkanSwapchainHelper(VulkanSwapchain swapchain, vk::Device device,
diff --git a/public/lib/fidl/cpp/interface_ptr_unittest.cc b/public/lib/fidl/cpp/interface_ptr_unittest.cc
index ffbf8d4..6d9950b 100644
--- a/public/lib/fidl/cpp/interface_ptr_unittest.cc
+++ b/public/lib/fidl/cpp/interface_ptr_unittest.cc
@@ -13,6 +13,7 @@
#include "lib/fidl/cpp/binding.h"
#include "lib/fidl/cpp/test/async_loop_for_test.h"
#include "lib/fidl/cpp/test/frobinator_impl.h"
+#include "lib/fxl/functional/make_copyable.h"
namespace fidl {
namespace {
@@ -262,9 +263,8 @@
EXPECT_EQ(ZX_OK, binding.Bind(ptr.NewRequest()));
std::vector<std::string> grobs;
- ptr->Grob("one", [moved = std::move(ptr), &grobs](StringPtr s) {
- grobs.push_back(s);
- });
+ ptr->Grob("one", fxl::MakeCopyable([moved = std::move(ptr), &grobs](
+ StringPtr s) { grobs.push_back(s); }));
EXPECT_FALSE(ptr.is_bound());
EXPECT_TRUE(grobs.empty());
diff --git a/public/lib/fidl/cpp/internal/pending_response.h b/public/lib/fidl/cpp/internal/pending_response.h
index 9ec2793..125a7d8 100644
--- a/public/lib/fidl/cpp/internal/pending_response.h
+++ b/public/lib/fidl/cpp/internal/pending_response.h
@@ -44,9 +44,9 @@
// called at most once among all the copies.
//
// The reason |PendingResponse| objects are copiable is so that they can be
- // held by an fit::function, which is also copyable. Typically, a
+ // held by an std::function, which is also copyable. Typically, a
// |PendingResponse| object is held as a member of another object that
- // implements operator(), which can be wrapped by fit::function.
+ // implements operator(), which can be wrapped by std::function.
PendingResponse(const PendingResponse& other);
PendingResponse& operator=(const PendingResponse& other);
@@ -77,8 +77,8 @@
private:
// This class should be small enough to fit into the inline storage for an
- // fit::function to avoid allocating additional storage when processing
- // messages. Currently, fit::function has space for three pointers.
+ // std::function to avoid allocating additional storage when processing
+ // messages. Currently, std::function has space for three pointers.
zx_txid_t txid_;
WeakStubController* weak_controller_;
};
diff --git a/public/lib/fsl/socket/blocking_drain.cc b/public/lib/fsl/socket/blocking_drain.cc
index e5e1b01..3ddd782 100644
--- a/public/lib/fsl/socket/blocking_drain.cc
+++ b/public/lib/fsl/socket/blocking_drain.cc
@@ -4,10 +4,8 @@
#include "lib/fsl/socket/blocking_drain.h"
-#include <vector>
-
-#include <lib/fit/function.h>
#include <lib/zx/socket.h>
+#include <vector>
#include "lib/fxl/logging.h"
@@ -15,7 +13,7 @@
bool BlockingDrainFrom(
zx::socket source,
- fit::function<size_t(const void*, uint32_t)> write_bytes) {
+ std::function<size_t(const void*, uint32_t)> write_bytes) {
std::vector<char> buffer(64 * 1024);
for (;;) {
size_t bytes_read;
diff --git a/public/lib/fsl/socket/blocking_drain.h b/public/lib/fsl/socket/blocking_drain.h
index e685f10..ab0eed0 100644
--- a/public/lib/fsl/socket/blocking_drain.h
+++ b/public/lib/fsl/socket/blocking_drain.h
@@ -5,11 +5,10 @@
#ifndef LIB_FSL_SOCKET_BLOCKING_DRAIN_H_
#define LIB_FSL_SOCKET_BLOCKING_DRAIN_H_
-#include <functional>
-
-#include <lib/fit/function.h>
#include <lib/zx/socket.h>
+#include <functional>
+
#include "lib/fxl/fxl_export.h"
namespace fsl {
@@ -19,7 +18,7 @@
// socket has been drained, |false| if an error occured.
FXL_EXPORT bool BlockingDrainFrom(
zx::socket source,
- fit::function<size_t(const void*, uint32_t)> write_bytes);
+ std::function<size_t(const void*, uint32_t)> write_bytes);
} // namespace fsl
diff --git a/public/lib/fsl/socket/files.cc b/public/lib/fsl/socket/files.cc
index d0e377f..b29aa4f 100644
--- a/public/lib/fsl/socket/files.cc
+++ b/public/lib/fsl/socket/files.cc
@@ -4,6 +4,7 @@
#include "lib/fsl/socket/files.h"
+#include <lib/async/cpp/wait.h>
#include <stdio.h>
#include <unistd.h>
@@ -12,9 +13,6 @@
#include <utility>
#include <vector>
-#include <lib/async/cpp/wait.h>
-#include <lib/fit/function.h>
-
#include "lib/fxl/files/file_descriptor.h"
namespace fsl {
@@ -26,7 +24,7 @@
public:
CopyToFileHandler(zx::socket source, fxl::UniqueFD destination,
async_dispatcher_t* dispatcher,
- fit::function<void(bool, fxl::UniqueFD)> callback);
+ std::function<void(bool, fxl::UniqueFD)> callback);
private:
~CopyToFileHandler();
@@ -37,7 +35,7 @@
zx::socket source_;
fxl::UniqueFD destination_;
- fit::function<void(bool, fxl::UniqueFD)> callback_;
+ std::function<void(bool, fxl::UniqueFD)> callback_;
async::WaitMethod<CopyToFileHandler, &CopyToFileHandler::OnHandleReady> wait_;
FXL_DISALLOW_COPY_AND_ASSIGN(CopyToFileHandler);
@@ -46,7 +44,7 @@
CopyToFileHandler::CopyToFileHandler(
zx::socket source, fxl::UniqueFD destination,
async_dispatcher_t* dispatcher,
- fit::function<void(bool, fxl::UniqueFD)> callback)
+ std::function<void(bool, fxl::UniqueFD)> callback)
: source_(std::move(source)),
destination_(std::move(destination)),
callback_(std::move(callback)),
@@ -106,7 +104,7 @@
public:
CopyFromFileHandler(fxl::UniqueFD source, zx::socket destination,
async_dispatcher_t* dispatcher,
- fit::function<void(bool, fxl::UniqueFD)> callback);
+ std::function<void(bool, fxl::UniqueFD)> callback);
private:
~CopyFromFileHandler();
@@ -119,7 +117,7 @@
zx::socket destination_;
async::WaitMethod<CopyFromFileHandler, &CopyFromFileHandler::OnHandleReady>
wait_;
- fit::function<void(bool, fxl::UniqueFD)> callback_;
+ std::function<void(bool, fxl::UniqueFD)> callback_;
std::vector<char> buffer_;
size_t buffer_offset_;
size_t buffer_end_;
@@ -130,7 +128,7 @@
CopyFromFileHandler::CopyFromFileHandler(
fxl::UniqueFD source, zx::socket destination,
async_dispatcher_t* dispatcher,
- fit::function<void(bool, fxl::UniqueFD)> callback)
+ std::function<void(bool, fxl::UniqueFD)> callback)
: source_(std::move(source)),
destination_(std::move(destination)),
wait_(this, destination_.get(),
@@ -195,16 +193,18 @@
} // namespace
-void CopyToFileDescriptor(zx::socket source, fxl::UniqueFD destination,
- async_dispatcher_t* dispatcher,
- fit::function<void(bool, fxl::UniqueFD)> callback) {
+void CopyToFileDescriptor(
+ zx::socket source, fxl::UniqueFD destination,
+ async_dispatcher_t* dispatcher,
+ std::function<void(bool, fxl::UniqueFD)> callback) {
new CopyToFileHandler(std::move(source), std::move(destination), dispatcher,
std::move(callback));
}
-void CopyFromFileDescriptor(fxl::UniqueFD source, zx::socket destination,
- async_dispatcher_t* dispatcher,
- fit::function<void(bool, fxl::UniqueFD)> callback) {
+void CopyFromFileDescriptor(
+ fxl::UniqueFD source, zx::socket destination,
+ async_dispatcher_t* dispatcher,
+ std::function<void(bool, fxl::UniqueFD)> callback) {
new CopyFromFileHandler(std::move(source), std::move(destination), dispatcher,
std::move(callback));
}
diff --git a/public/lib/fsl/socket/files.h b/public/lib/fsl/socket/files.h
index 696126f..03ec2fc 100644
--- a/public/lib/fsl/socket/files.h
+++ b/public/lib/fsl/socket/files.h
@@ -5,12 +5,11 @@
#ifndef LIB_FSL_SOCKET_FILES_H_
#define LIB_FSL_SOCKET_FILES_H_
-#include <functional>
-
#include <lib/async/dispatcher.h>
-#include <lib/fit/function.h>
#include <lib/zx/socket.h>
+#include <functional>
+
#include "lib/fxl/files/unique_fd.h"
#include "lib/fxl/fxl_export.h"
#include "lib/fxl/tasks/task_runner.h"
@@ -23,7 +22,7 @@
FXL_EXPORT void CopyToFileDescriptor(
zx::socket source, fxl::UniqueFD destination,
async_dispatcher_t* dispatcher,
- fit::function<void(bool /*success*/, fxl::UniqueFD /*destination*/)>
+ std::function<void(bool /*success*/, fxl::UniqueFD /*destination*/)>
callback);
// Asynchronously copies data from source file to the destination. The given
@@ -32,7 +31,8 @@
FXL_EXPORT void CopyFromFileDescriptor(
fxl::UniqueFD source, zx::socket destination,
async_dispatcher_t* dispatcher,
- fit::function<void(bool /*success*/, fxl::UniqueFD /*source*/)> callback);
+ std::function<void(bool /*success*/, fxl::UniqueFD /*source*/)>
+ callback);
} // namespace fsl
diff --git a/public/lib/fsl/socket/socket_drainer_unittest.cc b/public/lib/fsl/socket/socket_drainer_unittest.cc
index 703d149..bb70286 100644
--- a/public/lib/fsl/socket/socket_drainer_unittest.cc
+++ b/public/lib/fsl/socket/socket_drainer_unittest.cc
@@ -4,8 +4,6 @@
#include "lib/fsl/socket/socket_drainer.h"
-#include <lib/fit/function.h>
-
#include "lib/fsl/socket/strings.h"
#include "lib/gtest/test_loop_fixture.h"
@@ -16,8 +14,8 @@
class Client : public SocketDrainer::Client {
public:
- Client(fit::function<void()> available_callback,
- fit::function<void()> completion_callback)
+ Client(std::function<void()> available_callback,
+ std::function<void()> completion_callback)
: available_callback_(std::move(available_callback)),
completion_callback_(std::move(completion_callback)) {}
~Client() override {}
@@ -32,8 +30,8 @@
void OnDataComplete() override { completion_callback_(); }
std::string value_;
- fit::function<void()> available_callback_;
- fit::function<void()> completion_callback_;
+ std::function<void()> available_callback_;
+ std::function<void()> completion_callback_;
};
TEST_F(SocketDrainerTest, ReadData) {
diff --git a/public/lib/fsl/tasks/fd_waiter.h b/public/lib/fsl/tasks/fd_waiter.h
index d0a6cb4..f5f39f8 100644
--- a/public/lib/fsl/tasks/fd_waiter.h
+++ b/public/lib/fsl/tasks/fd_waiter.h
@@ -10,7 +10,6 @@
#include <lib/async/cpp/wait.h>
#include <lib/async/default.h>
#include <lib/fdio/unsafe.h>
-#include <lib/fit/function.h>
#include <zircon/types.h>
#include "lib/fxl/fxl_export.h"
@@ -28,7 +27,7 @@
// wait failed (e.g., because the file descriptor was closed during the wait),
// the first argument will be the error code and the second argument will be
// zero.
- using Callback = fit::function<void(zx_status_t, uint32_t)>;
+ using Callback = std::function<void(zx_status_t, uint32_t)>;
// Creates an asynchronous, one-shot wait for the given events on the given
// file descriptor until the given timeout. Calls |callback| when the wait
diff --git a/public/lib/fxl/files/path.cc b/public/lib/fxl/files/path.cc
index ab9cd1e..a217da5 100644
--- a/public/lib/fxl/files/path.cc
+++ b/public/lib/fxl/files/path.cc
@@ -16,8 +16,6 @@
#include <list>
#include <memory>
-#include <lib/fit/function.h>
-
#include "lib/fxl/files/directory.h"
namespace files {
@@ -41,7 +39,7 @@
}
bool ForEachEntry(int root_fd, const std::string& path,
- fit::function<bool(const std::string& path)> callback) {
+ std::function<bool(const std::string& path)> callback) {
int dir_fd = openat(root_fd, path.c_str(), O_RDONLY);
if (dir_fd == -1) {
return false;
diff --git a/public/lib/fxl/functional/bind_callback_unittest.cc b/public/lib/fxl/functional/bind_callback_unittest.cc
index bdbdea5..9aa8182 100644
--- a/public/lib/fxl/functional/bind_callback_unittest.cc
+++ b/public/lib/fxl/functional/bind_callback_unittest.cc
@@ -3,9 +3,6 @@
// found in the LICENSE file.
#include "lib/fxl/functional/bind_callback.h"
-
-#include <lib/fit/function.h>
-
#include "gtest/gtest.h"
namespace fxl {
@@ -31,7 +28,7 @@
TEST(BindCallback, UnwrapNoArgs) {
int counter = 0;
- fit::function<void()> cb;
+ std::function<void()> cb;
{
SampleBinderClass dummy(counter);
cb = BindWeakUnwrap(dummy.GetWeakPtr(), [](SampleBinderClass& sender) {
@@ -49,7 +46,7 @@
TEST(BindCallback, UnwrapArgs) {
int counter = 0;
- fit::function<void(int)> cb;
+ std::function<void(int)> cb;
{
SampleBinderClass dummy(counter);
cb = BindWeakUnwrap<int>(dummy.GetWeakPtr(),
@@ -68,7 +65,7 @@
TEST(BindCallback, BindWeakSelf) {
int counter = 0;
- fit::function<void()> cb;
+ std::function<void()> cb;
{
SampleBinderClass dummy(counter);
cb = BindWeakSelf(dummy.GetWeakPtr(), &SampleBinderClass::incrementBy, 2);
@@ -85,7 +82,7 @@
TEST(BindCallback, BindWeakPlaceHolder) {
int counter = 0;
- fit::function<void(int)> cb;
+ std::function<void(int)> cb;
{
SampleBinderClass dummy(counter);
diff --git a/public/lib/fxl/functional/cancelable_callback.h b/public/lib/fxl/functional/cancelable_callback.h
index 14d8e93..2b1d1c3 100644
--- a/public/lib/fxl/functional/cancelable_callback.h
+++ b/public/lib/fxl/functional/cancelable_callback.h
@@ -7,15 +7,13 @@
#include <functional>
-#include <lib/fit/function.h>
-
#include "lib/fxl/logging.h"
#include "lib/fxl/macros.h"
#include "lib/fxl/memory/weak_ptr.h"
namespace fxl {
-// CancelableCallback is a wrapper around fit::function that allows the
+// CancelableCallback is a wrapper around std::function that allows the
// cancellation of a callback. CancelableCallback takes a reference on the
// wrapped callback until this object is destroyed or Reset()/Cancel() are
// called.
@@ -48,7 +46,7 @@
public:
CancelableCallback() : weak_ptr_factory_(this) {}
- explicit CancelableCallback(fit::function<void(Args...)> callback)
+ explicit CancelableCallback(std::function<void(Args...)> callback)
: callback_(std::move(callback)), weak_ptr_factory_(this) {
FXL_DCHECK(callback_);
BindWrapper();
@@ -67,11 +65,11 @@
// Returns a callback that can be disabled by calling Cancel(). This returns a
// null callback if this object currently does not wrap around a callback,
// e.g. after a call to Cancel() or when in default-constructed state.
- fit::function<void(Args...)> callback() { return wrapper_.share(); }
+ const std::function<void(Args...)>& callback() const { return wrapper_; }
// Sets |callback| as the closure that may be canceled. |callback| may not be
// null. Outstanding and any previously wrapped callbacks are canceled.
- void Reset(fit::function<void(Args...)> callback) {
+ void Reset(std::function<void(Args...)> callback) {
FXL_DCHECK(callback);
Cancel();
@@ -92,10 +90,10 @@
// The closure that wraps around |callback_|. This acts as the cancelable
// closure that gets vended out to clients.
- fit::function<void(Args...)> wrapper_;
+ std::function<void(Args...)> wrapper_;
// The stored closure that may be canceled.
- fit::function<void(Args...)> callback_;
+ std::function<void(Args...)> callback_;
// Used to make sure that |wrapper_| is not run when this object is destroyed.
fxl::WeakPtrFactory<CancelableCallback> weak_ptr_factory_;
diff --git a/public/lib/fxl/functional/closure.h b/public/lib/fxl/functional/closure.h
index 0594254..dc8e032 100644
--- a/public/lib/fxl/functional/closure.h
+++ b/public/lib/fxl/functional/closure.h
@@ -7,11 +7,9 @@
#include <functional>
-#include <lib/fit/function.h>
-
namespace fxl {
-typedef fit::function<void()> Closure;
+typedef std::function<void()> Closure;
} // namespace fxl
diff --git a/public/lib/fxl/functional/make_copyable.h b/public/lib/fxl/functional/make_copyable.h
index fef5de2..6c780c9 100644
--- a/public/lib/fxl/functional/make_copyable.h
+++ b/public/lib/fxl/functional/make_copyable.h
@@ -7,8 +7,6 @@
#include <utility>
-#include <lib/fit/function.h>
-
#include "lib/fxl/memory/ref_counted.h"
#include "lib/fxl/memory/ref_ptr.h"
@@ -38,23 +36,23 @@
} // namespace internal
-// Provides a wrapper for a move-only lambda that is implicitly convertible to
-// an fit::function.
+// Provides a wrapper for a move-only lambda that is implicitly convertible to an
+// std::function.
//
-// fit::function is copyable, but if a lambda captures an argument with a
+// std::function is copyable, but if a lambda captures an argument with a
// move-only type, the lambda itself is not copyable. In order to use the lambda
-// in places that accept fit::functions, we provide a copyable object that wraps
-// the lambda and is implicitly convertible to an fit::function.
+// in places that accept std::functions, we provide a copyable object that wraps
+// the lambda and is implicitly convertible to an std::function.
//
// EXAMPLE:
//
// std::unique_ptr<Foo> foo = ...
-// fit::function<int()> func =
+// std::function<int()> func =
// fxl::MakeCopyable([bar = std::move(foo)]() { return bar->count(); });
//
// Notice that the return type of MakeCopyable is rarely used directly. Instead,
// callers typically erase the type by implicitly converting the return value
-// to an fit::function.
+// to an std::function.
template <typename T>
internal::CopyableLambda<T> MakeCopyable(T lambda) {
return internal::CopyableLambda<T>(std::move(lambda));
diff --git a/public/lib/fxl/strings/string_view_unittest.cc b/public/lib/fxl/strings/string_view_unittest.cc
index 9823246..46942f0 100644
--- a/public/lib/fxl/strings/string_view_unittest.cc
+++ b/public/lib/fxl/strings/string_view_unittest.cc
@@ -6,8 +6,6 @@
#include <functional>
-#include <lib/fit/function.h>
-
#include "gtest/gtest.h"
namespace fxl {
@@ -19,7 +17,7 @@
// Loops over all substrings of |needles|, and calls |callback| for each.
void LoopOverSubstrings(
StringView haystack, StringView needles,
- fit::function<void(std::string haystack_str, StringView haystack_sw,
+ std::function<void(std::string haystack_str, StringView haystack_sw,
std::string to_find_str, StringView to_find_sw,
int start_index)>
callback) {
@@ -39,7 +37,7 @@
// Loops over all characters in |needles|, and calls |callback| for each.
void LoopOverChars(
StringView haystack, StringView needles,
- fit::function<void(std::string haystack_str, StringView haystack_sw, char c,
+ std::function<void(std::string haystack_str, StringView haystack_sw, char c,
int start_index)>
callback) {
std::string haystack_str = haystack.ToString();
@@ -55,7 +53,7 @@
// |callback| for each.
void LoopOverCharCombinations(
StringView haystack, StringView needles,
- fit::function<void(std::string haystack_str, StringView haystack_sw,
+ std::function<void(std::string haystack_str, StringView haystack_sw,
std::string current_chars, size_t pos)>
callback) {
// Look for all chars combinations, and compare with string.
diff --git a/public/lib/json/json_parser.cc b/public/lib/json/json_parser.cc
index 0a2e7d7..aef4b39 100644
--- a/public/lib/json/json_parser.cc
+++ b/public/lib/json/json_parser.cc
@@ -12,7 +12,6 @@
#include <string>
#include <lib/fit/function.h>
-
#include "lib/fxl/files/file.h"
#include "lib/fxl/macros.h"
#include "lib/fxl/strings/join_strings.h"
@@ -23,7 +22,7 @@
namespace json {
namespace {
-using ErrorCallback = fit::function<void(size_t, const std::string&)>;
+using ErrorCallback = std::function<void(size_t, const std::string&)>;
using fxl::StringPrintf;
void GetLineAndColumnForOffset(const std::string& input, size_t offset,
diff --git a/public/lib/json/json_parser_unittest.cc b/public/lib/json/json_parser_unittest.cc
index 2d0f475..d7371ee 100644
--- a/public/lib/json/json_parser_unittest.cc
+++ b/public/lib/json/json_parser_unittest.cc
@@ -9,8 +9,6 @@
#include <functional>
#include <string>
-#include <lib/fit/function.h>
-
#include "gtest/gtest.h"
#include "lib/fxl/files/file.h"
#include "lib/fxl/files/path.h"
@@ -57,10 +55,10 @@
bool ParseFromDirectory(JSONParser* parser, const std::string& dir,
std::string* error) {
- fit::function<void(rapidjson::Document)> cb =
+ std::function<void(rapidjson::Document)> cb =
std::bind(&JSONParserTest::InterpretDocument, this, parser,
std::placeholders::_1);
- parser->ParseFromDirectory(dir, std::move(cb));
+ parser->ParseFromDirectory(dir, cb);
*error = parser->error_str();
return !parser->HasError();
}
diff --git a/public/lib/ui/sketchy/client/canvas.cc b/public/lib/ui/sketchy/client/canvas.cc
index 1a14244..25401c3 100644
--- a/public/lib/ui/sketchy/client/canvas.cc
+++ b/public/lib/ui/sketchy/client/canvas.cc
@@ -4,6 +4,8 @@
#include "lib/ui/sketchy/client/canvas.h"
+#include "lib/fxl/functional/make_copyable.h"
+
namespace sketchy_lib {
Canvas::Canvas(component::StartupContext* context, async::Loop* loop)
@@ -32,7 +34,7 @@
// it safe to continue using.
commands_.clear();
}
- canvas_->Present(time, std::move(callback));
+ canvas_->Present(time, fxl::MakeCopyable(std::move(callback)));
}
} // namespace sketchy_lib
diff --git a/public/lib/ui/tests/mocks/mock_input_device.cc b/public/lib/ui/tests/mocks/mock_input_device.cc
index 74ecda8..63863c8 100644
--- a/public/lib/ui/tests/mocks/mock_input_device.cc
+++ b/public/lib/ui/tests/mocks/mock_input_device.cc
@@ -11,11 +11,11 @@
uint32_t device_id, fuchsia::ui::input::DeviceDescriptor descriptor,
fidl::InterfaceRequest<fuchsia::ui::input::InputDevice>
input_device_request,
- OnReportCallback on_report_callback)
+ const OnReportCallback& on_report_callback)
: id_(device_id),
descriptor_(std::move(descriptor)),
input_device_binding_(this, std::move(input_device_request)),
- on_report_callback_(std::move(on_report_callback)) {}
+ on_report_callback_(on_report_callback) {}
MockInputDevice::~MockInputDevice() {}
diff --git a/public/lib/ui/tests/mocks/mock_input_device.h b/public/lib/ui/tests/mocks/mock_input_device.h
index 84db4a3..d148c3b 100644
--- a/public/lib/ui/tests/mocks/mock_input_device.h
+++ b/public/lib/ui/tests/mocks/mock_input_device.h
@@ -6,8 +6,6 @@
#define LIB_UI_TESTS_MOCKS_MOCK_INPUT_DEVICE_H_
#include <fuchsia/ui/input/cpp/fidl.h>
-#include <lib/fit/function.h>
-
#include "lib/fidl/cpp/binding.h"
#include "lib/fxl/macros.h"
@@ -15,7 +13,7 @@
namespace test {
using OnReportCallback =
- fit::function<void(fuchsia::ui::input::InputReport report)>;
+ std::function<void(fuchsia::ui::input::InputReport report)>;
class MockInputDevice : public fuchsia::ui::input::InputDevice {
public:
@@ -23,7 +21,7 @@
fuchsia::ui::input::DeviceDescriptor descriptor,
fidl::InterfaceRequest<fuchsia::ui::input::InputDevice>
input_device_request,
- OnReportCallback on_report_callback);
+ const OnReportCallback& on_report_callback);
~MockInputDevice();
uint32_t id() { return id_; }
diff --git a/public/lib/ui/tests/mocks/mock_input_device_registry.cc b/public/lib/ui/tests/mocks/mock_input_device_registry.cc
index dabda6e..a9b4d6a 100644
--- a/public/lib/ui/tests/mocks/mock_input_device_registry.cc
+++ b/public/lib/ui/tests/mocks/mock_input_device_registry.cc
@@ -8,9 +8,10 @@
namespace test {
MockInputDeviceRegistry::MockInputDeviceRegistry(
- OnDeviceCallback on_device_callback, OnReportCallback on_report_callback)
- : on_device_callback_(std::move(on_device_callback)),
- on_report_callback_(std::move(on_report_callback)) {}
+ const OnDeviceCallback on_device_callback,
+ const OnReportCallback on_report_callback)
+ : on_device_callback_(on_device_callback),
+ on_report_callback_(on_report_callback) {}
MockInputDeviceRegistry::~MockInputDeviceRegistry() {}
@@ -23,7 +24,7 @@
std::unique_ptr<MockInputDevice> input_device =
std::make_unique<MockInputDevice>(device_id, std::move(descriptor),
std::move(input_device_request),
- std::move(on_report_callback_));
+ on_report_callback_);
MockInputDevice* input_device_ptr = input_device.get();
devices_by_id_.emplace(device_id, std::move(input_device));
diff --git a/public/lib/ui/tests/mocks/mock_input_device_registry.h b/public/lib/ui/tests/mocks/mock_input_device_registry.h
index 8b69c02..f20d061 100644
--- a/public/lib/ui/tests/mocks/mock_input_device_registry.h
+++ b/public/lib/ui/tests/mocks/mock_input_device_registry.h
@@ -9,8 +9,6 @@
#include <unordered_map>
#include <fuchsia/ui/input/cpp/fidl.h>
-#include <lib/fit/function.h>
-
#include "lib/component/cpp/startup_context.h"
#include "lib/fxl/macros.h"
#include "lib/ui/tests/mocks/mock_input_device.h"
@@ -18,7 +16,7 @@
namespace mozart {
namespace test {
-using OnDeviceCallback = fit::function<void(MockInputDevice*)>;
+using OnDeviceCallback = std::function<void(MockInputDevice*)>;
class MockInputDeviceRegistry : public fuchsia::ui::input::InputDeviceRegistry {
public:
diff --git a/public/lib/ui/tests/mocks/mock_view_container_listener.cc b/public/lib/ui/tests/mocks/mock_view_container_listener.cc
index 2da7d81..3047449 100644
--- a/public/lib/ui/tests/mocks/mock_view_container_listener.cc
+++ b/public/lib/ui/tests/mocks/mock_view_container_listener.cc
@@ -13,8 +13,8 @@
MockViewContainerListener::MockViewContainerListener(
OnMockChildAttachedCallback child_attached_callback,
OnMockChildUnavailable child_unavailable_callback)
- : child_attached_callback_(std::move(child_attached_callback)),
- child_unavailable_callback_(std::move(child_unavailable_callback)) {}
+ : child_attached_callback_(child_attached_callback),
+ child_unavailable_callback_(child_unavailable_callback) {}
MockViewContainerListener::~MockViewContainerListener() {}
diff --git a/public/lib/ui/tests/mocks/mock_view_container_listener.h b/public/lib/ui/tests/mocks/mock_view_container_listener.h
index d52f377..62552d3 100644
--- a/public/lib/ui/tests/mocks/mock_view_container_listener.h
+++ b/public/lib/ui/tests/mocks/mock_view_container_listener.h
@@ -6,16 +6,14 @@
#define LIB_UI_TESTS_MOCKS_MOCK_VIEW_CONTAINER_LISTENER_H_
#include <fuchsia/ui/viewsv1/cpp/fidl.h>
-#include <lib/fit/function.h>
-
#include "lib/fxl/macros.h"
namespace mozart {
namespace test {
using OnMockChildAttachedCallback =
- fit::function<void(uint32_t, ::fuchsia::ui::viewsv1::ViewInfo)>;
-using OnMockChildUnavailable = fit::function<void(uint32_t)>;
+ std::function<void(uint32_t, ::fuchsia::ui::viewsv1::ViewInfo)>;
+using OnMockChildUnavailable = std::function<void(uint32_t)>;
class MockViewContainerListener
: public ::fuchsia::ui::viewsv1::ViewContainerListener {
diff --git a/public/lib/ui/tests/mocks/mock_view_listener.h b/public/lib/ui/tests/mocks/mock_view_listener.h
index 67af230..8c00ecc 100644
--- a/public/lib/ui/tests/mocks/mock_view_listener.h
+++ b/public/lib/ui/tests/mocks/mock_view_listener.h
@@ -6,8 +6,6 @@
#define LIB_UI_TESTS_MOCKS_MOCK_VIEW_LISTENER_H_
#include <fuchsia/ui/viewsv1/cpp/fidl.h>
-#include <lib/fit/function.h>
-
#include "lib/fxl/macros.h"
#include <functional>
@@ -16,7 +14,7 @@
namespace test {
using OnMockViewPropertiesCallback =
- fit::function<void(::fuchsia::ui::viewsv1::ViewProperties)>;
+ std::function<void(::fuchsia::ui::viewsv1::ViewProperties)>;
class MockViewListener : public ::fuchsia::ui::viewsv1::ViewListener {
public:
diff --git a/public/lib/ui/view_framework/view_provider_service.h b/public/lib/ui/view_framework/view_provider_service.h
index 7700877..530c453 100644
--- a/public/lib/ui/view_framework/view_provider_service.h
+++ b/public/lib/ui/view_framework/view_provider_service.h
@@ -9,8 +9,6 @@
#include <vector>
#include <fuchsia/ui/viewsv1/cpp/fidl.h>
-#include <lib/fit/function.h>
-
#include "lib/component/cpp/startup_context.h"
#include "lib/fidl/cpp/binding_set.h"
#include "lib/fxl/macros.h"
@@ -30,7 +28,7 @@
// A callback to create a view in response to a call to
// |ViewProvider.CreateView()|.
using ViewFactory =
- fit::function<std::unique_ptr<BaseView>(ViewContext context)>;
+ std::function<std::unique_ptr<BaseView>(ViewContext context)>;
// Publishes a view provider as an outgoing service of the application.
// The views created by the view provider are owned by it and will be destroyed