chromium/components/image_fetcher/core/cache/image_cache.cc

// Copyright 2018 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/image_fetcher/core/cache/image_cache.h"

#include <algorithm>
#include <utility>

#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/hash/sha1.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/time/clock.h"
#include "base/time/time.h"
#include "components/base32/base32.h"
#include "components/image_fetcher/core/cache/image_data_store.h"
#include "components/image_fetcher/core/cache/image_metadata_store.h"
#include "components/image_fetcher/core/image_fetcher_metrics_reporter.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"

namespace {

constexpr char kPrefLastStartupEviction[] =;

constexpr char kPrefLastLRUEviction[] =;

// TODO(wylieb): Control these parameters server-side.
constexpr int kCacheMaxSize =;         // 64mb.
constexpr int kCacheResizeWhenFull =;  // 48mb.

// Cache items are allowed to live for the given amount of days.
constexpr int kCacheItemsTimeToLiveDays =;
constexpr int kImageCacheEvictionIntervalHours =;

void OnStartupEvictionQueued() {}

}  // namespace

namespace image_fetcher {

// static
std::string ImageCache::HashUrlToKey(const std::string& input) {}

// static
void ImageCache::RegisterProfilePrefs(PrefRegistrySimple* registry) {}

ImageCache::ImageCache(std::unique_ptr<ImageDataStore> data_store,
                       std::unique_ptr<ImageMetadataStore> metadata_store,
                       PrefService* pref_service,
                       base::Clock* clock,
                       scoped_refptr<base::SequencedTaskRunner> task_runner)
    :{}

ImageCache::~ImageCache() = default;

void ImageCache::SaveImage(std::string url,
                           std::string image_data,
                           bool needs_transcoding,
                           ExpirationInterval expiration_interval) {}

void ImageCache::LoadImage(bool read_only,
                           std::string url,
                           ImageDataCallback callback) {}

void ImageCache::DeleteImage(std::string url) {}

void ImageCache::QueueOrStartRequest(base::OnceClosure request) {}

void ImageCache::MaybeStartInitialization() {}

bool ImageCache::AreAllDependenciesInitialized() const {}

void ImageCache::OnDependencyInitialized() {}

void ImageCache::SaveImageImpl(const std::string& url,
                               std::string image_data,
                               bool needs_transcoding,
                               ExpirationInterval expiration_interval) {}

void ImageCache::LoadImageImpl(bool read_only,
                               const std::string& url,
                               ImageDataCallback callback) {}

void ImageCache::OnImageMetadataLoadedForLoadImage(
    bool read_only,
    const std::string& key,
    ImageDataCallback callback,
    base::TimeTicks start_time,
    std::optional<CachedImageMetadataProto> metadata) {}

void ImageCache::DeleteImageImpl(const std::string& url) {}

void ImageCache::RunEvictionOnStartup() {}

void ImageCache::RunEvictionWhenFull() {}

void ImageCache::RunEviction(size_t bytes_left,
                             base::OnceClosure on_completion) {}

void ImageCache::OnKeysEvicted(base::OnceClosure on_completion,
                               std::vector<std::string> keys) {}

void ImageCache::RunReconciliation() {}

void ImageCache::ReconcileMetadataKeys(std::vector<std::string> metadata_keys) {}

void ImageCache::ReconcileDataKeys(std::vector<std::string> metadata_keys,
                                   std::vector<std::string> data_keys) {}

}  // namespace image_fetcher