/* * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.android.libraries.mobiledatadownload.internal; import com.google.android.libraries.mobiledatadownload.internal.collect.GroupKeyAndGroup; import com.google.common.util.concurrent.ListenableFuture; import com.google.mobiledatadownload.internal.MetadataProto.DataFileGroupInternal; import com.google.mobiledatadownload.internal.MetadataProto.GroupKey; import com.google.mobiledatadownload.internal.MetadataProto.GroupKeyProperties; import java.util.List; import org.checkerframework.checker.nullness.compatqual.NullableType; /** Stores and provides access to file group metadata. */ public interface FileGroupsMetadata { /** * Makes any changes that should be made before accessing the internal state of this store. * *
Other methods in this class do not call or check if this method was already called before
* trying to access internal state. It is expected from the caller to call this before anything
* else.
*/
ListenableFuture> getAllGroupKeys();
/**
* Retrieves all groups in metadata. Will ignore groups that are unable to parse.
*
* @return A future resolving to a list containing pairs of serialized GroupKeys and the
* corresponding DataFileGroups.
*/
ListenableFuture
> getAllFreshGroups();
/**
* Removes all entries with a key in keys from the SharedPreferencesFileGroupsMetadata's storage.
* This method doesn't take care of garbage collecting any files used by this group, and that is
* left for the caller to do.
*
* @param keys - the list of keys to remove entries for
* @return - true if the removals were successfully persisted to disk.
*/
ListenableFuture
> getAllStaleGroups();
/**
* Adds file group to list of file groups to unsubscribe from when their TTLs expire. This method
* will set the staleExpirationDate field on the file group.
*
* @param fileGroup - a file group that is no longer needed (and should release all of its files
* once its TTL expires). The staleLifetimeSecs field must be set.
* @return future resolving to false if an IO error occurs
*/
ListenableFuture