| 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 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 determined to be 'stable' at the given version. | 201 determined to be 'stable' at the given version. |
| 202 ''' | 202 ''' |
| 203 if channel_info.channel == 'stable': | 203 if channel_info.channel == 'stable': |
| 204 return self._CheckStableAvailability(api_name, | 204 return self._CheckStableAvailability(api_name, |
| 205 file_system, | 205 file_system, |
| 206 channel_info.version) | 206 channel_info.version) |
| 207 return self._CheckChannelAvailability(api_name, | 207 return self._CheckChannelAvailability(api_name, |
| 208 file_system, | 208 file_system, |
| 209 channel_info) | 209 channel_info) |
| 210 | 210 |
| 211 def _FindScheduled(self, api_name): |
| 212 '''Determines the earliest version of Chrome where the API is stable. |
| 213 Unlike the code in GetApiAvailability, this checks if the API is stable |
| 214 even when Chrome is in dev or beta, which shows that the API is scheduled |
| 215 to be stable in that verison of Chrome. |
| 216 ''' |
| 217 def check_scheduled(file_system, channel_info): |
| 218 return self._CheckStableAvailability( |
| 219 api_name, file_system, channel_info.version) |
| 220 |
| 221 stable_availability = self._file_system_iterator.Descending( |
| 222 self._branch_utility.GetChannelInfo('dev'), check_scheduled) |
| 223 |
| 224 return stable_availability.version if stable_availability else None |
| 225 |
| 211 def GetApiAvailability(self, api_name): | 226 def GetApiAvailability(self, api_name): |
| 212 '''Performs a search for an API's top-level availability by using a | 227 '''Performs a search for an API's top-level availability by using a |
| 213 HostFileSystemIterator instance to traverse multiple version of the | 228 HostFileSystemIterator instance to traverse multiple version of the |
| 214 SVN filesystem. | 229 SVN filesystem. |
| 215 ''' | 230 ''' |
| 216 availability = self._top_level_object_store.Get(api_name).Get() | 231 availability = self._top_level_object_store.Get(api_name).Get() |
| 217 if availability is not None: | 232 if availability is not None: |
| 218 return availability | 233 return availability |
| 219 | 234 |
| 220 # Check for predetermined availability and cache this information if found. | 235 # Check for predetermined availability and cache this information if found. |
| 221 availability = self._GetPredeterminedAvailability(api_name) | 236 availability = self._GetPredeterminedAvailability(api_name) |
| 222 if availability is not None: | 237 if availability is not None: |
| 223 self._top_level_object_store.Set(api_name, availability) | 238 self._top_level_object_store.Set(api_name, availability) |
| 224 return availability | 239 return availability |
| 225 | 240 |
| 226 def check_api_availability(file_system, channel_info): | 241 def check_api_availability(file_system, channel_info): |
| 227 return self._CheckApiAvailability(api_name, file_system, channel_info) | 242 return self._CheckApiAvailability(api_name, file_system, channel_info) |
| 228 | 243 |
| 229 availability = self._file_system_iterator.Descending( | 244 availability = self._file_system_iterator.Descending( |
| 230 self._branch_utility.GetChannelInfo('dev'), | 245 self._branch_utility.GetChannelInfo('dev'), |
| 231 check_api_availability) | 246 check_api_availability) |
| 232 if availability is None: | 247 if availability is None: |
| 233 # The API wasn't available on 'dev', so it must be a 'trunk'-only API. | 248 # The API wasn't available on 'dev', so it must be a 'trunk'-only API. |
| 234 availability = self._branch_utility.GetChannelInfo('trunk') | 249 availability = self._branch_utility.GetChannelInfo('trunk') |
| 250 |
| 251 # If the API is not stable, check if it is stable in the dev or beta |
| 252 # versions of Chrome. This means that the API is scheduled to be stable. |
| 253 if availability.channel != 'stable': |
| 254 availability.scheduled = self._FindScheduled(api_name) |
| 255 |
| 235 self._top_level_object_store.Set(api_name, availability) | 256 self._top_level_object_store.Set(api_name, availability) |
| 236 return availability | 257 return availability |
| 237 | 258 |
| 238 def GetApiNodeAvailability(self, api_name): | 259 def GetApiNodeAvailability(self, api_name): |
| 239 '''Returns an APISchemaGraph annotated with each node's availability (the | 260 '''Returns an APISchemaGraph annotated with each node's availability (the |
| 240 ChannelInfo at the oldest channel it's available in). | 261 ChannelInfo at the oldest channel it's available in). |
| 241 ''' | 262 ''' |
| 242 availability_graph = self._node_level_object_store.Get(api_name).Get() | 263 availability_graph = self._node_level_object_store.Get(api_name).Get() |
| 243 if availability_graph is not None: | 264 if availability_graph is not None: |
| 244 return availability_graph | 265 return availability_graph |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 | 303 |
| 283 # Continue looping until there are no longer differences between this | 304 # Continue looping until there are no longer differences between this |
| 284 # version and trunk. | 305 # version and trunk. |
| 285 return version_stat != trunk_stat | 306 return version_stat != trunk_stat |
| 286 | 307 |
| 287 self._file_system_iterator.Ascending(self.GetApiAvailability(api_name), | 308 self._file_system_iterator.Ascending(self.GetApiAvailability(api_name), |
| 288 update_availability_graph) | 309 update_availability_graph) |
| 289 | 310 |
| 290 self._node_level_object_store.Set(api_name, availability_graph) | 311 self._node_level_object_store.Set(api_name, availability_graph) |
| 291 return availability_graph | 312 return availability_graph |
| OLD | NEW |