chromium/components/image_fetcher/core/cache/proto/cached_image_metadata.proto

// 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.

syntax = "proto2";

option optimize_for = LITE_RUNTIME;

package image_fetcher;

// Controls how cached image fetcher manages disk cache files. Maps to
// CacheOption enum in cpp.
enum CacheStrategy {
  // If reached storage space limit, the cache file may be deleted based on LRU
  // eviction. The cache files also have a default expiration time after
  // |creation_time|.
  BEST_EFFORT = 0;

  // The cache file will be deleted after an |expiration_interval| after
  // |last_used_time|.
  HOLD_UNTIL_EXPIRED = 1;
}

message CachedImageMetadataProto {
  // The key for the source image.
  optional string key = 1;

  // The time which the entry was created at. Used for garbage collection.
  optional int64 creation_time = 2;

  // The time which the entry was last used. Used for LRU eviction. This time
  // won't always be updated, such as if the cache is in a read-only mode.
  optional int64 last_used_time = 3;

  // Size of the image data. Used to decide when to stop evictions after a
  // certain amount of space has been freed. Is not used to decide the order in
  // which images are evicted.
  optional int64 data_size = 4;

  // True if the image data needs transcoding before it can be trusted.
  optional bool needs_transcoding = 5;

  // The cache strategy used to control the cache file lifecycle.
  optional CacheStrategy cache_strategy = 6 [default = BEST_EFFORT];

  // The expiration interval since |last_used_time| to delete the cache file for
  // CacheStrategy::HOLD_UNTIL_EXPIRED. Measured in microseconds.
  optional int64 expiration_interval = 7;
}