chromium/services/data_decoder/public/cpp/decode_image.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "services/data_decoder/public/cpp/decode_image.h"

#include <utility>

#include "base/debug/dump_without_crashing.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/metrics/histogram_functions.h"
#include "base/time/time.h"
#include "base/timer/elapsed_timer.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/data_decoder/public/cpp/data_decoder.h"
#include "skia/ext/skia_utils_base.h"
#include "third_party/skia/include/core/SkBitmap.h"

namespace data_decoder {

namespace {

// Helper which wraps the original `callback` while also:
// 1) owning a mojo::Remote<ImageDecoder>
// 2) measuring and recording the end-to-end duration
// 3) calculating and recording the process+ipc overhead
void OnDecodeImage(mojo::Remote<mojom::ImageDecoder> decoder,
                   DecodeImageCallback callback,
                   const std::string& uma_name_prefix,
                   base::ElapsedTimer timer,
                   base::TimeDelta image_decoding_time,
                   const SkBitmap& bitmap) {}

// Helper which wraps the original `callback` while also owning and keeping
// alive a mojo::Remote<ImageDecoder>.
void OnDecodeImages(mojo::Remote<mojom::ImageDecoder> decoder,
                    mojom::ImageDecoder::DecodeAnimationCallback callback,
                    std::vector<mojom::AnimationFramePtr> bitmaps) {}

void DecodeImageUsingServiceProcess(DataDecoder* data_decoder,
                                    base::span<const uint8_t> encoded_bytes,
                                    mojom::ImageCodec codec,
                                    bool shrink_to_fit,
                                    uint64_t max_size_in_bytes,
                                    const gfx::Size& desired_image_frame_size,
                                    DecodeImageCallback callback,
                                    const std::string& uma_name_prefix,
                                    base::ElapsedTimer timer) {}

}  // namespace

void DecodeImageIsolated(base::span<const uint8_t> encoded_bytes,
                         mojom::ImageCodec codec,
                         bool shrink_to_fit,
                         uint64_t max_size_in_bytes,
                         const gfx::Size& desired_image_frame_size,
                         DecodeImageCallback callback) {}

void DecodeImage(DataDecoder* data_decoder,
                 base::span<const uint8_t> encoded_bytes,
                 mojom::ImageCodec codec,
                 bool shrink_to_fit,
                 uint64_t max_size_in_bytes,
                 const gfx::Size& desired_image_frame_size,
                 DecodeImageCallback callback) {}

void DecodeAnimationIsolated(
    base::span<const uint8_t> encoded_bytes,
    bool shrink_to_fit,
    uint64_t max_size_in_bytes,
    mojom::ImageDecoder::DecodeAnimationCallback callback) {}

void DecodeAnimation(DataDecoder* data_decoder,
                     base::span<const uint8_t> encoded_bytes,
                     bool shrink_to_fit,
                     uint64_t max_size_in_bytes,
                     mojom::ImageDecoder::DecodeAnimationCallback callback) {}

}  // namespace data_decoder