Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Unified Diff: tools/android/loading/sandwich_swr.py

Issue 2112013003: sandwich: Use cachetool's batch mode to speed-up cache processing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@af00
Patch Set: Makes os.{read,write} non blocking Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)))
« tools/android/loading/chrome_cache.py ('K') | « tools/android/loading/sandwich_prefetch.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698