chromium/chrome/browser/bitmap_fetcher/bitmap_fetcher_service.cc

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

#include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h"

#include <stddef.h>

#include <memory>
#include <utility>

#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/metrics/field_trial_params.h"
#include "base/not_fatal_until.h"
#include "build/build_config.h"
#include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h"
#include "chrome/browser/image_decoder/image_decoder.h"
#include "chrome/browser/profiles/profile.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "components/omnibox/common/omnibox_features.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "net/base/load_flags.h"
#include "services/data_decoder/public/cpp/data_decoder.h"
#include "third_party/skia/include/core/SkBitmap.h"

namespace {

const size_t kMaxRequests =;  // Maximum number of inflight requests allowed.

// Maximum number of cache entries. This was 5 before, which worked well enough
// for few images like weather answers, but with rich entity suggestions showing
// several images at once, even changing some while the user types, a larger
// cache is necessary to avoid flickering. Each cache entry is expected to take
// 16kb (64x64 @ 32bpp).  With 16, the total memory consumed would be ~256kb.
// 16 is double the default number of maximum suggestions so this can
// accommodate one match image plus one answer image for each result.
#if BUILDFLAG(IS_ANDROID)
// Android caches the images in the java layer.
const int kMaxCacheEntries = 0;
#else
const int kMaxCacheEntries =;
#endif

constexpr net::NetworkTrafficAnnotationTag kTrafficAnnotation =;

}  // namespace.

class BitmapFetcherRequest {};

BitmapFetcherRequest::BitmapFetcherRequest(
    BitmapFetcherService::RequestId request_id,
    BitmapFetcherService::BitmapFetchedCallback callback)
    :{}

BitmapFetcherRequest::~BitmapFetcherRequest() = default;

void BitmapFetcherRequest::NotifyImageChanged(const SkBitmap* bitmap) {}

BitmapFetcherService::CacheEntry::CacheEntry() = default;

BitmapFetcherService::CacheEntry::~CacheEntry() = default;

BitmapFetcherService::BitmapFetcherService(content::BrowserContext* context)
    :{}

BitmapFetcherService::~BitmapFetcherService() {}

void BitmapFetcherService::CancelRequest(int request_id) {}

BitmapFetcherService::RequestId BitmapFetcherService::RequestImageForTesting(
    const GURL& url,
    BitmapFetchedCallback callback,
    const net::NetworkTrafficAnnotationTag& traffic_annotation) {}

BitmapFetcherService::RequestId BitmapFetcherService::RequestImageImpl(
    const GURL& url,
    BitmapFetchedCallback callback,
    const net::NetworkTrafficAnnotationTag& traffic_annotation) {}

void BitmapFetcherService::Prefetch(const GURL& url) {}

bool BitmapFetcherService::IsCached(const GURL& url) {}

std::unique_ptr<BitmapFetcher> BitmapFetcherService::CreateFetcher(
    const GURL& url,
    const net::NetworkTrafficAnnotationTag& traffic_annotation) {}

BitmapFetcherService::RequestId BitmapFetcherService::RequestImage(
    const GURL& url,
    BitmapFetchedCallback callback) {}

const BitmapFetcher* BitmapFetcherService::EnsureFetcherForUrl(
    const GURL& url,
    const net::NetworkTrafficAnnotationTag& traffic_annotation) {}

const BitmapFetcher* BitmapFetcherService::FindFetcherForUrl(const GURL& url) {}

void BitmapFetcherService::RemoveFetcher(const BitmapFetcher* fetcher) {}

void BitmapFetcherService::OnFetchComplete(const GURL& url,
                                           const SkBitmap* bitmap) {}