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

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

Issue 14125010: Docserver: Add support for viewing docs with a codereview patch applied (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: everything but patch_servlet Created 7 years, 7 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/compiled_file_system.py
===================================================================
--- chrome/common/extensions/docs/server2/compiled_file_system.py (revision 199575)
+++ chrome/common/extensions/docs/server2/compiled_file_system.py (working copy)
@@ -4,7 +4,7 @@
class _CacheEntry(object):
def __init__(self, cache_data, version):
- self._cache_data = cache_data
+ self.cache_data = cache_data
self.version = version
class CompiledFileSystem(object):
@@ -70,15 +70,19 @@
apply for the first time the file is fetched; if already cached, |binary|
will be ignored.
"""
+ return self._GetCacheEntryFromFile(path, binary).cache_data
+
+ def _GetCacheEntryFromFile(self, path, binary=False):
version = self._file_system.Stat(path).version
cache_entry = self._file_object_store.Get(path).Get()
if (cache_entry is not None) and (version == cache_entry.version):
- return cache_entry._cache_data
+ return cache_entry
cache_data = self._populate_function(
path,
self._file_system.ReadSingle(path, binary=binary))
- self._file_object_store.Set(path, _CacheEntry(cache_data, version))
- return cache_data
+ cache_entry = _CacheEntry(cache_data, version)
+ self._file_object_store.Set(path, cache_entry)
+ return cache_entry
def GetFromFileListing(self, path):
"""Calls |populate_function| on the listing of the files at |path|.
@@ -86,10 +90,15 @@
"""
if not path.endswith('/'):
path += '/'
+ return self._GetCacheEntryFromFileListing(path).cache_data
+
+ def _GetCacheEntryFromFileListing(self, path):
+ assert path.endswith('/')
version = self._file_system.Stat(path).version
cache_entry = self._list_object_store.Get(path).Get()
if (cache_entry is not None) and (version == cache_entry.version):
- return cache_entry._cache_data
+ return cache_entry
cache_data = self._populate_function(path, self._RecursiveList(path))
- self._list_object_store.Set(path, _CacheEntry(cache_data, version))
- return cache_data
+ cache_entry = _CacheEntry(cache_data, version)
+ self._list_object_store.Set(path, cache_entry)
+ return cache_entry

Powered by Google App Engine
This is Rietveld 408576698