| Index: tools/android/loading/sandwich_swr.py
|
| diff --git a/tools/android/loading/sandwich_swr.py b/tools/android/loading/sandwich_swr.py
|
| index 46910c4078cd3f09bc8b361f35ad6a72ceaf87b7..7f41bedf18ef41105bc988ba8fdefb8d90885db1 100644
|
| --- a/tools/android/loading/sandwich_swr.py
|
| +++ b/tools/android/loading/sandwich_swr.py
|
| @@ -26,20 +26,21 @@ def _BuildPatchedCache(original_cache_run_path, original_cache_archive_path,
|
| with common_util.TemporaryDirectory(prefix='sandwich_tmp') as tmp_path:
|
| cache_path = os.path.join(tmp_path, 'cache')
|
| chrome_cache.UnzipDirectoryContent(original_cache_archive_path, cache_path)
|
| - cache_backend = chrome_cache.CacheBackend(cache_path, 'simple')
|
| - cache_keys = set(cache_backend.ListKeys())
|
| - for request in trace.request_track.GetEvents():
|
| - if request.url not in cache_keys:
|
| - continue
|
| - caching_policy = request_track.CachingPolicy(request)
|
| - assert caching_policy.IsCacheable()
|
| - freshness = caching_policy.GetFreshnessLifetimes()
|
| - if freshness[0] == 0:
|
| - continue
|
| - request.SetHTTPResponseHeader('cache-control', CACHE_CONTROL_VALUE)
|
| - raw_headers = request.GetRawResponseHeaders()
|
| - cache_backend.UpdateRawResponseHeaders(request.url, raw_headers)
|
| - patch_count += 1
|
| + with chrome_cache.OnlineCacheBackend(
|
| + cache_path, chrome_cache.CacheBackendType.SIMPLE) as cache_backend:
|
| + cache_keys = set(cache_backend.ListKeys())
|
| + for request in trace.request_track.GetEvents():
|
| + if request.url not in cache_keys:
|
| + continue
|
| + caching_policy = request_track.CachingPolicy(request)
|
| + assert caching_policy.IsCacheable()
|
| + freshness = caching_policy.GetFreshnessLifetimes()
|
| + if freshness[0] == 0:
|
| + continue
|
| + request.SetHTTPResponseHeader('cache-control', CACHE_CONTROL_VALUE)
|
| + raw_headers = request.GetRawResponseHeaders()
|
| + cache_backend.UpdateRawResponseHeaders(request.url, raw_headers)
|
| + patch_count += 1
|
| chrome_cache.ZipDirectoryContent(cache_path, cache_archive_dest_path)
|
| logging.info('Patched %d cached resources out of %d' % (
|
| patch_count, len(cache_keys)))
|
|
|