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 from collections import Mapping | 5 from collections import Mapping |
6 import posixpath | 6 import posixpath |
7 | 7 |
8 from api_schema_graph import APISchemaGraph | 8 from api_schema_graph import APISchemaGraph |
9 from branch_utility import BranchUtility | 9 from branch_utility import BranchUtility |
10 from extensions_paths import API_PATHS, JSON_TEMPLATES | 10 from extensions_paths import API_PATHS, JSON_TEMPLATES |
11 from features_bundle import FeaturesBundle | 11 from features_bundle import FeaturesBundle |
12 import features_utility | 12 import features_utility |
13 from file_system import FileNotFoundError | 13 from file_system import FileNotFoundError |
| 14 from third_party.json_schema_compiler.memoize import memoize |
14 from third_party.json_schema_compiler.model import UnixName | 15 from third_party.json_schema_compiler.model import UnixName |
15 | 16 |
16 | 17 |
17 _EXTENSION_API = 'extension_api.json' | 18 _EXTENSION_API = 'extension_api.json' |
18 | 19 |
19 # The version where api_features.json is first available. | 20 # The version where api_features.json is first available. |
20 _API_FEATURES_MIN_VERSION = 28 | 21 _API_FEATURES_MIN_VERSION = 28 |
21 # The version where permission_ and manifest_features.json are available and | 22 # The version where permission_ and manifest_features.json are available and |
22 # presented in the current format. | 23 # presented in the current format. |
23 _ORIGINAL_FEATURES_MIN_VERSION = 20 | 24 _ORIGINAL_FEATURES_MIN_VERSION = 20 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 # If an API is not represented in any of the _features files, but exists | 171 # If an API is not represented in any of the _features files, but exists |
171 # in the filesystem, then assume it is available in this version. | 172 # in the filesystem, then assume it is available in this version. |
172 # The chrome.windows API is an example of this. | 173 # The chrome.windows API is an example of this. |
173 available_channel = channel_info.channel | 174 available_channel = channel_info.channel |
174 # If the channel we're checking is the same as or newer than the | 175 # If the channel we're checking is the same as or newer than the |
175 # |available_channel| then the API is available at this channel. | 176 # |available_channel| then the API is available at this channel. |
176 newest = BranchUtility.NewestChannel((available_channel, | 177 newest = BranchUtility.NewestChannel((available_channel, |
177 channel_info.channel)) | 178 channel_info.channel)) |
178 return available_channel is not None and newest == channel_info.channel | 179 return available_channel is not None and newest == channel_info.channel |
179 | 180 |
| 181 @memoize |
180 def _CreateFeaturesBundle(self, file_system): | 182 def _CreateFeaturesBundle(self, file_system): |
181 return FeaturesBundle(file_system, | 183 return FeaturesBundle(file_system, |
182 self._compiled_fs_factory, | 184 self._compiled_fs_factory, |
183 self._object_store_creator) | 185 self._object_store_creator) |
184 | 186 |
185 def _GetChannelFromApiFeatures(self, api_name, features_bundle): | 187 def _GetChannelFromApiFeatures(self, api_name, features_bundle): |
186 return _GetChannelFromFeatures(api_name, features_bundle.GetAPIFeatures()) | 188 return _GetChannelFromFeatures(api_name, features_bundle.GetAPIFeatures()) |
187 | 189 |
188 def _GetChannelFromManifestFeatures(self, api_name, features_bundle): | 190 def _GetChannelFromManifestFeatures(self, api_name, features_bundle): |
189 # _manifest_features.json uses unix_style API names. | 191 # _manifest_features.json uses unix_style API names. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 284 |
283 # Continue looping until there are no longer differences between this | 285 # Continue looping until there are no longer differences between this |
284 # version and trunk. | 286 # version and trunk. |
285 return version_stat != trunk_stat | 287 return version_stat != trunk_stat |
286 | 288 |
287 self._file_system_iterator.Ascending(self.GetApiAvailability(api_name), | 289 self._file_system_iterator.Ascending(self.GetApiAvailability(api_name), |
288 update_availability_graph) | 290 update_availability_graph) |
289 | 291 |
290 self._node_level_object_store.Set(api_name, availability_graph) | 292 self._node_level_object_store.Set(api_name, availability_graph) |
291 return availability_graph | 293 return availability_graph |
OLD | NEW |