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

Side by Side 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: add executable bits for tests 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 unified diff | Download patch
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 class _CacheEntry(object): 5 class _CacheEntry(object):
6 def __init__(self, cache_data, version): 6 def __init__(self, cache_data, version):
7 self._cache_data = cache_data 7 self._cache_data = cache_data
8 self.version = version 8 self.version = version
9 9
10 class CompiledFileSystem(object): 10 class CompiledFileSystem(object):
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 """ 86 """
87 if not path.endswith('/'): 87 if not path.endswith('/'):
88 path += '/' 88 path += '/'
89 version = self._file_system.Stat(path).version 89 version = self._file_system.Stat(path).version
90 cache_entry = self._list_object_store.Get(path).Get() 90 cache_entry = self._list_object_store.Get(path).Get()
91 if (cache_entry is not None) and (version == cache_entry.version): 91 if (cache_entry is not None) and (version == cache_entry.version):
92 return cache_entry._cache_data 92 return cache_entry._cache_data
93 cache_data = self._populate_function(path, self._RecursiveList(path)) 93 cache_data = self._populate_function(path, self._RecursiveList(path))
94 self._list_object_store.Set(path, _CacheEntry(cache_data, version)) 94 self._list_object_store.Set(path, _CacheEntry(cache_data, version))
95 return cache_data 95 return cache_data
96
97 def StatFile(self, path):
98 cache_entry = self._file_object_store.Get(path).Get()
99 if cache_entry is not None:
100 return cache_entry.version
101 return self._file_system.Stat(path).version
102
103 def StatFileListing(self, path):
104 if not path.endswith('/'):
105 path += '/'
106 cache_entry = self._list_object_store.Get(path).Get()
107 if cache_entry is not None:
108 return cache_entry.version
109 return self._file_system.Stat(path).version
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698