chromium/components/favicon/core/large_icon_worker.cc

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

#include "components/favicon/core/large_icon_worker.h"

#include <vector>

#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h"
#include "base/task/task_runner.h"
#include "base/task/thread_pool.h"
#include "components/favicon/core/favicon_service.h"
#include "components/favicon_base/fallback_icon_style.h"
#include "skia/ext/image_operations.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/geometry/size.h"

namespace favicon {

// The resized and decoded images generated from LargeIconService are sometimes
// (but not always) shown to the user, so the task priority was increased from
// BEST_EFFORT to USER_VISIBLE. If this potentially expensive change causes any
// issues, enable the kill switch below.
BASE_FEATURE();

NoBigEnoughIconBehavior;

namespace {

bool ShouldReturnBitmap(const favicon_base::FaviconRawBitmapResult& db_result,
                        int min_source_size,
                        NoBigEnoughIconBehavior no_big_enough_icon_behavior) {}

// Wraps the PNG data in `db_result` in a gfx::Image. If `desired_size` is not
// 0, the image gets decoded and resized to `desired_size` (in px). Must run on
// a background thread in production.
gfx::Image ResizeLargeIconOnBackgroundThread(
    const favicon_base::FaviconRawBitmapResult& db_result,
    int desired_size) {}

// Processes the `db_result` and writes the result into `raw_result` if
// `raw_result` is not nullptr or to `bitmap`, otherwise. If `db_result` is not
// valid or is smaller than `min_source_size`, the resulting fallback style is
// written into `fallback_icon_style`.
void ProcessIconOnBackgroundThread(
    const favicon_base::FaviconRawBitmapResult& db_result,
    int min_source_size,
    int size_to_resize_to,
    LargeIconService::NoBigEnoughIconBehavior no_big_enough_icon_behavior,
    favicon_base::FaviconRawBitmapResult* raw_result,
    SkBitmap* bitmap,
    GURL* icon_url,
    std::unique_ptr<favicon_base::FallbackIconStyle>* fallback_icon_style) {}

}  // namespace

LargeIconWorker::LargeIconWorker(
    int min_source_size_in_pixel,
    int size_in_pixel_to_resize_to,
    NoBigEnoughIconBehavior no_big_enough_icon_behavior,
    favicon_base::LargeIconCallback raw_bitmap_callback,
    favicon_base::LargeIconImageCallback image_callback,
    base::CancelableTaskTracker* tracker)
    :{}

LargeIconWorker::~LargeIconWorker() = default;

void LargeIconWorker::OnIconLookupComplete(
    const favicon_base::FaviconRawBitmapResult& db_result) {}

// static
base::CancelableTaskTracker::TaskId LargeIconWorker::GetLargeIconRawBitmap(
    FaviconService* favicon_service,
    const GURL& page_url,
    int min_source_size_in_pixel,
    int size_in_pixel_to_resize_to,
    NoBigEnoughIconBehavior no_big_enough_icon_behavior,
    favicon_base::LargeIconCallback raw_bitmap_callback,
    favicon_base::LargeIconImageCallback image_callback,
    base::CancelableTaskTracker* tracker) {}

void LargeIconWorker::OnIconProcessingComplete() {}

}  // namespace favicon