#include "chrome/browser/image_decoder/image_decoder.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "ipc/ipc_channel.h"
#include "services/data_decoder/public/cpp/data_decoder.h"
#include "services/data_decoder/public/cpp/decode_image.h"
#include "third_party/skia/include/core/SkBitmap.h"
namespace {
const int64_t kMaxImageSizeInBytes = …;
void OnDecodeImageDone(
base::OnceCallback<void(int)> fail_callback,
base::OnceCallback<void(const SkBitmap&, int)> success_callback,
int request_id,
const SkBitmap& image) { … }
void RunDecodeCallbackOnTaskRunner(
data_decoder::DecodeImageCallback callback,
scoped_refptr<base::SequencedTaskRunner> task_runner,
const SkBitmap& image) { … }
template <typename ImageDataType>
void DecodeImage(ImageDataType image_data,
data_decoder::mojom::ImageCodec codec,
bool shrink_to_fit,
const gfx::Size& desired_image_frame_size,
data_decoder::DecodeImageCallback callback,
scoped_refptr<base::SequencedTaskRunner> callback_task_runner,
data_decoder::DataDecoder* data_decoder) { … }
}
ImageDecoder::ImageRequest::ImageRequest()
: … { … }
ImageDecoder::ImageRequest::ImageRequest(
const scoped_refptr<base::SequencedTaskRunner>& task_runner)
: … { … }
ImageDecoder::ImageRequest::ImageRequest(
data_decoder::DataDecoder* data_decoder)
: … { … }
ImageDecoder::ImageRequest::~ImageRequest() { … }
ImageDecoder* ImageDecoder::GetInstance() { … }
template <typename ImageDataType>
void ImageDecoder::Start(ImageRequest* image_request,
ImageDataType image_data) { … }
template void ImageDecoder::Start(ImageRequest*, std::vector<uint8_t>);
template void ImageDecoder::Start(ImageRequest*, std::string);
template <typename ImageDataType>
void ImageDecoder::StartWithOptions(ImageRequest* image_request,
ImageDataType image_data,
ImageCodec image_codec,
bool shrink_to_fit,
const gfx::Size& desired_image_frame_size) { … }
template void ImageDecoder::StartWithOptions(ImageRequest*,
std::vector<uint8_t>,
ImageCodec,
bool,
const gfx::Size&);
template void ImageDecoder::StartWithOptions(ImageRequest*,
std::string,
ImageCodec,
bool,
const gfx::Size&);
ImageDecoder::ImageDecoder() : … { … }
template <typename ImageDataType>
void ImageDecoder::StartWithOptionsImpl(
ImageRequest* image_request,
ImageDataType image_data,
ImageCodec image_codec,
bool shrink_to_fit,
const gfx::Size& desired_image_frame_size) { … }
template void ImageDecoder::StartWithOptionsImpl(ImageRequest*,
std::vector<uint8_t>,
ImageCodec,
bool,
const gfx::Size&);
template void ImageDecoder::StartWithOptionsImpl(ImageRequest*,
std::string,
ImageCodec,
bool,
const gfx::Size&);
void ImageDecoder::Cancel(ImageRequest* image_request) { … }
void ImageDecoder::CancelImpl(ImageRequest* image_request) { … }
void ImageDecoder::OnDecodeImageSucceeded(const SkBitmap& decoded_image,
int request_id) { … }
void ImageDecoder::OnDecodeImageFailed(int request_id) { … }