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

Side by Side Diff: Source/core/inspector/CodeGeneratorInspector.py

Issue 1129473003: DevTools: respond with error when Debugger command is sent to disabled debugger agent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed comments, added checks in DOMDebugger Created 5 years, 7 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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 Google Inc. All rights reserved. 2 # Copyright (c) 2011 Google Inc. All rights reserved.
3 # Copyright (c) 2012 Intel Corporation. All rights reserved. 3 # Copyright (c) 2012 Intel Corporation. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are 6 # modification, are permitted provided that the following conditions are
7 # met: 7 # met:
8 # 8 #
9 # * Redistributions of source code must retain the above copyright 9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 TYPES_WITH_RUNTIME_CAST_SET = frozenset(["Runtime.RemoteObject", "Runtime.Proper tyDescriptor", "Runtime.InternalPropertyDescriptor", 50 TYPES_WITH_RUNTIME_CAST_SET = frozenset(["Runtime.RemoteObject", "Runtime.Proper tyDescriptor", "Runtime.InternalPropertyDescriptor",
51 "Debugger.FunctionDetails", "Debugger.G eneratorObjectDetails", "Debugger.CollectionEntry", "Debugger.CallFrame", "Debug ger.Location"]) 51 "Debugger.FunctionDetails", "Debugger.G eneratorObjectDetails", "Debugger.CollectionEntry", "Debugger.CallFrame", "Debug ger.Location"])
52 52
53 TYPES_WITH_OPEN_FIELD_LIST_SET = frozenset([ 53 TYPES_WITH_OPEN_FIELD_LIST_SET = frozenset([
54 # InspectorStyleSheet not only creat es this property but wants to read it and modify it. 54 # InspectorStyleSheet not only creat es this property but wants to read it and modify it.
55 "CSS.CSSProperty", 55 "CSS.CSSProperty",
56 # InspectorResourceAgent needs to up date mime-type. 56 # InspectorResourceAgent needs to up date mime-type.
57 "Network.Response"]) 57 "Network.Response"])
58 58
59 DOMAINS_WITH_ENABLEMENT_CHECK = frozenset(["DOMDebugger", "Debugger"])
60
59 cmdline_parser = optparse.OptionParser() 61 cmdline_parser = optparse.OptionParser()
60 cmdline_parser.add_option("--output_dir") 62 cmdline_parser.add_option("--output_dir")
61 63
62 try: 64 try:
63 arg_options, arg_values = cmdline_parser.parse_args() 65 arg_options, arg_values = cmdline_parser.parse_args()
64 if (len(arg_values) != 1): 66 if (len(arg_values) != 1):
65 raise Exception("Exactly one plain argument expected (found %s)" % len(a rg_values)) 67 raise Exception("Exactly one plain argument expected (found %s)" % len(a rg_values))
66 input_json_filename = arg_values[0] 68 input_json_filename = arg_values[0]
67 output_dirname = arg_options.output_dir 69 output_dirname = arg_options.output_dir
68 if not output_dirname: 70 if not output_dirname:
(...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 domainClassName=domain_name, 1647 domainClassName=domain_name,
1646 domainFieldName=domain_name_lower, 1648 domainFieldName=domain_name_lower,
1647 frontendDomainMethodDeclarations="".join(flatten_list(frontend_m ethod_declaration_lines)))) 1649 frontendDomainMethodDeclarations="".join(flatten_list(frontend_m ethod_declaration_lines))))
1648 1650
1649 agent_interface_name = Capitalizer.lower_camel_case_to_upper(domain_ name) + "CommandHandler" 1651 agent_interface_name = Capitalizer.lower_camel_case_to_upper(domain_ name) + "CommandHandler"
1650 Generator.backend_agent_interface_list.append(" class %s {\n" % a gent_interface_name) 1652 Generator.backend_agent_interface_list.append(" class %s {\n" % a gent_interface_name)
1651 Generator.backend_agent_interface_list.append(" public:\n") 1653 Generator.backend_agent_interface_list.append(" public:\n")
1652 if "commands" in json_domain: 1654 if "commands" in json_domain:
1653 for json_command in json_domain["commands"]: 1655 for json_command in json_domain["commands"]:
1654 Generator.process_command(json_command, domain_name, agent_f ield_name, agent_interface_name) 1656 Generator.process_command(json_command, domain_name, agent_f ield_name, agent_interface_name)
1657 if domain_name in DOMAINS_WITH_ENABLEMENT_CHECK:
1658 Generator.backend_agent_interface_list.append("\n virtual boo l checkEnabled(ErrorString*) = 0;\n")
1655 Generator.backend_agent_interface_list.append("\n protected:\n") 1659 Generator.backend_agent_interface_list.append("\n protected:\n")
1656 Generator.backend_agent_interface_list.append(" virtual ~%s() { }\n" % agent_interface_name) 1660 Generator.backend_agent_interface_list.append(" virtual ~%s() { }\n" % agent_interface_name)
1657 Generator.backend_agent_interface_list.append(" };\n\n") 1661 Generator.backend_agent_interface_list.append(" };\n\n")
1658 1662
1659 Generator.backend_constructor_init_list.append(" , m_%s(0)" % agent_field_name) 1663 Generator.backend_constructor_init_list.append(" , m_%s(0)" % agent_field_name)
1660 Generator.backend_virtual_setters_list.append(" virtual void regi sterAgent(%s* %s) = 0;" % (agent_interface_name, agent_field_name)) 1664 Generator.backend_virtual_setters_list.append(" virtual void regi sterAgent(%s* %s) = 0;" % (agent_interface_name, agent_field_name))
1661 Generator.backend_setters_list.append(" virtual void registerAgen t(%s* %s) { ASSERT(!m_%s); m_%s = %s; }" % (agent_interface_name, agent_field_na me, agent_field_name, agent_field_name, agent_field_name)) 1665 Generator.backend_setters_list.append(" virtual void registerAgen t(%s* %s) { ASSERT(!m_%s); m_%s = %s; }" % (agent_interface_name, agent_field_na me, agent_field_name, agent_field_name, agent_field_name))
1662 Generator.backend_field_list.append(" %s* m_%s;" % (agent_interfa ce_name, agent_field_name)) 1666 Generator.backend_field_list.append(" %s* m_%s;" % (agent_interfa ce_name, agent_field_name))
1663 1667
1664 @staticmethod 1668 @staticmethod
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 ad_hoc_type_output = [] 1716 ad_hoc_type_output = []
1713 backend_agent_interface_list.append(ad_hoc_type_output) 1717 backend_agent_interface_list.append(ad_hoc_type_output)
1714 ad_hoc_type_writer = Writer(ad_hoc_type_output, " ") 1718 ad_hoc_type_writer = Writer(ad_hoc_type_output, " ")
1715 1719
1716 backend_agent_interface_list.append(" virtual void %s(ErrorString *" % json_command_name) 1720 backend_agent_interface_list.append(" virtual void %s(ErrorString *" % json_command_name)
1717 1721
1718 method_in_code = "" 1722 method_in_code = ""
1719 method_out_code = "" 1723 method_out_code = ""
1720 agent_call_param_list = ["&error"] 1724 agent_call_param_list = ["&error"]
1721 agent_call_params_declaration_list = [" ErrorString error;"] 1725 agent_call_params_declaration_list = [" ErrorString error;"]
1726 agent_enablement_check = ""
1727 if domain_name in DOMAINS_WITH_ENABLEMENT_CHECK and json_command["name"] != "enable":
1728 agent_enablement_check = " if (!m_" + agent_field_name + "->check Enabled(&error)) {\n"
1729 agent_enablement_check += " reportProtocolError(callId, Serve rError, error);\n"
pfeldman 2015/05/05 14:00:13 - This is not a server error, this is rather illeg
1730 agent_enablement_check += " return;\n"
1731 agent_enablement_check += " }\n"
1722 send_response_call_params_list = ["error"] 1732 send_response_call_params_list = ["error"]
1723 request_message_param = "" 1733 request_message_param = ""
1724 normal_response_cook_text = "" 1734 normal_response_cook_text = ""
1725 error_type_binding = None 1735 error_type_binding = None
1726 if "error" in json_command: 1736 if "error" in json_command:
1727 json_error = json_command["error"] 1737 json_error = json_command["error"]
1728 error_type_binding = Generator.resolve_type_and_generate_ad_hoc(json _error, json_command_name + "Error", json_command_name, domain_name, ad_hoc_type _writer, agent_interface_name + "::") 1738 error_type_binding = Generator.resolve_type_and_generate_ad_hoc(json _error, json_command_name + "Error", json_command_name, domain_name, ad_hoc_type _writer, agent_interface_name + "::")
1729 error_type_model = error_type_binding.get_type_model().get_optional( ) 1739 error_type_model = error_type_binding.get_type_model().get_optional( )
1730 error_annotated_type = error_type_model.get_command_return_pass_mode l().get_output_parameter_type() 1740 error_annotated_type = error_type_model.get_command_return_pass_mode l().get_output_parameter_type()
1731 agent_call_param_list.append("%serrorData" % error_type_model.get_co mmand_return_pass_model().get_output_argument_prefix()) 1741 agent_call_param_list.append("%serrorData" % error_type_model.get_co mmand_return_pass_model().get_output_argument_prefix())
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 agent_field = "m_" + agent_field_name 1878 agent_field = "m_" + agent_field_name
1869 if "redirect" in json_command: 1879 if "redirect" in json_command:
1870 agent_field = "m_" + DomainNameFixes.get_fixed_data(json_command.get ("redirect")) 1880 agent_field = "m_" + DomainNameFixes.get_fixed_data(json_command.get ("redirect"))
1871 1881
1872 Generator.backend_method_implementation_list.append(Templates.backend_me thod.substitute(None, 1882 Generator.backend_method_implementation_list.append(Templates.backend_me thod.substitute(None,
1873 domainName=domain_name, methodName=json_command_name, 1883 domainName=domain_name, methodName=json_command_name,
1874 agentField=agent_field, 1884 agentField=agent_field,
1875 methodCode="".join([method_in_code, method_out_code]), 1885 methodCode="".join([method_in_code, method_out_code]),
1876 agentCallParamsDeclaration="\n".join(agent_call_params_declaration_l ist), 1886 agentCallParamsDeclaration="\n".join(agent_call_params_declaration_l ist),
1877 agentCallParams=", ".join(agent_call_param_list), 1887 agentCallParams=", ".join(agent_call_param_list),
1888 agentEnablementCheck=agent_enablement_check,
1878 requestMessageObject=request_message_param, 1889 requestMessageObject=request_message_param,
1879 responseCook=normal_response_cook_text, 1890 responseCook=normal_response_cook_text,
1880 sendResponseCallParams=", ".join(send_response_call_params_list), 1891 sendResponseCallParams=", ".join(send_response_call_params_list),
1881 commandNameIndex=cmd_enum_name)) 1892 commandNameIndex=cmd_enum_name))
1882 declaration_command_name = "%s.%s\\0" % (domain_name, json_command_name) 1893 declaration_command_name = "%s.%s\\0" % (domain_name, json_command_name)
1883 Generator.backend_method_name_declaration_list.append(" \"%s\"" % dec laration_command_name) 1894 Generator.backend_method_name_declaration_list.append(" \"%s\"" % dec laration_command_name)
1884 assert Generator.backend_method_name_declaration_current_index < 2 ** 16 , "Number too large for unsigned short." 1895 assert Generator.backend_method_name_declaration_current_index < 2 ** 16 , "Number too large for unsigned short."
1885 Generator.backend_method_name_declaration_index_list.append(" %d," % Generator.backend_method_name_declaration_current_index) 1896 Generator.backend_method_name_declaration_index_list.append(" %d," % Generator.backend_method_name_declaration_current_index)
1886 Generator.backend_method_name_declaration_current_index += len(declarati on_command_name) - 1 1897 Generator.backend_method_name_declaration_current_index += len(declarati on_command_name) - 1
1887 1898
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 validatorIfdefName=VALIDATOR_IFDEF_NAME)) 2129 validatorIfdefName=VALIDATOR_IFDEF_NAME))
2119 2130
2120 backend_h_file.close() 2131 backend_h_file.close()
2121 backend_cpp_file.close() 2132 backend_cpp_file.close()
2122 2133
2123 frontend_h_file.close() 2134 frontend_h_file.close()
2124 frontend_cpp_file.close() 2135 frontend_cpp_file.close()
2125 2136
2126 typebuilder_h_file.close() 2137 typebuilder_h_file.close()
2127 typebuilder_cpp_file.close() 2138 typebuilder_cpp_file.close()
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/ScriptDebugServer.cpp ('k') | Source/core/inspector/CodeGeneratorInspectorStrings.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698