| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 import features_utility | 5 import features_utility |
| 6 import svn_constants | 6 import svn_constants |
| 7 from third_party.json_schema_compiler.json_parse import Parse | 7 from third_party.json_schema_compiler.json_parse import Parse |
| 8 | 8 |
| 9 | 9 |
| 10 def _AddPlatformsFromDependencies(feature, features_bundle): | 10 def _AddPlatformsFromDependencies(feature, features_bundle): |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 # so is this feature. | 25 # so is this feature. |
| 26 if dependency_feature is None: | 26 if dependency_feature is None: |
| 27 return [] | 27 return [] |
| 28 platforms = platforms.union(dependency_feature['platforms']) | 28 platforms = platforms.union(dependency_feature['platforms']) |
| 29 feature['platforms'] = list(platforms) | 29 feature['platforms'] = list(platforms) |
| 30 | 30 |
| 31 | 31 |
| 32 class _FeaturesCache(object): | 32 class _FeaturesCache(object): |
| 33 def __init__(self, file_system, compiled_fs_factory, *json_paths): | 33 def __init__(self, file_system, compiled_fs_factory, *json_paths): |
| 34 self._file_system = file_system | 34 self._file_system = file_system |
| 35 self._cache = compiled_fs_factory.Create(self._CreateCache, type(self)) | 35 self._cache = compiled_fs_factory.Create( |
| 36 file_system, self._CreateCache, type(self)) |
| 36 self._json_path = json_paths[0] | 37 self._json_path = json_paths[0] |
| 37 self._extra_paths = json_paths[1:] | 38 self._extra_paths = json_paths[1:] |
| 38 | 39 |
| 39 def _CreateCache(self, _, features_json): | 40 def _CreateCache(self, _, features_json): |
| 40 features = features_utility.Parse(Parse(features_json)) | 41 features = features_utility.Parse(Parse(features_json)) |
| 41 for path in self._extra_paths: | 42 for path in self._extra_paths: |
| 42 extra_json = self._file_system.ReadSingle(path).Get() | 43 extra_json = self._file_system.ReadSingle(path).Get() |
| 43 features = features_utility.MergedWith( | 44 features = features_utility.MergedWith( |
| 44 features_utility.Parse(Parse(extra_json)), features) | 45 features_utility.Parse(Parse(extra_json)), features) |
| 45 return features | 46 return features |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 api_features = self._api_cache.GetFeatures() | 83 api_features = self._api_cache.GetFeatures() |
| 83 # TODO(rockot): Handle inter-API dependencies more gracefully. | 84 # TODO(rockot): Handle inter-API dependencies more gracefully. |
| 84 # Not yet a problem because there is only one such case (windows -> tabs). | 85 # Not yet a problem because there is only one such case (windows -> tabs). |
| 85 # If we don't store this value before annotating platforms, inter-API | 86 # If we don't store this value before annotating platforms, inter-API |
| 86 # dependencies will lead to infinite recursion. | 87 # dependencies will lead to infinite recursion. |
| 87 self._object_store.Set('api_features', api_features) | 88 self._object_store.Set('api_features', api_features) |
| 88 for feature in api_features.itervalues(): | 89 for feature in api_features.itervalues(): |
| 89 _AddPlatformsFromDependencies(feature, self) | 90 _AddPlatformsFromDependencies(feature, self) |
| 90 self._object_store.Set('api_features', api_features) | 91 self._object_store.Set('api_features', api_features) |
| 91 return api_features | 92 return api_features |
| OLD | NEW |