| 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 posixpath | 5 import posixpath |
| 6 | 6 |
| 7 from api_models import GetNodeCategories | 7 from api_models import GetNodeCategories |
| 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 compiled_file_system import CompiledFileSystem, SingleFile, Unicode | 10 from compiled_file_system import CompiledFileSystem, SingleFile, Unicode |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 return _GetChannelFromFeatures(api_name, | 52 return _GetChannelFromFeatures(api_name, |
| 53 features_bundle.GetPermissionFeatures()) | 53 features_bundle.GetPermissionFeatures()) |
| 54 | 54 |
| 55 | 55 |
| 56 def _GetAPISchemaFilename(api_name, file_system, version): | 56 def _GetAPISchemaFilename(api_name, file_system, version): |
| 57 '''Gets the name of the file which may contain the schema for |api_name| in | 57 '''Gets the name of the file which may contain the schema for |api_name| in |
| 58 |file_system|, or None if the API is not found. Note that this may be the | 58 |file_system|, or None if the API is not found. Note that this may be the |
| 59 single _EXTENSION_API file which all APIs share in older versions of Chrome, | 59 single _EXTENSION_API file which all APIs share in older versions of Chrome, |
| 60 in which case it is unknown whether the API actually exists there. | 60 in which case it is unknown whether the API actually exists there. |
| 61 ''' | 61 ''' |
| 62 if version == 'trunk' or version > _ORIGINAL_FEATURES_MIN_VERSION: | 62 if version == 'master' or version > _ORIGINAL_FEATURES_MIN_VERSION: |
| 63 # API schema filenames switch format to unix_hacker_style. | 63 # API schema filenames switch format to unix_hacker_style. |
| 64 api_name = UnixName(api_name) | 64 api_name = UnixName(api_name) |
| 65 | 65 |
| 66 # Devtools API names have 'devtools.' prepended to them. | 66 # Devtools API names have 'devtools.' prepended to them. |
| 67 # The corresponding filenames do not. | 67 # The corresponding filenames do not. |
| 68 if 'devtools_' in api_name: | 68 if 'devtools_' in api_name: |
| 69 api_name = api_name.replace('devtools_', '') | 69 api_name = api_name.replace('devtools_', '') |
| 70 | 70 |
| 71 for api_path in API_PATHS: | 71 for api_path in API_PATHS: |
| 72 try: | 72 try: |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 self._top_level_object_store.Set(api_name, availability) | 361 self._top_level_object_store.Set(api_name, availability) |
| 362 return availability | 362 return availability |
| 363 | 363 |
| 364 def check_api_availability(file_system, channel_info): | 364 def check_api_availability(file_system, channel_info): |
| 365 return self._CheckAPIAvailability(api_name, file_system, channel_info) | 365 return self._CheckAPIAvailability(api_name, file_system, channel_info) |
| 366 | 366 |
| 367 channel_info = self._file_system_iterator.Descending( | 367 channel_info = self._file_system_iterator.Descending( |
| 368 self._branch_utility.GetChannelInfo('dev'), | 368 self._branch_utility.GetChannelInfo('dev'), |
| 369 check_api_availability) | 369 check_api_availability) |
| 370 if channel_info is None: | 370 if channel_info is None: |
| 371 # The API wasn't available on 'dev', so it must be a 'trunk'-only API. | 371 # The API wasn't available on 'dev', so it must be a 'master'-only API. |
| 372 channel_info = self._branch_utility.GetChannelInfo('trunk') | 372 channel_info = self._branch_utility.GetChannelInfo('master') |
| 373 | 373 |
| 374 # If the API is not stable, check when it will be scheduled to be stable. | 374 # If the API is not stable, check when it will be scheduled to be stable. |
| 375 if channel_info.channel == 'stable': | 375 if channel_info.channel == 'stable': |
| 376 scheduled = None | 376 scheduled = None |
| 377 else: | 377 else: |
| 378 scheduled = self._FindScheduled(api_name) | 378 scheduled = self._FindScheduled(api_name) |
| 379 | 379 |
| 380 availability = AvailabilityInfo(channel_info, scheduled=scheduled) | 380 availability = AvailabilityInfo(channel_info, scheduled=scheduled) |
| 381 | 381 |
| 382 self._top_level_object_store.Set(api_name, availability) | 382 self._top_level_object_store.Set(api_name, availability) |
| 383 return availability | 383 return availability |
| 384 | 384 |
| 385 def GetAPINodeAvailability(self, api_name): | 385 def GetAPINodeAvailability(self, api_name): |
| 386 '''Returns an APISchemaGraph annotated with each node's availability (the | 386 '''Returns an APISchemaGraph annotated with each node's availability (the |
| 387 ChannelInfo at the oldest channel it's available in). | 387 ChannelInfo at the oldest channel it's available in). |
| 388 ''' | 388 ''' |
| 389 availability_graph = self._node_level_object_store.Get(api_name).Get() | 389 availability_graph = self._node_level_object_store.Get(api_name).Get() |
| 390 if availability_graph is not None: | 390 if availability_graph is not None: |
| 391 return availability_graph | 391 return availability_graph |
| 392 | 392 |
| 393 def assert_not_none(value): | 393 def assert_not_none(value): |
| 394 assert value is not None | 394 assert value is not None |
| 395 return value | 395 return value |
| 396 | 396 |
| 397 availability_graph = APISchemaGraph() | 397 availability_graph = APISchemaGraph() |
| 398 host_fs = self._host_file_system | 398 host_fs = self._host_file_system |
| 399 trunk_stat = assert_not_none(host_fs.Stat(_GetAPISchemaFilename( | 399 master_stat = assert_not_none(host_fs.Stat(_GetAPISchemaFilename( |
| 400 api_name, host_fs, 'trunk'))) | 400 api_name, host_fs, 'master'))) |
| 401 | 401 |
| 402 # Weird object thing here because nonlocal is Python 3. | 402 # Weird object thing here because nonlocal is Python 3. |
| 403 previous = type('previous', (object,), {'stat': None, 'graph': None}) | 403 previous = type('previous', (object,), {'stat': None, 'graph': None}) |
| 404 | 404 |
| 405 def update_availability_graph(file_system, channel_info): | 405 def update_availability_graph(file_system, channel_info): |
| 406 # If we can't find a filename, skip checking at this branch. | 406 # If we can't find a filename, skip checking at this branch. |
| 407 # For example, something could have a predetermined availability of 23, | 407 # For example, something could have a predetermined availability of 23, |
| 408 # but it doesn't show up in the file system until 26. | 408 # but it doesn't show up in the file system until 26. |
| 409 # We know that the file will become available at some point. | 409 # We know that the file will become available at some point. |
| 410 # | 410 # |
| (...skipping 28 matching lines...) Expand all Loading... |
| 439 return self._CheckAPINodeAvailability('%s.%s' % (api_name, node_name), | 439 return self._CheckAPINodeAvailability('%s.%s' % (api_name, node_name), |
| 440 channel_info) | 440 channel_info) |
| 441 | 441 |
| 442 availability_graph.Update(version_graph.Subtract(availability_graph), | 442 availability_graph.Update(version_graph.Subtract(availability_graph), |
| 443 annotator) | 443 annotator) |
| 444 | 444 |
| 445 previous.stat = version_stat | 445 previous.stat = version_stat |
| 446 previous.graph = version_graph | 446 previous.graph = version_graph |
| 447 | 447 |
| 448 # Continue looping until there are no longer differences between this | 448 # Continue looping until there are no longer differences between this |
| 449 # version and trunk. | 449 # version and master. |
| 450 return version_stat != trunk_stat | 450 return version_stat != master_stat |
| 451 | 451 |
| 452 self._file_system_iterator.Ascending( | 452 self._file_system_iterator.Ascending( |
| 453 self.GetAPIAvailability(api_name).channel_info, | 453 self.GetAPIAvailability(api_name).channel_info, |
| 454 update_availability_graph) | 454 update_availability_graph) |
| 455 | 455 |
| 456 self._node_level_object_store.Set(api_name, availability_graph) | 456 self._node_level_object_store.Set(api_name, availability_graph) |
| 457 return availability_graph | 457 return availability_graph |
| OLD | NEW |