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

Unified Diff: chrome/common/extensions/docs/server2/fetcher_cache.py

Issue 10689144: Extensions Docs Server: Samples zip files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up and tests Created 8 years, 5 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: chrome/common/extensions/docs/server2/fetcher_cache.py
diff --git a/chrome/common/extensions/docs/server2/fetcher_cache.py b/chrome/common/extensions/docs/server2/fetcher_cache.py
index dc3b12ede4bb8e78999d28871f0d60c006a8bed2..68cfdddb63a28f57eb49eb48983505590d6d8e99 100644
--- a/chrome/common/extensions/docs/server2/fetcher_cache.py
+++ b/chrome/common/extensions/docs/server2/fetcher_cache.py
@@ -34,13 +34,22 @@ class FetcherCache(object):
self._populate_function = populate_function
self._cache = {}
- def get(self, key):
+ def _Fetch(self, fetch_func, key, optional_params=None):
if key in self._cache:
if self._cache[key].HasExpired():
self._cache.pop(key)
else:
return self._cache[key]._cache_data
- cache_data = self._fetcher.FetchResource(key).content
+ if optional_params != None:
+ cache_data = fetch_func(key, optional_params).content
+ else:
+ cache_data = fetch_func(key).content
self._cache[key] = self._CacheEntry(self._populate_function(cache_data),
time.time() + self._timeout_seconds)
return self._cache[key]._cache_data
+
+ def getFromFileListing(self, path, recursive=False):
+ return self._Fetch(self._fetcher.ListDirectory, path, recursive)
+
+ def getFromFile(self, key):
+ return self._Fetch(self._fetcher.FetchResource, key)
« no previous file with comments | « chrome/common/extensions/docs/server2/example_zipper.py ('k') | chrome/common/extensions/docs/server2/intro_data_source.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698