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

Side by Side Diff: chrome/common/extensions/docs/server2/availability_finder.py

Issue 344453003: Docserver: separate models for apps and extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 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, ChannelInfo 9 from branch_utility import BranchUtility, ChannelInfo
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
13 from file_system import FileNotFoundError 12 from file_system import FileNotFoundError
13 from platform_util import PlatformToExtensionType
14 from third_party.json_schema_compiler.memoize import memoize 14 from third_party.json_schema_compiler.memoize import memoize
15 from third_party.json_schema_compiler.model import UnixName 15 from third_party.json_schema_compiler.model import UnixName
16 16
17 17
18 _EXTENSION_API = 'extension_api.json' 18 _EXTENSION_API = 'extension_api.json'
19 19
20 # The version where api_features.json is first available. 20 # The version where api_features.json is first available.
21 _API_FEATURES_MIN_VERSION = 28 21 _API_FEATURES_MIN_VERSION = 28
22 # The version where permission_ and manifest_features.json are available and 22 # The version where permission_ and manifest_features.json are available and
23 # presented in the current format. 23 # presented in the current format.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 class AvailabilityFinder(object): 63 class AvailabilityFinder(object):
64 '''Generates availability information for APIs by looking at API schemas and 64 '''Generates availability information for APIs by looking at API schemas and
65 _features files over multiple release versions of Chrome. 65 _features files over multiple release versions of Chrome.
66 ''' 66 '''
67 67
68 def __init__(self, 68 def __init__(self,
69 branch_utility, 69 branch_utility,
70 compiled_fs_factory, 70 compiled_fs_factory,
71 file_system_iterator, 71 file_system_iterator,
72 host_file_system, 72 host_file_system,
73 object_store_creator): 73 object_store_creator,
74 platform):
74 self._branch_utility = branch_utility 75 self._branch_utility = branch_utility
75 self._compiled_fs_factory = compiled_fs_factory 76 self._compiled_fs_factory = compiled_fs_factory
76 self._file_system_iterator = file_system_iterator 77 self._file_system_iterator = file_system_iterator
77 self._host_file_system = host_file_system 78 self._host_file_system = host_file_system
78 self._object_store_creator = object_store_creator 79 self._object_store_creator = object_store_creator
79 def create_object_store(category): 80 def create_object_store(category):
80 return object_store_creator.Create(AvailabilityFinder, category=category) 81 return object_store_creator.Create(
82 AvailabilityFinder, category='/'.join((platform, category)))
81 self._top_level_object_store = create_object_store('top_level') 83 self._top_level_object_store = create_object_store('top_level')
82 self._node_level_object_store = create_object_store('node_level') 84 self._node_level_object_store = create_object_store('node_level')
83 self._json_fs = compiled_fs_factory.ForJson(self._host_file_system) 85 self._json_fs = compiled_fs_factory.ForJson(self._host_file_system)
86 self._platform = platform
84 87
85 def _GetPredeterminedAvailability(self, api_name): 88 def _GetPredeterminedAvailability(self, api_name):
86 '''Checks a configuration file for hardcoded (i.e. predetermined) 89 '''Checks a configuration file for hardcoded (i.e. predetermined)
87 availability information for an API. 90 availability information for an API.
88 ''' 91 '''
89 api_info = self._json_fs.GetFromFile( 92 api_info = self._json_fs.GetFromFile(
90 JSON_TEMPLATES + 'api_availabilities.json').Get().get(api_name) 93 JSON_TEMPLATES + 'api_availabilities.json').Get().get(api_name)
91 if api_info is None: 94 if api_info is None:
92 return None 95 return None
93 if api_info['channel'] == 'stable': 96 if api_info['channel'] == 'stable':
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 # If the channel we're checking is the same as or newer than the 201 # If the channel we're checking is the same as or newer than the
199 # |available_channel| then the API is available at this channel. 202 # |available_channel| then the API is available at this channel.
200 newest = BranchUtility.NewestChannel((available_channel, 203 newest = BranchUtility.NewestChannel((available_channel,
201 channel_info.channel)) 204 channel_info.channel))
202 return available_channel is not None and newest == channel_info.channel 205 return available_channel is not None and newest == channel_info.channel
203 206
204 @memoize 207 @memoize
205 def _CreateFeaturesBundle(self, file_system): 208 def _CreateFeaturesBundle(self, file_system):
206 return FeaturesBundle(file_system, 209 return FeaturesBundle(file_system,
207 self._compiled_fs_factory, 210 self._compiled_fs_factory,
208 self._object_store_creator) 211 self._object_store_creator,
212 self._platform)
209 213
210 def _GetChannelFromAPIFeatures(self, api_name, features_bundle): 214 def _GetChannelFromAPIFeatures(self, api_name, features_bundle):
211 return _GetChannelFromFeatures(api_name, features_bundle.GetAPIFeatures()) 215 return _GetChannelFromFeatures(api_name, features_bundle.GetAPIFeatures())
212 216
213 def _GetChannelFromManifestFeatures(self, api_name, features_bundle): 217 def _GetChannelFromManifestFeatures(self, api_name, features_bundle):
214 # _manifest_features.json uses unix_style API names. 218 # _manifest_features.json uses unix_style API names.
215 api_name = UnixName(api_name) 219 api_name = UnixName(api_name)
216 return _GetChannelFromFeatures(api_name, 220 return _GetChannelFromFeatures(api_name,
217 features_bundle.GetManifestFeatures()) 221 features_bundle.GetManifestFeatures())
218 222
219 def _GetChannelFromPermissionFeatures(self, api_name, features_bundle): 223 def _GetChannelFromPermissionFeatures(self, api_name, features_bundle):
220 return _GetChannelFromFeatures(api_name, 224 return _GetChannelFromFeatures(api_name,
221 features_bundle.GetPermissionFeatures()) 225 features_bundle.GetPermissionFeatures())
222 226
223 def _CheckAPIAvailability(self, api_name, file_system, channel_info): 227 def _CheckAPIAvailability(self, api_name, file_system, channel_info):
224 '''Determines the availability for an API at a certain version of Chrome. 228 '''Determines the availability for an API at a certain version of Chrome.
225 Two branches of logic are used depending on whether or not the API is 229 Two branches of logic are used depending on whether or not the API is
226 determined to be 'stable' at the given version. 230 determined to be 'stable' at the given version.
227 ''' 231 '''
228 if channel_info.channel == 'stable': 232 if channel_info.channel == 'stable':
229 return self._CheckStableAvailability(api_name, 233 return self._CheckStableAvailability(
230 file_system, 234 api_name, file_system, channel_info.version)
231 channel_info.version) 235 return self._CheckChannelAvailability(
232 return self._CheckChannelAvailability(api_name, 236 api_name, file_system, channel_info)
233 file_system,
234 channel_info)
235 237
236 def _FindScheduled(self, api_name): 238 def _FindScheduled(self, api_name):
237 '''Determines the earliest version of Chrome where the API is stable. 239 '''Determines the earliest version of Chrome where the API is stable.
238 Unlike the code in GetAPIAvailability, this checks if the API is stable 240 Unlike the code in GetAPIAvailability, this checks if the API is stable
239 even when Chrome is in dev or beta, which shows that the API is scheduled 241 even when Chrome is in dev or beta, which shows that the API is scheduled
240 to be stable in that verison of Chrome. 242 to be stable in that verison of Chrome.
241 ''' 243 '''
242 def check_scheduled(file_system, channel_info): 244 def check_scheduled(file_system, channel_info):
243 return self._CheckStableAvailability( 245 return self._CheckStableAvailability(
244 api_name, file_system, channel_info.version) 246 api_name, file_system, channel_info.version)
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 # Continue looping until there are no longer differences between this 334 # Continue looping until there are no longer differences between this
333 # version and trunk. 335 # version and trunk.
334 return version_stat != trunk_stat 336 return version_stat != trunk_stat
335 337
336 self._file_system_iterator.Ascending( 338 self._file_system_iterator.Ascending(
337 self.GetAPIAvailability(api_name).channel_info, 339 self.GetAPIAvailability(api_name).channel_info,
338 update_availability_graph) 340 update_availability_graph)
339 341
340 self._node_level_object_store.Set(api_name, availability_graph) 342 self._node_level_object_store.Set(api_name, availability_graph)
341 return availability_graph 343 return availability_graph
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698