// Copyright 2019 The Chromium Authors. All rights reserved.
// 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 optimization_guide.proto;

import "hints.proto";

// The types of StoreEntries.
//
// The values should match those of
// components/previews/content/hint_cache_store.h
enum StoreEntryType {
  // StoreEntryType when the entry type is unknown.
  EMPTY = 0;
  // StoreEntryType when storing a metadata entry, which holds metadata about
  // the store and the set of entries for a particular source, fetched or
  // component.
  METADATA = 1;
  // StoreEntryType when storing a component hint entry, holds a hint that was
  // provided by a component update. The version should be provided.
  COMPONENT_HINT = 2;
  // StoreEntryType when storing a fetched hint entry, holds a hint that was
  // fetched from the remote Optimization Guide Service. |update_time_secs|
  // should be provided.
  FETCHED_HINT = 3;
}

message StoreEntry {
  // Generic version field. For the schema metadata entry, version represents
  // the schema version; for the component metadata entry, version represents
  // the component version.
  optional string version = 1;
  // The actual hint data.
  optional Hint hint = 2;
  // Time when top host fetched hints are still usable but update should
  // be requested. This is set on the fetched metadata entry.
  optional int64 update_time_secs = 3;
  // The type of entry stored.
  optional StoreEntryType entry_type = 4;
  // Expiry time for this Hint entry (i.e., when hint is no longer usable).
  // This is set on OnePlatform Hint entries.
  optional int64 expiry_time_secs = 5;
}
