| 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
|
|
|