summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorvkuzkokov <vkuzkokov@chromium.org>2014-12-03 04:20:38 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-03 12:21:09 +0000
commit0f1372f8bba274ada49d6cb859b21c9459e5199f (patch)
tree112c0e444b835ad198412af17ca1dd86d4ca7614 /content
parenta12855418a74cf01d26d281231079a6ec5da710d (diff)
downloadchromium_src-0f1372f8bba274ada49d6cb859b21c9459e5199f.zip
chromium_src-0f1372f8bba274ada49d6cb859b21c9459e5199f.tar.gz
chromium_src-0f1372f8bba274ada49d6cb859b21c9459e5199f.tar.bz2
[DevTools] Removed devtools_protocol_constants in content
BUG=405566 Review URL: https://codereview.chromium.org/737763003 Cr-Commit-Position: refs/heads/master@{#306591}
Diffstat (limited to 'content')
-rw-r--r--content/browser/BUILD.gn2
-rw-r--r--content/browser/devtools/BUILD.gn26
-rw-r--r--content/browser/devtools/devtools_http_handler_impl.cc1
-rw-r--r--content/browser/devtools/devtools_resources.gyp28
-rwxr-xr-xcontent/browser/devtools/protocol/devtools_protocol_handler_generator.py18
-rw-r--r--content/content_browser.gypi3
-rwxr-xr-xcontent/public/browser/devtools_protocol_constants_generator.py211
7 files changed, 18 insertions, 271 deletions
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
index ccccb62..feb93d76 100644
--- a/content/browser/BUILD.gn
+++ b/content/browser/BUILD.gn
@@ -83,8 +83,6 @@ source_set("browser") {
"$root_gen_dir/webkit/grit/devtools_resources_map.h",
"$root_gen_dir/content/browser/tracing/grit/tracing_resources.h",
"$root_gen_dir/ui/resources/grit/webui_resources_map.cc",
- "$root_gen_dir/content/browser/devtools/devtools_protocol_constants.cc",
- "$root_gen_dir/content/browser/devtools/devtools_protocol_constants.h",
"$root_gen_dir/content/browser/devtools/protocol/devtools_protocol_handler_impl.cc",
"$root_gen_dir/content/browser/devtools/protocol/devtools_protocol_handler_impl.h",
], ".")
diff --git a/content/browser/devtools/BUILD.gn b/content/browser/devtools/BUILD.gn
index 19a4003..9a8fa4f 100644
--- a/content/browser/devtools/BUILD.gn
+++ b/content/browser/devtools/BUILD.gn
@@ -8,7 +8,6 @@ import("//tools/grit/grit_rule.gni")
group("resources") {
deps = [
":devtools_resources",
- ":devtools_protocol_constants",
":devtools_protocol_handler",
]
}
@@ -37,26 +36,6 @@ grit("devtools_resources") {
]
}
-action("gen_devtools_protocol_constants") {
- visibility = [ ":devtools_protocol_constants" ]
-
- script = "//content/public/browser/devtools_protocol_constants_generator.py"
-
- blink_protocol = "//third_party/WebKit/Source/devtools/protocol.json"
- browser_protocol = "browser_protocol.json"
- inputs = [ blink_protocol, browser_protocol ]
-
- outputs = [
- "$target_gen_dir/devtools_protocol_constants.cc",
- "$target_gen_dir/devtools_protocol_constants.h",
- ]
-
- args = [ "content" ] + rebase_path(outputs, root_build_dir) + [
- rebase_path(blink_protocol, root_build_dir),
- rebase_path(browser_protocol, root_build_dir),
- ]
-}
-
action("gen_devtools_protocol_handler") {
visibility = [ ":devtools_protocol_handler" ]
@@ -76,11 +55,6 @@ action("gen_devtools_protocol_handler") {
rebase_path(outputs, root_build_dir)
}
-source_set("devtools_protocol_constants") {
- visibility = [ ":resources" ]
- sources = get_target_outputs(":gen_devtools_protocol_constants")
-}
-
source_set("devtools_protocol_handler") {
visibility = [ ":resources" ]
sources = get_target_outputs(":gen_devtools_protocol_handler")
diff --git a/content/browser/devtools/devtools_http_handler_impl.cc b/content/browser/devtools/devtools_http_handler_impl.cc
index f3aa4a3..3f3df91 100644
--- a/content/browser/devtools/devtools_http_handler_impl.cc
+++ b/content/browser/devtools/devtools_http_handler_impl.cc
@@ -17,7 +17,6 @@
#include "base/values.h"
#include "content/browser/devtools/devtools_manager.h"
#include "content/browser/devtools/devtools_protocol.h"
-#include "content/browser/devtools/devtools_protocol_constants.h"
#include "content/browser/devtools/protocol/devtools_protocol_handler_impl.h"
#include "content/browser/devtools/protocol/system_info_handler.h"
#include "content/browser/devtools/protocol/tethering_handler.h"
diff --git a/content/browser/devtools/devtools_resources.gyp b/content/browser/devtools/devtools_resources.gyp
index 72ae706..3b82cc3 100644
--- a/content/browser/devtools/devtools_resources.gyp
+++ b/content/browser/devtools/devtools_resources.gyp
@@ -43,34 +43,6 @@
'<@(grit_rc_header_format)'],
'message': 'Generating resources from <(grit_grd_file)',
},
- {
- 'action_name': 'devtools_protocol_constants',
- 'variables': {
- 'blink_protocol': '../../../third_party/WebKit/Source/devtools/protocol.json',
- 'browser_protocol': 'browser_protocol.json',
- 'generator': '../../public/browser/devtools_protocol_constants_generator.py',
- 'package': 'content'
- },
- 'inputs': [
- '<(blink_protocol)',
- '<(browser_protocol)',
- '<(generator)',
- ],
- 'outputs': [
- '<(SHARED_INTERMEDIATE_DIR)/<(package)/browser/devtools/devtools_protocol_constants.cc',
- '<(SHARED_INTERMEDIATE_DIR)/<(package)/browser/devtools/devtools_protocol_constants.h'
- ],
- 'action':[
- 'python',
- '<(generator)',
- '<(package)',
- '<(SHARED_INTERMEDIATE_DIR)/<(package)/browser/devtools/devtools_protocol_constants.cc',
- '<(SHARED_INTERMEDIATE_DIR)/<(package)/browser/devtools/devtools_protocol_constants.h',
- '<(blink_protocol)',
- '<(browser_protocol)',
- ],
- 'message': 'Generating DevTools protocol constants from <(blink_protocol)'
- }
],
'direct_dependent_settings': {
'include_dirs': [
diff --git a/content/browser/devtools/protocol/devtools_protocol_handler_generator.py b/content/browser/devtools/protocol/devtools_protocol_handler_generator.py
index 9138e26..e35f2f9 100755
--- a/content/browser/devtools/protocol/devtools_protocol_handler_generator.py
+++ b/content/browser/devtools/protocol/devtools_protocol_handler_generator.py
@@ -38,6 +38,10 @@ class DevToolsProtocolHandlerImpl;
namespace devtools {
+extern const char kProtocolVersion[];
+
+bool IsSupportedProtocolVersion(const std::string& version);
+
template<typename T>
base::Value* CreateValue(const T& param) {
return new base::FundamentalValue(param);
@@ -227,6 +231,7 @@ template_cc = string.Template(header + """\
#include "content/browser/devtools/protocol/devtools_protocol_handler_impl.h"
#include "base/bind.h"
+#include "base/strings/string_number_conversions.h"
${includes}\
namespace content {
@@ -271,6 +276,17 @@ ${methods}\
namespace devtools {
+const char kProtocolVersion[] = "${major}.${minor}";
+
+bool IsSupportedProtocolVersion(const std::string& version) {
+ std::vector<std::string> tokens;
+ Tokenize(version, ".", &tokens);
+ int major, minor;
+ return tokens.size() == 2 &&
+ base::StringToInt(tokens[0], &major) && major == ${major} &&
+ base::StringToInt(tokens[1], &minor) && minor <= ${minor};
+}
+
template<>
base::Value* CreateValue(const std::string& param) {
return new base::StringValue(param);
@@ -730,6 +746,8 @@ output_h_file.write(template_h.substitute({},
output_h_file.close()
output_cc_file.write(template_cc.substitute({},
+ major = blink_protocol["version"]["major"],
+ minor = blink_protocol["version"]["minor"],
includes = "".join(sorted(includes)),
fields_init = ",\n ".join(fields_init),
methods = "\n".join(handler_method_impls),
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 819ce32..cf826c6 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -1421,9 +1421,6 @@
'<(SHARED_INTERMEDIATE_DIR)/webkit/grit/devtools_resources_map.h',
'<(SHARED_INTERMEDIATE_DIR)/content/browser/tracing/grit/tracing_resources.h',
'<(SHARED_INTERMEDIATE_DIR)/ui/resources/grit/webui_resources_map.cc',
- # These files are generated by devtools_protocol_constants_generator.py.
- '<(SHARED_INTERMEDIATE_DIR)/content/browser/devtools/devtools_protocol_constants.cc',
- '<(SHARED_INTERMEDIATE_DIR)/content/browser/devtools/devtools_protocol_constants.h',
# These files are generated by devtools_protocol_handler_generator.py.
'<(SHARED_INTERMEDIATE_DIR)/content/browser/devtools/protocol/devtools_protocol_handler_impl.cc',
'<(SHARED_INTERMEDIATE_DIR)/content/browser/devtools/protocol/devtools_protocol_handler_impl.h',
diff --git a/content/public/browser/devtools_protocol_constants_generator.py b/content/public/browser/devtools_protocol_constants_generator.py
deleted file mode 100755
index 3447fb1..0000000
--- a/content/public/browser/devtools_protocol_constants_generator.py
+++ /dev/null
@@ -1,211 +0,0 @@
-#!/usr/bin/python
-# Copyright 2014 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import sys
-import string
-import json
-
-package = sys.argv[1]
-output_cc_path = sys.argv[2]
-output_h_path = sys.argv[3]
-blink_protocol_path = sys.argv[4]
-browser_protocol_path = sys.argv[5] if len(sys.argv) > 5 else None
-
-template_h = string.Template("""\
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ${PACKAGE}_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_CONSTANTS_H_
-#define ${PACKAGE}_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_CONSTANTS_H_
-
-// THIS FILE IS AUTOGENERATED. DO NOT EDIT.
-// Generated by
-// content/public/browser/devtools_protocol_constants_generator.py from
-// third_party/WebKit/Source/devtools/protocol.json and
-// content/browser/devtools/browser_protocol.json
-
-#include <string>
-
-namespace $package {
-namespace devtools {
-
-extern const char kProtocolVersion[];
-
-bool IsSupportedProtocolVersion(const std::string& version);
-
-extern const char kResult[];
-$contents
-
-} // devtools
-} // $package
-
-#endif // ${PACKAGE}_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_CONSTANTS_H_
-""")
-
-template_cc = string.Template("""\
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// THIS FILE IS AUTOGENERATED. DO NOT EDIT.
-// Generated by
-// content/public/browser/devtools_protocol_constants_generator.py from
-// third_party/WebKit/Source/devtools/protocol.json and
-// content/browser/devtools/browser_protocol.json
-
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/string_util.h"
-#include "$package/browser/devtools/devtools_protocol_constants.h"
-
-namespace $package {
-namespace devtools {
-
-const char kProtocolVersion[] = "$major.$minor";
-
-bool IsSupportedProtocolVersion(const std::string& version) {
- std::vector<std::string> tokens;
- Tokenize(version, ".", &tokens);
- int major, minor;
- return tokens.size() == 2 &&
- base::StringToInt(tokens[0], &major) && major == $major &&
- base::StringToInt(tokens[1], &minor) && minor <= $minor;
-}
-
-const char kResult[] = "result";
-$contents
-
-} // devtools
-} // $package
-""")
-
-def Capitalize(s):
- return s[:1].capitalize() + s[1:]
-
-references = []
-
-def CreateNamespace(domain_name, data, keys, prefixes, name = None):
- result = {}
- if name:
- result["kName"] = name
- for i, key in enumerate(keys):
- if key in data:
- for parameter in data[key]:
- parameter_name = parameter["name"];
- result[prefixes[i] + Capitalize(parameter_name)] = parameter_name
- if "enum" in parameter:
- enum_name = Capitalize(parameter_name)
- result[enum_name] = {}
- for enum in parameter["enum"]:
- result[enum_name]["kEnum" + Capitalize(enum)] = enum
- reference = ""
- if "$ref" in parameter:
- reference = parameter["$ref"]
- if "items" in parameter and "$ref" in parameter["items"]:
- reference = parameter["items"]["$ref"]
- if reference:
- if not "." in reference:
- reference = domain_name + "." + reference
- references.append(reference)
- return result
-
-def IsHandledInBrowser(item):
- return "handlers" in item and "browser" in item["handlers"]
-
-def FormatContents(tree, indent, format_string):
- outer = dict((key, value) for key, value in tree.iteritems()
- if not isinstance(value, dict))
- inner = dict((key, value) for key, value in tree.iteritems()
- if isinstance(value, dict))
- body = ""
- body += "".join(indent + format_string.format(key, value)
- for (key, value) in sorted(outer.items()))
- body += "".join(FormatNamespace(key, value, indent, format_string)
- for (key, value) in sorted(inner.items()))
- return body
-
-def FormatNamespace(title, tree, indent, format_string):
- if (not tree):
- return ""
- body = '\n' + indent + "namespace " + title + " {\n"
- body += FormatContents(tree, indent + " ", format_string)
- body += indent + "} // " + title + "\n"
- return body
-
-def CreateHeader(tree, output_file):
- contents = FormatContents(tree, "", "extern const char {0}[];\n")
- output_file.write(template_h.substitute({
- "contents": contents,
- "package": package,
- "PACKAGE": package.upper()
- }))
-
-def CreateBody(tree, version, output_file):
- contents = FormatContents(tree, "", "const char {0}[] = \"{1}\";\n")
- output_file.write(template_cc.substitute({
- "major": version["major"],
- "minor": version["minor"],
- "contents": contents,
- "package": package
- }))
-
-blink_protocol_data = open(blink_protocol_path).read()
-blink_protocol = json.loads(blink_protocol_data)
-blink_version = blink_protocol["version"]
-
-domains = blink_protocol["domains"]
-
-if browser_protocol_path:
- browser_protocol_data = open(browser_protocol_path).read()
- browser_protocol = json.loads(browser_protocol_data)
- domains = domains + browser_protocol["domains"]
-
-namespace_tree = {}
-
-for domain in domains:
- domain_value = {}
- domain_namespace_name = Capitalize(domain["domain"])
- if "commands" in domain:
- for command in domain["commands"]:
- if (IsHandledInBrowser(command)):
- domain_value[command["name"]] = CreateNamespace(domain["domain"],
- command, ["parameters", "returns"], ["kParam", "kResponse"],
- domain_namespace_name + "." + command["name"])
-
- if "events" in domain:
- for event in domain["events"]:
- if IsHandledInBrowser(event):
- domain_value[event["name"]] = CreateNamespace(domain["domain"],
- event, ["parameters"], ["kParam"],
- domain_namespace_name + "." + event["name"])
- if domain_value:
- namespace_tree[domain_namespace_name] = domain_value
-
-while (references):
- reference = references.pop();
- path = reference.split(".");
- parent_namespace = namespace_tree;
- for path_segment in path[0:-1]:
- if path_segment not in parent_namespace:
- parent_namespace[path_segment] = {}
- parent_namespace = parent_namespace[path_segment]
- if (path[-1] not in parent_namespace):
- try:
- domain = [d for d in domains if d["domain"] == path[0]][0]
- ref_type = [t for t in domain["types"] if t["id"] == path[1]][0]
- parent_namespace[ref_type["id"]] = CreateNamespace(path[0],
- ref_type, ["properties"], ["kParam"])
- except IndexError:
- sys.stderr.write("Failed to resolve type [{0}].\n".format(reference))
- sys.exit(1)
-
-for (namespace_name, namespace) in namespace_tree.items():
- namespace["kName"] = namespace_name
-
-with open(output_cc_path, "w") as f:
- CreateBody(namespace_tree, blink_version, f)
-
-with open(output_h_path, "w") as f:
- CreateHeader(namespace_tree, f)