Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 return lambda suffix: extended_attributes['MeasureAs'] | 359 return lambda suffix: extended_attributes['MeasureAs'] |
| 360 if 'Measure' in extended_attributes: | 360 if 'Measure' in extended_attributes: |
| 361 includes.add('core/frame/UseCounter.h') | 361 includes.add('core/frame/UseCounter.h') |
| 362 measure_as_name = capitalize(definition_or_member.name) | 362 measure_as_name = capitalize(definition_or_member.name) |
| 363 if interface is not None: | 363 if interface is not None: |
| 364 measure_as_name = '%s_%s' % (capitalize(interface.name), measure_as_ name) | 364 measure_as_name = '%s_%s' % (capitalize(interface.name), measure_as_ name) |
| 365 return lambda suffix: 'V8%s_%s' % (measure_as_name, suffix) | 365 return lambda suffix: 'V8%s_%s' % (measure_as_name, suffix) |
| 366 return None | 366 return None |
| 367 | 367 |
| 368 | 368 |
| 369 # [OriginTrialEnabled] | |
| 370 def origin_trial_enabled(definition_or_member, interface): | |
|
iclelland
2016/04/05 13:38:58
This function's name suggests that it is a boolean
chasej
2016/04/05 19:50:22
The function is implemented similar to the depreca
iclelland
2016/04/07 14:00:31
With the obvious parallels to RuntimeEnabled code,
| |
| 371 extended_attributes = definition_or_member.extended_attributes | |
| 372 is_origin_trial_enabled = 'OriginTrialEnabled' in extended_attributes | |
| 373 | |
| 374 if (is_origin_trial_enabled and 'RuntimeEnabled' in extended_attributes): | |
|
iclelland
2016/04/05 13:38:58
Is there a compelling reason for this check to be
chasej
2016/04/05 19:50:22
I had the check here because it really belongs to
iclelland
2016/04/07 14:00:32
It just seems like an obvious symmetry, that it co
| |
| 375 raise Exception('[OriginTrialEnabled] and [RuntimeEnabled] must ' | |
|
iclelland
2016/04/05 13:38:58
I'd expect a more specific exception type to be ra
chasej
2016/04/05 19:50:22
Other than a few specific scenarios, most of the b
iclelland
2016/04/07 14:00:32
Acknowledged. All I had seen (without looking *too
| |
| 376 'not be specified on the same definition: ' | |
| 377 '%s.%s' % (definition_or_member.idl_name, definition_or_ member.name)) | |
| 378 | |
| 379 if is_origin_trial_enabled: | |
| 380 includes.add('core/inspector/ConsoleMessage.h') | |
| 381 includes.add('core/origin_trials/OriginTrials.h') | |
| 382 | |
| 383 trial_name = extended_attributes['OriginTrialEnabled'] | |
| 384 return 'OriginTrials::%sEnabled' % uncapitalize(trial_name) | |
| 385 | |
| 386 return None | |
| 387 | |
| 388 | |
| 369 def runtime_feature_name(definition_or_member): | 389 def runtime_feature_name(definition_or_member): |
| 370 extended_attributes = definition_or_member.extended_attributes | 390 extended_attributes = definition_or_member.extended_attributes |
| 371 if 'RuntimeEnabled' not in extended_attributes: | 391 if 'RuntimeEnabled' not in extended_attributes: |
| 372 return None | 392 return None |
| 373 return extended_attributes['RuntimeEnabled'] | 393 return extended_attributes['RuntimeEnabled'] |
| 374 | 394 |
| 375 | 395 |
| 376 def is_origin_trial_enabled(definition_or_member): | |
| 377 return 'OriginTrialEnabled' in definition_or_member.extended_attributes | |
| 378 | |
| 379 | |
| 380 def origin_trial_name(definition_or_member): | |
| 381 return definition_or_member.extended_attributes['OriginTrialEnabled'] if is_ origin_trial_enabled(definition_or_member) else None | |
| 382 | |
| 383 | |
| 384 def origin_trial_enabled_function(definition_or_member): | |
| 385 trial_name = origin_trial_name(definition_or_member) | |
| 386 feature_name = runtime_feature_name(definition_or_member) | |
| 387 if not feature_name or not trial_name: | |
| 388 return | |
| 389 return 'OriginTrials::%sEnabled' % uncapitalize(feature_name) | |
| 390 | |
| 391 | |
| 392 # [RuntimeEnabled] | 396 # [RuntimeEnabled] |
| 393 def runtime_enabled_function_name(definition_or_member): | 397 def runtime_enabled_function_name(definition_or_member): |
| 394 """Returns the name of the RuntimeEnabledFeatures function. | 398 """Returns the name of the RuntimeEnabledFeatures function. |
|
iclelland
2016/04/05 13:38:58
Document the new side effect
chasej
2016/04/05 19:50:22
Done.
| |
| 395 | 399 |
| 396 The returned function checks if a method/attribute is enabled. | 400 The returned function checks if a method/attribute is enabled. |
| 397 Given extended attribute RuntimeEnabled=FeatureName, return: | 401 Given extended attribute RuntimeEnabled=FeatureName, return: |
| 398 RuntimeEnabledFeatures::{featureName}Enabled | 402 RuntimeEnabledFeatures::{featureName}Enabled |
| 399 """ | 403 """ |
| 400 feature_name = runtime_feature_name(definition_or_member) | 404 feature_name = runtime_feature_name(definition_or_member) |
| 401 | 405 |
| 402 # If an origin trial is on the method/attribute, it overrides the runtime | 406 # If an origin trial is on the method/attribute, it overrides the runtime |
| 403 # enabled status. For now, we are unconditionally installing these | 407 # enabled status. For now, we are unconditionally installing these |
| 404 # attributes/methods, so we are acting as though the runtime enabled | 408 # attributes/methods, so we are acting as though the runtime enabled |
| 405 # function doesn't exist. (It is checked in the generated OriginTrials | 409 # function doesn't exist. (It is checked in the generated OriginTrials |
| 406 # function, instead) | 410 # function, instead) |
| 407 trial_name = origin_trial_name(definition_or_member) | 411 trial_enabled = origin_trial_enabled(definition_or_member, None) |
| 408 if not feature_name or trial_name: | 412 if not feature_name or trial_enabled: |
|
haraken
2016/04/05 01:23:18
Do we still need this check?
chasej
2016/04/05 19:50:22
You're right, we probably don't need this check an
| |
| 409 return | 413 return |
| 414 | |
| 415 includes.add('platform/RuntimeEnabledFeatures.h') | |
| 410 return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name) | 416 return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name) |
| 411 | 417 |
| 412 | 418 |
| 413 # [Unforgeable] | 419 # [Unforgeable] |
| 414 def is_unforgeable(interface, member): | 420 def is_unforgeable(interface, member): |
| 415 return (('Unforgeable' in interface.extended_attributes or | 421 return (('Unforgeable' in interface.extended_attributes or |
| 416 'Unforgeable' in member.extended_attributes) and | 422 'Unforgeable' in member.extended_attributes) and |
| 417 not member.is_static) | 423 not member.is_static) |
| 418 | 424 |
| 419 | 425 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 593 except StopIteration: | 599 except StopIteration: |
| 594 return None | 600 return None |
| 595 | 601 |
| 596 | 602 |
| 597 IdlInterface.indexed_property_getter = property(indexed_property_getter) | 603 IdlInterface.indexed_property_getter = property(indexed_property_getter) |
| 598 IdlInterface.indexed_property_setter = property(indexed_property_setter) | 604 IdlInterface.indexed_property_setter = property(indexed_property_setter) |
| 599 IdlInterface.indexed_property_deleter = property(indexed_property_deleter) | 605 IdlInterface.indexed_property_deleter = property(indexed_property_deleter) |
| 600 IdlInterface.named_property_getter = property(named_property_getter) | 606 IdlInterface.named_property_getter = property(named_property_getter) |
| 601 IdlInterface.named_property_setter = property(named_property_setter) | 607 IdlInterface.named_property_setter = property(named_property_setter) |
| 602 IdlInterface.named_property_deleter = property(named_property_deleter) | 608 IdlInterface.named_property_deleter = property(named_property_deleter) |
| OLD | NEW |