1 /* 2 * Copyright (C) 2018 The Android Open Source Project 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 17 package com.android.ahat.progress; 18 19 /** 20 * Interface for notifying users of progress during long operations. 21 */ 22 public interface Progress { 23 /** 24 * Called to indicate the start of a new phase of work with the given 25 * duration. Behavior is undefined if there is a current phase in progress. 26 * 27 * @param description human readable description of the work to be done. 28 * @param duration the maximum duration of the phase, in arbitrary units 29 * appropriate for the work in question. 30 */ start(String description, long duration)31 void start(String description, long duration); 32 33 /** 34 * Called to indicate the current phase has advanced a single unit of its 35 * overall duration towards completion. Behavior is undefined if there is no 36 * current phase in progress. 37 */ advance()38 default void advance() { 39 advance(1); 40 } 41 42 /** 43 * Called to indicate the current phase has advanced <code>n</code> units of 44 * its overall duration towards completion. Behavior is undefined if there 45 * is no current phase in progress. 46 * 47 * @param n number of units of progress that have advanced. 48 */ advance(long n)49 void advance(long n); 50 51 /** 52 * Called to indicate the current phase has completed <code>current</code> 53 * absolute units of its overall duration. Behavior is undefined if there is 54 * no current phase in progress. 55 * 56 * @param current progress towards duration 57 */ update(long current)58 void update(long current); 59 60 /** 61 * Called to indicates that the current phase has been completed. Behavior 62 * is undefined if there is no current phase in progress. 63 */ done()64 void done(); 65 } 66