• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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 package com.google.android.exoplayer2.upstream;
17 
18 import com.google.android.exoplayer2.upstream.Loader.Loadable;
19 import java.io.IOException;
20 
21 /**
22  * Conditionally throws errors affecting a {@link Loader}.
23  */
24 public interface LoaderErrorThrower {
25 
26   /**
27    * Throws a fatal error, or a non-fatal error if loading is currently backed off and the current
28    * {@link Loadable} has incurred a number of errors greater than the {@link Loader}s default
29    * minimum number of retries. Else does nothing.
30    *
31    * @throws IOException The error.
32    */
maybeThrowError()33   void maybeThrowError() throws IOException;
34 
35   /**
36    * Throws a fatal error, or a non-fatal error if loading is currently backed off and the current
37    * {@link Loadable} has incurred a number of errors greater than the specified minimum number
38    * of retries. Else does nothing.
39    *
40    * @param minRetryCount A minimum retry count that must be exceeded for a non-fatal error to be
41    *     thrown. Should be non-negative.
42    * @throws IOException The error.
43    */
maybeThrowError(int minRetryCount)44   void maybeThrowError(int minRetryCount) throws IOException;
45 
46   /**
47    * A {@link LoaderErrorThrower} that never throws.
48    */
49   final class Dummy implements LoaderErrorThrower {
50 
51     @Override
maybeThrowError()52     public void maybeThrowError() {
53       // Do nothing.
54     }
55 
56     @Override
maybeThrowError(int minRetryCount)57     public void maybeThrowError(int minRetryCount) {
58       // Do nothing.
59     }
60   }
61 
62 }
63