mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
d4e1202b4e
Summary: * Create `ImageTelemetry` as a property of ImageRequest to pass image metadata from the ImageShadowNode into RCTImageComponentView * ImageRequest is a object in the ImageShadowNode::ConcreteState Reviewed By: fkgozali Differential Revision: D23239664 fbshipit-source-id: db0f08bb889af8ce63fbe1abe88744edddb86150
72 lines
1.9 KiB
C++
72 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include "ImageRequest.h"
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
ImageRequest::ImageRequest(
|
|
const ImageSource &imageSource,
|
|
std::shared_ptr<const ImageTelemetry> telemetry,
|
|
std::shared_ptr<const ImageInstrumentation> instrumentation)
|
|
: imageSource_(imageSource),
|
|
telemetry_(telemetry),
|
|
instrumentation_(instrumentation) {
|
|
coordinator_ = std::make_shared<ImageResponseObserverCoordinator>();
|
|
}
|
|
|
|
ImageRequest::ImageRequest(ImageRequest &&other) noexcept
|
|
: imageSource_(std::move(other.imageSource_)),
|
|
telemetry_(std::move(other.telemetry_)),
|
|
coordinator_(std::move(other.coordinator_)),
|
|
instrumentation_(std::move(other.instrumentation_)) {
|
|
other.moved_ = true;
|
|
other.coordinator_ = nullptr;
|
|
other.cancelRequest_ = nullptr;
|
|
other.telemetry_ = nullptr;
|
|
other.instrumentation_ = nullptr;
|
|
}
|
|
|
|
ImageRequest::~ImageRequest() {
|
|
if (cancelRequest_) {
|
|
cancelRequest_();
|
|
}
|
|
}
|
|
|
|
void ImageRequest::setCancelationFunction(
|
|
std::function<void(void)> cancelationFunction) {
|
|
cancelRequest_ = cancelationFunction;
|
|
}
|
|
|
|
const std::shared_ptr<const ImageTelemetry> &ImageRequest::getSharedTelemetry()
|
|
const {
|
|
return telemetry_;
|
|
}
|
|
|
|
const ImageResponseObserverCoordinator &ImageRequest::getObserverCoordinator()
|
|
const {
|
|
return *coordinator_;
|
|
}
|
|
|
|
const std::shared_ptr<const ImageResponseObserverCoordinator>
|
|
&ImageRequest::getSharedObserverCoordinator() const {
|
|
return coordinator_;
|
|
}
|
|
|
|
const std::shared_ptr<const ImageInstrumentation>
|
|
&ImageRequest::getSharedImageInstrumentation() const {
|
|
return instrumentation_;
|
|
}
|
|
|
|
const ImageInstrumentation &ImageRequest::getImageInstrumentation() const {
|
|
return *instrumentation_;
|
|
}
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|