Chromium Code Reviews| Index: chrome/common/extensions/docs/server2/manifest_data_source.py |
| diff --git a/chrome/common/extensions/docs/server2/manifest_data_source.py b/chrome/common/extensions/docs/server2/manifest_data_source.py |
| index 6a850da177c6c63aa6c3ebd6266c7073d49524e1..b69d3a8593eccd821b0f4f58abf2af78f8822b21 100644 |
| --- a/chrome/common/extensions/docs/server2/manifest_data_source.py |
| +++ b/chrome/common/extensions/docs/server2/manifest_data_source.py |
| @@ -6,7 +6,7 @@ import json |
| from data_source import DataSource |
| import features_utility |
| -from manifest_features import CreateManifestFeatures, ConvertDottedKeysToNested |
| +from manifest_features import ConvertDottedKeysToNested |
| from third_party.json_schema_compiler.json_parse import Parse |
| def _ListifyAndSortDocs(features, app_name): |
| @@ -100,36 +100,26 @@ class ManifestDataSource(DataSource): |
| '''Provides access to the properties in manifest features. |
| ''' |
| def __init__(self, server_instance, _): |
| - self._manifest_path = server_instance.manifest_json_path |
| - self._features_path = server_instance.manifest_features_path |
| - self._file_system = server_instance.host_file_system |
| - self._cache = server_instance.compiled_host_fs_factory.Create( |
| - self._CreateManifestData, ManifestDataSource) |
| - |
| - def _CreateManifestData(self, _, content): |
| - '''Combine the contents of |_manifest_path| and |_features_path| and filter |
| - the results into lists specific to apps or extensions for templates. Marks |
| - up features with annotations. |
| - ''' |
| + self._features_bundle = server_instance.features_bundle |
| + self._cache = None |
| + |
| + def _CreateCache(self): |
| def for_templates(manifest_features, platform): |
| return _AddLevelAnnotations( |
| _ListifyAndSortDocs( |
| ConvertDottedKeysToNested( |
| features_utility.Filtered(manifest_features, platform)), |
| app_name=platform.capitalize())) |
| - |
| - manifest_json = Parse(self._file_system.ReadSingle(self._manifest_path)) |
| - manifest_features = CreateManifestFeatures( |
| - features_json=Parse(content), manifest_json=manifest_json) |
| - |
| + manifest_features = self._features_bundle.GetManifestFeatures() |
| return { |
| - 'apps': for_templates(manifest_features, 'app'), |
| - 'extensions': for_templates(manifest_features, 'extension') |
| + 'apps': for_templates(manifest_features, 'apps'), |
| + 'extensions': for_templates(manifest_features, 'extensions') |
| } |
| def Cron(self): |
| - self._cache.GetFromFile(self._features_path) |
| - self._file_system.ReadSingle(self._manifest_path) |
| + self._cache = self._CreateCache() |
| def get(self, key): |
| - return self._cache.GetFromFile(self._features_path)[key] |
| + if self._cache is None: |
| + self._cache = self._CreateCache() |
| + return self._cache.get(key) |
|
not at google - send to devlin
2013/10/01 16:34:34
you could also consider doing this with an ObjectS
Ken Rockot(use gerrit already)
2013/10/01 22:18:16
Done, minus fine-grained caching.
|