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

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

Issue 26538009: Docserver: make file_system a property of Create (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: niggles Created 7 years, 2 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 | Annotate | Revision Log
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 os 6 import os
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 compiled_file_system import CompiledFileSystem 10 from compiled_file_system import CompiledFileSystem
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 def _CheckStableAvailability(self, api_name, file_system, version): 133 def _CheckStableAvailability(self, api_name, file_system, version):
134 '''Checks for availability of an API, |api_name|, on the stable channel. 134 '''Checks for availability of an API, |api_name|, on the stable channel.
135 Considers several _features.json files, file system existence, and 135 Considers several _features.json files, file system existence, and
136 extension_api.json depending on the given |version|. 136 extension_api.json depending on the given |version|.
137 ''' 137 '''
138 if version < 5: 138 if version < 5:
139 # SVN data isn't available below version 5. 139 # SVN data isn't available below version 5.
140 return False 140 return False
141 available_channel = None 141 available_channel = None
142 fs_factory = CompiledFileSystem.Factory(file_system, 142 fs_factory = CompiledFileSystem.Factory(self._object_store_creator)
143 self._object_store_creator) 143 features_fs = fs_factory.Create(file_system,
144 features_fs = fs_factory.Create(lambda _, json: json_parse.Parse(json), 144 lambda _, json: json_parse.Parse(json),
145 AvailabilityFinder, 145 AvailabilityFinder,
146 category='features') 146 category='features')
147 if version >= 28: 147 if version >= 28:
148 # The _api_features.json file first appears in version 28 and should be 148 # The _api_features.json file first appears in version 28 and should be
149 # the most reliable for finding API availability. 149 # the most reliable for finding API availability.
150 available_channel = _GetChannelFromApiFeatures(api_name, features_fs) 150 available_channel = _GetChannelFromApiFeatures(api_name, features_fs)
151 if version >= 20: 151 if version >= 20:
152 # The _permission_features.json and _manifest_features.json files are 152 # The _permission_features.json and _manifest_features.json files are
153 # present in Chrome 20 and onwards. Use these if no information could be 153 # present in Chrome 20 and onwards. Use these if no information could be
154 # found using _api_features.json. 154 # found using _api_features.json.
155 available_channel = available_channel or ( 155 available_channel = available_channel or (
156 _GetChannelFromPermissionFeatures(api_name, features_fs) 156 _GetChannelFromPermissionFeatures(api_name, features_fs)
157 or _GetChannelFromManifestFeatures(api_name, features_fs)) 157 or _GetChannelFromManifestFeatures(api_name, features_fs))
158 if available_channel is not None: 158 if available_channel is not None:
159 return available_channel == 'stable' 159 return available_channel == 'stable'
160 if version >= 5: 160 if version >= 5:
161 # Fall back to a check for file system existence if the API is not 161 # Fall back to a check for file system existence if the API is not
162 # stable in any of the _features.json files, or if the _features files 162 # stable in any of the _features.json files, or if the _features files
163 # do not exist (version 19 and earlier). 163 # do not exist (version 19 and earlier).
164 return _HasApiSchema(api_name, file_system) 164 return _HasApiSchema(api_name, file_system)
165 165
166 def _CheckChannelAvailability(self, api_name, file_system, channel_name): 166 def _CheckChannelAvailability(self, api_name, file_system, channel_name):
167 '''Searches through the _features files in a given |file_system| and 167 '''Searches through the _features files in a given |file_system| and
168 determines whether or not an API is available on the given channel, 168 determines whether or not an API is available on the given channel,
169 |channel_name|. 169 |channel_name|.
170 ''' 170 '''
171 fs_factory = CompiledFileSystem.Factory(file_system, 171 fs_factory = CompiledFileSystem.Factory(self._object_store_creator)
172 self._object_store_creator) 172 features_fs = fs_factory.Create(file_system,
173 features_fs = fs_factory.Create(lambda _, json: json_parse.Parse(json), 173 lambda _, json: json_parse.Parse(json),
174 AvailabilityFinder, 174 AvailabilityFinder,
175 category='features') 175 category='features')
176 available_channel = (_GetChannelFromApiFeatures(api_name, features_fs) 176 available_channel = (_GetChannelFromApiFeatures(api_name, features_fs)
177 or _GetChannelFromPermissionFeatures(api_name, features_fs) 177 or _GetChannelFromPermissionFeatures(api_name, features_fs)
178 or _GetChannelFromManifestFeatures(api_name, features_fs)) 178 or _GetChannelFromManifestFeatures(api_name, features_fs))
179 if available_channel is None and _HasApiSchema(api_name, file_system): 179 if available_channel is None and _HasApiSchema(api_name, file_system):
180 # If an API is not represented in any of the _features files, but exists 180 # If an API is not represented in any of the _features files, but exists
181 # in the filesystem, then assume it is available in this version. 181 # in the filesystem, then assume it is available in this version.
182 # The windows API is an example of this. 182 # The windows API is an example of this.
183 available_channel = channel_name 183 available_channel = channel_name
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 245
246 # Continue looping until there are no longer differences between this 246 # Continue looping until there are no longer differences between this
247 # version and trunk. 247 # version and trunk.
248 return trunk_graph != version_graph 248 return trunk_graph != version_graph
249 249
250 self._file_system_iterator.Ascending(self.GetApiAvailability(api_name), 250 self._file_system_iterator.Ascending(self.GetApiAvailability(api_name),
251 update_availability_graph) 251 update_availability_graph)
252 252
253 self._node_level_object_store.Set(api_name, availability_graph) 253 self._node_level_object_store.Set(api_name, availability_graph)
254 return availability_graph 254 return availability_graph
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/app.yaml ('k') | chrome/common/extensions/docs/server2/caching_file_system.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698