chromium/components/image_fetcher/core/cache/image_metadata_store_leveldb.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_metadata_store_leveldb.h"

#include <algorithm>
#include <utility>

#include "base/functional/bind.h"
#include "base/system/sys_info.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/clock.h"
#include "base/time/time.h"
#include "components/image_fetcher/core/cache/proto/cached_image_metadata.pb.h"
#include "components/image_fetcher/core/image_fetcher_metrics_reporter.h"
#include "components/leveldb_proto/public/proto_database_provider.h"

CachedImageMetadataProto;

// TODO(wylieb): Emit a histogram for various failure cases. Find a way to
// share it with other implementations.
namespace image_fetcher {

namespace {

leveldb::ReadOptions CreateReadOptions() {}

int64_t ToDatabaseTime(base::Time time) {}

CacheOption ToCacheOption(CacheStrategy cache_strategy) {}

// The folder where the data will be stored on disk.
const char kImageDatabaseFolder[] =;

// Most writes are very small, <100 bytes. This should buffer a handful of them
// together, but not much more. This should allow a handful of them to be
// buffered together without causing a significant impact to memory.
const size_t kDatabaseWriteBufferSizeBytes =;  // 1KB

bool KeyMatcherFilter(std::string key, const std::string& other_key) {}

bool SortByLastUsedTime(const CachedImageMetadataProto* a,
                        const CachedImageMetadataProto* b) {}

}  // namespace

MetadataKeyEntryVector;

ImageMetadataStoreLevelDB::ImageMetadataStoreLevelDB(
    leveldb_proto::ProtoDatabaseProvider* proto_database_provider,
    const base::FilePath& database_dir,
    scoped_refptr<base::SequencedTaskRunner> task_runner,
    base::Clock* clock)
    :{}

ImageMetadataStoreLevelDB::ImageMetadataStoreLevelDB(
    std::unique_ptr<leveldb_proto::ProtoDatabase<CachedImageMetadataProto>>
        database,
    base::Clock* clock)
    :{}

ImageMetadataStoreLevelDB::~ImageMetadataStoreLevelDB() = default;

void ImageMetadataStoreLevelDB::Initialize(base::OnceClosure callback) {}

bool ImageMetadataStoreLevelDB::IsInitialized() {}

void ImageMetadataStoreLevelDB::LoadImageMetadata(
    const std::string& key,
    ImageMetadataCallback callback) {}

void ImageMetadataStoreLevelDB::SaveImageMetadata(
    const std::string& key,
    const size_t data_size,
    bool needs_transcoding,
    ExpirationInterval expiration_interval) {}

void ImageMetadataStoreLevelDB::DeleteImageMetadata(const std::string& key) {}

void ImageMetadataStoreLevelDB::UpdateImageMetadata(const std::string& key) {}

void ImageMetadataStoreLevelDB::GetAllKeys(KeysCallback callback) {}

int64_t ImageMetadataStoreLevelDB::GetEstimatedSize(CacheOption cache_option) {}

void ImageMetadataStoreLevelDB::EvictImageMetadata(base::Time expiration_time,
                                                   const size_t bytes_left,
                                                   KeysCallback callback) {}

void ImageMetadataStoreLevelDB::OnDatabaseInitialized(
    base::OnceClosure callback,
    leveldb_proto::Enums::InitStatus status) {}

void ImageMetadataStoreLevelDB::LoadImageMetadataImpl(
    ImageMetadataCallback callback,
    bool success,
    std::unique_ptr<std::vector<CachedImageMetadataProto>> entries) {}

void ImageMetadataStoreLevelDB::OnImageUpdated(bool success) {}

void ImageMetadataStoreLevelDB::UpdateImageMetadataImpl(
    bool success,
    std::unique_ptr<std::vector<CachedImageMetadataProto>> entries) {}

void ImageMetadataStoreLevelDB::GetAllKeysImpl(
    KeysCallback callback,
    bool success,
    std::unique_ptr<std::vector<std::string>> keys) {}

void ImageMetadataStoreLevelDB::EvictImageMetadataImpl(
    base::Time expiration_time,
    const size_t bytes_left,
    KeysCallback callback,
    bool success,
    std::unique_ptr<std::vector<CachedImageMetadataProto>> entries) {}

void ImageMetadataStoreLevelDB::GetMetadataToRemove(
    CacheOption cache_option,
    std::vector<const CachedImageMetadataProto*> entries,
    base::Time expiration_time,
    const size_t bytes_left,
    std::vector<std::string>* keys_to_remove) {}

void ImageMetadataStoreLevelDB::OnEvictImageMetadataDone(
    KeysCallback callback,
    std::vector<std::string> deleted_keys,
    bool success) {}

}  // namespace image_fetcher