1 /* 2 * Copyright 2022 Google LLC 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.google.android.libraries.mobiledatadownload.internal.logging; 17 18 import static com.google.common.util.concurrent.Futures.immediateFuture; 19 import static com.google.common.util.concurrent.Futures.immediateVoidFuture; 20 21 import com.google.common.base.Optional; 22 import com.google.common.collect.ImmutableList; 23 import com.google.common.util.concurrent.ListenableFuture; 24 import com.google.mobiledatadownload.internal.MetadataProto.FileGroupLoggingState; 25 import com.google.mobiledatadownload.internal.MetadataProto.SamplingInfo; 26 import java.util.List; 27 28 /** LoggingStateStore that returns empty or void for all operations. */ 29 public final class NoOpLoggingState implements LoggingStateStore { 30 NoOpLoggingState()31 public NoOpLoggingState() {} 32 33 @Override getAndResetDaysSinceLastMaintenance()34 public ListenableFuture<Optional<Integer>> getAndResetDaysSinceLastMaintenance() { 35 return immediateFuture(Optional.absent()); 36 } 37 38 @Override incrementDataUsage(FileGroupLoggingState unused)39 public ListenableFuture<Void> incrementDataUsage(FileGroupLoggingState unused) { 40 return immediateVoidFuture(); 41 } 42 43 @Override getAndResetAllDataUsage()44 public ListenableFuture<List<FileGroupLoggingState>> getAndResetAllDataUsage() { 45 return immediateFuture(ImmutableList.of()); 46 } 47 48 @Override clear()49 public ListenableFuture<Void> clear() { 50 return immediateVoidFuture(); 51 } 52 53 @Override getStableSamplingInfo()54 public ListenableFuture<SamplingInfo> getStableSamplingInfo() { 55 return immediateFuture(SamplingInfo.getDefaultInstance()); 56 } 57 } 58