use of com.android.okhttp.AndroidShimResponseCache in project android_frameworks_base by ResurrectionRemix.
the class HttpResponseCache method install.
/**
* Creates a new HTTP response cache and sets it as the system default cache.
*
* @param directory the directory to hold cache data.
* @param maxSize the maximum size of the cache in bytes.
* @return the newly-installed cache
* @throws IOException if {@code directory} cannot be used for this cache.
* Most applications should respond to this exception by logging a
* warning.
*/
public static synchronized HttpResponseCache install(File directory, long maxSize) throws IOException {
ResponseCache installed = ResponseCache.getDefault();
if (installed instanceof HttpResponseCache) {
HttpResponseCache installedResponseCache = (HttpResponseCache) installed;
// don't close and reopen if an equivalent cache is already installed
AndroidShimResponseCache trueResponseCache = installedResponseCache.delegate;
if (trueResponseCache.isEquivalent(directory, maxSize)) {
return installedResponseCache;
} else {
// The HttpResponseCache that owns this object is about to be replaced.
trueResponseCache.close();
}
}
AndroidShimResponseCache trueResponseCache = AndroidShimResponseCache.create(directory, maxSize);
HttpResponseCache newResponseCache = new HttpResponseCache(trueResponseCache);
ResponseCache.setDefault(newResponseCache);
return newResponseCache;
}
use of com.android.okhttp.AndroidShimResponseCache in project android_frameworks_base by crdroidandroid.
the class HttpResponseCache method install.
/**
* Creates a new HTTP response cache and sets it as the system default cache.
*
* @param directory the directory to hold cache data.
* @param maxSize the maximum size of the cache in bytes.
* @return the newly-installed cache
* @throws IOException if {@code directory} cannot be used for this cache.
* Most applications should respond to this exception by logging a
* warning.
*/
public static synchronized HttpResponseCache install(File directory, long maxSize) throws IOException {
ResponseCache installed = ResponseCache.getDefault();
if (installed instanceof HttpResponseCache) {
HttpResponseCache installedResponseCache = (HttpResponseCache) installed;
// don't close and reopen if an equivalent cache is already installed
AndroidShimResponseCache trueResponseCache = installedResponseCache.delegate;
if (trueResponseCache.isEquivalent(directory, maxSize)) {
return installedResponseCache;
} else {
// The HttpResponseCache that owns this object is about to be replaced.
trueResponseCache.close();
}
}
AndroidShimResponseCache trueResponseCache = AndroidShimResponseCache.create(directory, maxSize);
HttpResponseCache newResponseCache = new HttpResponseCache(trueResponseCache);
ResponseCache.setDefault(newResponseCache);
return newResponseCache;
}
use of com.android.okhttp.AndroidShimResponseCache in project platform_frameworks_base by android.
the class HttpResponseCache method install.
/**
* Creates a new HTTP response cache and sets it as the system default cache.
*
* @param directory the directory to hold cache data.
* @param maxSize the maximum size of the cache in bytes.
* @return the newly-installed cache
* @throws IOException if {@code directory} cannot be used for this cache.
* Most applications should respond to this exception by logging a
* warning.
*/
public static synchronized HttpResponseCache install(File directory, long maxSize) throws IOException {
ResponseCache installed = ResponseCache.getDefault();
if (installed instanceof HttpResponseCache) {
HttpResponseCache installedResponseCache = (HttpResponseCache) installed;
// don't close and reopen if an equivalent cache is already installed
AndroidShimResponseCache trueResponseCache = installedResponseCache.delegate;
if (trueResponseCache.isEquivalent(directory, maxSize)) {
return installedResponseCache;
} else {
// The HttpResponseCache that owns this object is about to be replaced.
trueResponseCache.close();
}
}
AndroidShimResponseCache trueResponseCache = AndroidShimResponseCache.create(directory, maxSize);
HttpResponseCache newResponseCache = new HttpResponseCache(trueResponseCache);
ResponseCache.setDefault(newResponseCache);
return newResponseCache;
}
use of com.android.okhttp.AndroidShimResponseCache in project android_frameworks_base by AOSPA.
the class HttpResponseCache method install.
/**
* Creates a new HTTP response cache and sets it as the system default cache.
*
* @param directory the directory to hold cache data.
* @param maxSize the maximum size of the cache in bytes.
* @return the newly-installed cache
* @throws IOException if {@code directory} cannot be used for this cache.
* Most applications should respond to this exception by logging a
* warning.
*/
public static synchronized HttpResponseCache install(File directory, long maxSize) throws IOException {
ResponseCache installed = ResponseCache.getDefault();
if (installed instanceof HttpResponseCache) {
HttpResponseCache installedResponseCache = (HttpResponseCache) installed;
// don't close and reopen if an equivalent cache is already installed
AndroidShimResponseCache trueResponseCache = installedResponseCache.delegate;
if (trueResponseCache.isEquivalent(directory, maxSize)) {
return installedResponseCache;
} else {
// The HttpResponseCache that owns this object is about to be replaced.
trueResponseCache.close();
}
}
AndroidShimResponseCache trueResponseCache = AndroidShimResponseCache.create(directory, maxSize);
HttpResponseCache newResponseCache = new HttpResponseCache(trueResponseCache);
ResponseCache.setDefault(newResponseCache);
return newResponseCache;
}
use of com.android.okhttp.AndroidShimResponseCache in project android_frameworks_base by DirtyUnicorns.
the class HttpResponseCache method install.
/**
* Creates a new HTTP response cache and sets it as the system default cache.
*
* @param directory the directory to hold cache data.
* @param maxSize the maximum size of the cache in bytes.
* @return the newly-installed cache
* @throws IOException if {@code directory} cannot be used for this cache.
* Most applications should respond to this exception by logging a
* warning.
*/
public static synchronized HttpResponseCache install(File directory, long maxSize) throws IOException {
ResponseCache installed = ResponseCache.getDefault();
if (installed instanceof HttpResponseCache) {
HttpResponseCache installedResponseCache = (HttpResponseCache) installed;
// don't close and reopen if an equivalent cache is already installed
AndroidShimResponseCache trueResponseCache = installedResponseCache.delegate;
if (trueResponseCache.isEquivalent(directory, maxSize)) {
return installedResponseCache;
} else {
// The HttpResponseCache that owns this object is about to be replaced.
trueResponseCache.close();
}
}
AndroidShimResponseCache trueResponseCache = AndroidShimResponseCache.create(directory, maxSize);
HttpResponseCache newResponseCache = new HttpResponseCache(trueResponseCache);
ResponseCache.setDefault(newResponseCache);
return newResponseCache;
}
Aggregations