1 /*
2  * Copyright (C) 2012 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 org.robolectric.android.fakes;
18 
19 import java.net.CacheResponse;
20 import java.net.HttpURLConnection;
21 
22 /**
23  * A response cache that supports statistics tracking and updating stored
24  * responses. Implementations of {@link java.net.ResponseCache} should implement this
25  * interface to receive additional support from the HTTP engine.
26  */
27 public interface RoboExtendedResponseCache {
28 
29   /**
30    * Track an HTTP response being satisfied by {@code source}.
31    *
32    * @param source Response source.
33    */
trackResponse(RoboResponseSource source)34   void trackResponse(RoboResponseSource source);
35 
36   /**
37    * Track an conditional GET that was satisfied by this cache.
38    */
trackConditionalCacheHit()39   void trackConditionalCacheHit();
40 
41   /**
42    * Updates stored HTTP headers using a hit on a conditional GET.
43    *
44    * @param conditionalCacheHit Conditional cache hit.
45    * @param httpConnection Http connection.
46    */
update(CacheResponse conditionalCacheHit, HttpURLConnection httpConnection)47   void update(CacheResponse conditionalCacheHit, HttpURLConnection httpConnection);
48 }
49