mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-06-17 18:46:21 +08:00
Summary: Sometimes, when we deal with ImageRequest and ImageResponseObserverCoordinator we subscribe for status (or access the coordinator) without owning an ImageRequest. In those cases, we have to retain the coordinator explicitly. For those cases, ImageRequest now exposes `ImageResponseObserverCoordinator` as a `std::shared_ptr`. Eg, concretely in the code, `completionBlock` and `progressBlock` copied a raw pointer to the observer inside which can lead to a crash when ImageRequest is being deallocated before we received an image data. Reviewed By: JoshuaGross Differential Revision: D14072079 fbshipit-source-id: e10120bc05bf685e288f7b3d69092714dcd91d43
41 lines
943 B
C++
41 lines
943 B
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)
|
|
: imageSource_(imageSource) {
|
|
// Not implemented.
|
|
}
|
|
|
|
ImageRequest::ImageRequest(ImageRequest &&other) noexcept
|
|
: imageSource_(std::move(other.imageSource_)),
|
|
coordinator_(std::move(other.coordinator_)) {
|
|
// Not implemented.
|
|
}
|
|
|
|
ImageRequest::~ImageRequest() {
|
|
// Not implemented.
|
|
}
|
|
|
|
const ImageResponseObserverCoordinator &ImageRequest::getObserverCoordinator()
|
|
const {
|
|
// Not implemented
|
|
abort();
|
|
}
|
|
|
|
const std::shared_ptr<const ImageResponseObserverCoordinator>
|
|
&ImageRequest::getSharedObserverCoordinator() const {
|
|
// Not implemented
|
|
abort();
|
|
}
|
|
} // namespace react
|
|
} // namespace facebook
|