Browse Source

deps: switch to upstream v8_inspector

This change picks up v8_inspector directly from the upstream chromium
repository [1]; dropping the intermediate repository. The upstream
code has been refactored substantially to make it easy to share code
without adaptation with Node.js.

The deps/v8_inspector directory is now simply a gathering of
dependencies:

* platform/v8_inspector: vendored from [2].
* platform/inspector_protocol: vendored from [3].
* deps/jinja2: vendored from [4].
* deps/markupsafe: vendored from [5].

[1]: https://chromium.googlesource.com/chromium/src/third_party/WebKit/Source/platform
[2]: https://chromium.googlesource.com/chromium/src/third_party/WebKit/Source/platform/v8_inspector
[3]: https://chromium.googlesource.com/chromium/src/third_party/WebKit/Source/platform/inspector_protocol
[4]: https://github.com/mitsuhiko/jinja2
[5]: https://github.com/mitsuhiko/markupsafe

PR-URL: https://github.com/nodejs/node/pull/7302
Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
v7.x
Ali Ijaz Sheikh 8 years ago
parent
commit
44b9154495
  1. 1
      configure
  2. 12
      deps/v8_inspector/README.md
  3. 3924
      deps/v8_inspector/devtools/Inspector-1.1.json
  4. 5167
      deps/v8_inspector/devtools/protocol.json
  5. 66
      deps/v8_inspector/platform/PlatformExport.h
  6. 4
      deps/v8_inspector/platform/inspector_protocol/Array.h
  7. 23
      deps/v8_inspector/platform/inspector_protocol/BackendCallback.h
  8. 0
      deps/v8_inspector/platform/inspector_protocol/Backend_cpp.template
  9. 78
      deps/v8_inspector/platform/inspector_protocol/Backend_h.template
  10. 173
      deps/v8_inspector/platform/inspector_protocol/CodeGenerator.py
  11. 9
      deps/v8_inspector/platform/inspector_protocol/Collections.h
  12. 11
      deps/v8_inspector/platform/inspector_protocol/CollectionsSTL.h
  13. 14
      deps/v8_inspector/platform/inspector_protocol/CollectionsWTF.h
  14. 173
      deps/v8_inspector/platform/inspector_protocol/DispatcherBase.cpp
  15. 97
      deps/v8_inspector/platform/inspector_protocol/DispatcherBase.h
  16. 365
      deps/v8_inspector/platform/inspector_protocol/Dispatcher_cpp.template
  17. 65
      deps/v8_inspector/platform/inspector_protocol/Dispatcher_h.template
  18. 1
      deps/v8_inspector/platform/inspector_protocol/ErrorSupport.cpp
  19. 6
      deps/v8_inspector/platform/inspector_protocol/ErrorSupport.h
  20. 35
      deps/v8_inspector/platform/inspector_protocol/FrontendChannel.h
  21. 53
      deps/v8_inspector/platform/inspector_protocol/Frontend_cpp.template
  22. 57
      deps/v8_inspector/platform/inspector_protocol/Frontend_h.template
  23. 6
      deps/v8_inspector/platform/inspector_protocol/Maybe.h
  24. 35
      deps/v8_inspector/platform/inspector_protocol/Object.cpp
  25. 30
      deps/v8_inspector/platform/inspector_protocol/Object.h
  26. 1
      deps/v8_inspector/platform/inspector_protocol/Parser.cpp
  27. 3
      deps/v8_inspector/platform/inspector_protocol/Parser.h
  28. 14
      deps/v8_inspector/platform/inspector_protocol/Platform.h
  29. 281
      deps/v8_inspector/platform/inspector_protocol/PlatformSTL.h
  30. 14
      deps/v8_inspector/platform/inspector_protocol/PlatformWTF.h
  31. 6
      deps/v8_inspector/platform/inspector_protocol/String16STL.cpp
  32. 15
      deps/v8_inspector/platform/inspector_protocol/String16STL.h
  33. 4
      deps/v8_inspector/platform/inspector_protocol/String16WTF.h
  34. 232
      deps/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template
  35. 165
      deps/v8_inspector/platform/inspector_protocol/TypeBuilder_h.template
  36. 11
      deps/v8_inspector/platform/inspector_protocol/ValueConversions.h
  37. 3
      deps/v8_inspector/platform/inspector_protocol/Values.cpp
  38. 5
      deps/v8_inspector/platform/inspector_protocol/Values.h
  39. 115
      deps/v8_inspector/platform/inspector_protocol/generate-inspector-protocol-version
  40. 89
      deps/v8_inspector/platform/inspector_protocol/protocol.gyp
  41. 6
      deps/v8_inspector/platform/v8_inspector/Atomics.h
  42. 36
      deps/v8_inspector/platform/v8_inspector/InjectedScript.cpp
  43. 10
      deps/v8_inspector/platform/v8_inspector/InjectedScript.h
  44. 1
      deps/v8_inspector/platform/v8_inspector/InjectedScriptNative.cpp
  45. 2
      deps/v8_inspector/platform/v8_inspector/InjectedScriptNative.h
  46. 221
      deps/v8_inspector/platform/v8_inspector/InjectedScriptSource.js
  47. 70
      deps/v8_inspector/platform/v8_inspector/InspectorWrapper.cpp
  48. 88
      deps/v8_inspector/platform/v8_inspector/InspectorWrapper.h
  49. 3
      deps/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.h
  50. 6
      deps/v8_inspector/platform/v8_inspector/OWNERS
  51. 2
      deps/v8_inspector/platform/v8_inspector/RemoteObjectId.cpp
  52. 4
      deps/v8_inspector/platform/v8_inspector/RemoteObjectId.h
  53. 4
      deps/v8_inspector/platform/v8_inspector/V8Compat.h
  54. 161
      deps/v8_inspector/platform/v8_inspector/V8Console.cpp
  55. 22
      deps/v8_inspector/platform/v8_inspector/V8Console.h
  56. 39
      deps/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.cpp
  57. 19
      deps/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.h
  58. 23
      deps/v8_inspector/platform/v8_inspector/V8DebuggerImpl.cpp
  59. 9
      deps/v8_inspector/platform/v8_inspector/V8DebuggerImpl.h
  60. 2
      deps/v8_inspector/platform/v8_inspector/V8FunctionCall.cpp
  61. 38
      deps/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp
  62. 17
      deps/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.h
  63. 69
      deps/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.cpp
  64. 4
      deps/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.h
  65. 113
      deps/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp
  66. 29
      deps/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h
  67. 20
      deps/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp
  68. 15
      deps/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.h
  69. 1
      deps/v8_inspector/platform/v8_inspector/V8Regex.cpp
  70. 34
      deps/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.cpp
  71. 19
      deps/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.h
  72. 33
      deps/v8_inspector/platform/v8_inspector/V8StackTraceImpl.cpp
  73. 8
      deps/v8_inspector/platform/v8_inspector/V8StackTraceImpl.h
  74. 22
      deps/v8_inspector/platform/v8_inspector/injected_script_externs.js
  75. 1866
      deps/v8_inspector/platform/v8_inspector/js_protocol-1.1.json
  76. 976
      deps/v8_inspector/platform/v8_inspector/js_protocol.json
  77. 3
      deps/v8_inspector/platform/v8_inspector/public/V8ContentSearchUtil.h
  78. 24
      deps/v8_inspector/platform/v8_inspector/public/V8Debugger.h
  79. 24
      deps/v8_inspector/platform/v8_inspector/public/V8DebuggerAgent.h
  80. 9
      deps/v8_inspector/platform/v8_inspector/public/V8DebuggerClient.h
  81. 36
      deps/v8_inspector/platform/v8_inspector/public/V8EventListenerInfo.h
  82. 23
      deps/v8_inspector/platform/v8_inspector/public/V8HeapProfilerAgent.h
  83. 58
      deps/v8_inspector/platform/v8_inspector/public/V8Inspector.cpp
  84. 14
      deps/v8_inspector/platform/v8_inspector/public/V8Inspector.h
  85. 16
      deps/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h
  86. 7
      deps/v8_inspector/platform/v8_inspector/public/V8InspectorSessionClient.h
  87. 22
      deps/v8_inspector/platform/v8_inspector/public/V8ProfilerAgent.h
  88. 23
      deps/v8_inspector/platform/v8_inspector/public/V8RuntimeAgent.h
  89. 7
      deps/v8_inspector/platform/v8_inspector/public/V8StackTrace.h
  90. 189
      deps/v8_inspector/platform/v8_inspector/v8_inspector.gyp
  91. 35
      deps/v8_inspector/v8_inspector.gyp
  92. 94
      deps/v8_inspector/v8_inspector.gypi
  93. 2
      node.gyp
  94. 17
      src/inspector_agent.cc

1
configure

@ -816,6 +816,7 @@ def configure_node(o):
o['variables']['asan'] = int(options.enable_asan or 0)
o['variables']['v8_inspector'] = b(not options.without_inspector)
o['variables']['debug_devtools'] = 'node'
if options.use_xcode and options.use_ninja:
raise Exception('--xcode and --ninja cannot be used together.')

12
deps/v8_inspector/README.md

@ -1,2 +1,10 @@
# v8_inspector
# v8_inspector
V8 Inspector support for Node.js
================================
This directory is a gathering of dependencies for Node.js support for the
[Chrome Debug Protocol][https://developer.chrome.com/devtools/docs/debugger-protocol].
* platform/v8_inspector: vendored from https://chromium.googlesource.com/chromium/src/third_party/WebKit/Source/platform/v8_inspector
* platform/inspector_protocol: vendored from https://chromium.googlesource.com/chromium/src/third_party/WebKit/Source/platform/inspector_protocol
* deps/jinja2: vendored from https://github.com/mitsuhiko/jinja2
* deps/markupsafe: vendored from https://github.com/mitsuhiko/markupsafe

3924
deps/v8_inspector/devtools/Inspector-1.1.json

File diff suppressed because it is too large

5167
deps/v8_inspector/devtools/protocol.json

File diff suppressed because it is too large

66
deps/v8_inspector/platform/PlatformExport.h

@ -1,66 +0,0 @@
/*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef PlatformExport_h
#define PlatformExport_h
#if !defined(BLINK_PLATFORM_IMPLEMENTATION)
#define BLINK_PLATFORM_IMPLEMENTATION 0
#endif
#if defined(COMPONENT_BUILD)
#if defined(WIN32)
#if BLINK_PLATFORM_IMPLEMENTATION
#define PLATFORM_EXPORT __declspec(dllexport)
#else
#define PLATFORM_EXPORT __declspec(dllimport)
#endif
#else // defined(WIN32)
#define PLATFORM_EXPORT __attribute__((visibility("default")))
#endif
#else // defined(COMPONENT_BUILD)
#define PLATFORM_EXPORT
#endif
#if defined(_MSC_VER)
// MSVC Compiler warning C4275:
// non dll-interface class 'Bar' used as base for dll-interface class 'Foo'.
// Note that this is intended to be used only when no access to the base class'
// static data is done through derived classes or inline methods. For more info,
// see http://msdn.microsoft.com/en-us/library/3tdb471s(VS.80).aspx
//
// This pragma will allow exporting a class that inherits from a non-exported
// base class, anywhere in the Blink platform component. This is only
// a problem when using the MSVC compiler on Windows.
#pragma warning(suppress:4275)
#endif
#endif // PlatformExport_h

4
deps/v8_inspector/platform/inspector_protocol/Array.h

@ -5,9 +5,9 @@
#ifndef Array_h
#define Array_h
#include "platform/PlatformExport.h"
#include "platform/inspector_protocol/Collections.h"
#include "platform/inspector_protocol/ErrorSupport.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/String16.h"
#include "platform/inspector_protocol/ValueConversions.h"
#include "platform/inspector_protocol/Values.h"
@ -91,7 +91,7 @@ public:
errors->addError("array expected");
return nullptr;
}
std::unique_ptr<Array<T>> result = wrapUnique(new Array<T>());
std::unique_ptr<Array<T>> result(new Array<T>());
errors->push();
for (size_t i = 0; i < array->size(); ++i) {
errors->setName(String16::number(i));

23
deps/v8_inspector/platform/inspector_protocol/BackendCallback.h

@ -0,0 +1,23 @@
// Copyright (c) 2016 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 BackendCallback_h
#define BackendCallback_h
#include "platform/inspector_protocol/ErrorSupport.h"
#include "platform/inspector_protocol/Platform.h"
namespace blink {
namespace protocol {
class PLATFORM_EXPORT BackendCallback {
public:
virtual ~BackendCallback() { }
virtual void sendFailure(const ErrorString&) = 0;
};
} // namespace platform
} // namespace blink
#endif // !defined(BackendCallback_h)

0
deps/v8_inspector/platform/inspector_protocol/Backend_cpp.template

78
deps/v8_inspector/platform/inspector_protocol/Backend_h.template

@ -1,78 +0,0 @@
// This file is generated
// Copyright (c) 2016 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 {{class_name}}_h
#define {{class_name}}_h
#include "platform/inspector_protocol/TypeBuilder.h"
namespace blink {
namespace protocol {
class FrontendChannel;
class BackendImplWeakPtr;
class PLATFORM_EXPORT Backend {
public:
class PLATFORM_EXPORT CallbackBase {
public:
virtual ~CallbackBase() { }
virtual void sendFailure(const ErrorString&) = 0;
};
{% for domain in api.domains %}
class PLATFORM_EXPORT {{domain.domain}} {
public:
{% for command in domain.commands %}
{% if "redirect" in command %}{% continue %}{% endif %}
{% if ("handlers" in command) and not ("renderer" in command["handlers"]) %}{% continue %}{% endif %}
{% if "async" in command %}
class PLATFORM_EXPORT {{command.name | to_title_case}}Callback : public CallbackBase {
public:
virtual void sendSuccess(
{%- for parameter in command.returns -%}
{%- if "optional" in parameter -%}
const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}}
{%- else -%}
{{resolve_type(parameter).pass_type}} {{parameter.name}}
{%- endif -%}
{%- if not loop.last -%}, {% endif -%}
{%- endfor -%}
) = 0;
};
{% endif %}
virtual void {{command.name}}(ErrorString*
{%- for parameter in command.parameters -%}
{%- if "optional" in parameter -%}
, const Maybe<{{resolve_type(parameter).raw_type}}>& in_{{parameter.name}}
{%- else -%}
, {{resolve_type(parameter).pass_type}} in_{{parameter.name}}
{%- endif -%}
{%- endfor -%}
{%- if "async" in command -%}
, std::unique_ptr<{{command.name | to_title_case}}Callback> callback
{%- else -%}
{%- for parameter in command.returns -%}
{%- if "optional" in parameter -%}
, Maybe<{{resolve_type(parameter).raw_type}}>* out_{{parameter.name}}
{%- else -%}
, {{resolve_type(parameter).type}}* out_{{parameter.name}}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
) = 0;
{% endfor %}
protected:
virtual ~{{domain.domain}}() { }
};
{% endfor %}
};
} // namespace protocol
} // namespace blink
#endif // !defined({{class_name}}_h)

173
deps/v8_inspector/platform/inspector_protocol/CodeGenerator.py

@ -4,9 +4,7 @@
import os.path
import sys
import string
import optparse
import re
try:
import json
except ImportError:
@ -22,49 +20,92 @@ except ImportError:
# since some compile processes will try to read the partially written cache.
module_path, module_filename = os.path.split(os.path.realpath(__file__))
templates_dir = module_path
deps_dir = os.path.normpath(os.path.join(
module_path, os.pardir, os.pardir, 'deps'))
# In Blink, jinja2 is in chromium's third_party directory.
# Insert at 1 so at front to override system libraries, and
# after path[0] == invoking script dir
third_party_dir = os.path.normpath(os.path.join(
module_path, os.pardir, os.pardir, os.pardir, os.pardir))
if os.path.isdir(third_party_dir):
sys.path.insert(1, third_party_dir)
# In Node, it is in deps folder
deps_dir = os.path.normpath(os.path.join(
module_path, os.pardir, os.pardir, "deps"))
if os.path.isdir(deps_dir):
sys.path.insert(1, os.path.join(deps_dir, "jinja2"))
sys.path.insert(1, os.path.join(deps_dir, "markupsafe"))
import jinja2
cmdline_parser = optparse.OptionParser()
cmdline_parser.add_option("--protocol")
cmdline_parser.add_option("--include")
cmdline_parser.add_option("--string_type")
cmdline_parser.add_option("--export_macro")
cmdline_parser.add_option("--output_dir")
cmdline_parser.add_option("--generate_dispatcher")
cmdline_parser.add_option("--output_package")
try:
arg_options, arg_values = cmdline_parser.parse_args()
if (len(arg_values) == 0):
raise Exception("At least one plain argument expected (found %s)" % len(arg_values))
protocol_file = arg_options.protocol
if not protocol_file:
raise Exception("Protocol directory must be specified")
include_file = arg_options.include
output_dirname = arg_options.output_dir
generate_dispatcher = arg_options.generate_dispatcher
if not output_dirname:
raise Exception("Output directory must be specified")
output_package = arg_options.output_package
if not output_package:
raise Exception("Output package must be specified")
string_type = arg_options.string_type
if not string_type:
raise Exception("String type must be specified")
export_macro = arg_options.export_macro
if not export_macro:
raise Exception("Export macro must be specified")
except Exception:
# Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html
exc = sys.exc_info()[1]
sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc)
sys.stderr.write("Usage: <script> --output_dir <output_dir> blink_protocol.json v8_protocol.json ...\n")
exit(1)
json_api = {"domains": []}
json_timestamp = 0
for filename in arg_values:
json_timestamp = max(os.path.getmtime(filename), json_timestamp)
input_file = open(filename, "r")
input_file = open(protocol_file, "r")
json_string = input_file.read()
parsed_json = json.loads(json_string)
json_api["domains"] += parsed_json["domains"]
# Make gyp / make generatos happy, otherwise make rebuilds world.
def up_to_date():
template_ts = max(
os.path.getmtime(__file__),
os.path.getmtime(os.path.join(templates_dir, "TypeBuilder_h.template")),
os.path.getmtime(os.path.join(templates_dir, "TypeBuilder_cpp.template")),
os.path.getmtime(protocol_file))
for domain in parsed_json["domains"]:
name = domain["domain"]
h_path = os.path.join(output_dirname, name + ".h")
cpp_path = os.path.join(output_dirname, name + ".cpp")
if not os.path.exists(h_path) or not os.path.exists(cpp_path):
return False
generated_ts = max(os.path.getmtime(h_path), os.path.getmtime(cpp_path))
if generated_ts < template_ts:
return False
return True
if up_to_date():
sys.exit()
def to_title_case(name):
return name[:1].upper() + name[1:]
def dash_to_camelcase(word):
return ''.join(to_title_case(x) or '-' for x in word.split('-'))
return "".join(to_title_case(x) or "-" for x in word.split("-"))
def initialize_jinja_env(cache_dir):
@ -77,7 +118,7 @@ def initialize_jinja_env(cache_dir):
lstrip_blocks=True, # so can indent control flow tags
trim_blocks=True)
jinja_env.filters.update({"to_title_case": to_title_case, "dash_to_camelcase": dash_to_camelcase})
jinja_env.add_extension('jinja2.ext.loopcontrols')
jinja_env.add_extension("jinja2.ext.loopcontrols")
return jinja_env
@ -149,28 +190,16 @@ def create_any_type_definition():
def create_string_type_definition(domain):
if domain in ["Runtime", "Debugger", "Profiler", "HeapProfiler"]:
return {
"return_type": "String16",
"pass_type": "const String16&",
"to_pass_type": "%s",
"to_raw_type": "%s",
"to_rvalue": "%s",
"type": "String16",
"raw_type": "String16",
"raw_pass_type": "const String16&",
"raw_return_type": "String16",
}
return {
"return_type": "String",
"pass_type": "const String&",
"return_type": string_type,
"pass_type": ("const %s&" % string_type),
"to_pass_type": "%s",
"to_raw_type": "%s",
"to_rvalue": "%s",
"type": "String",
"raw_type": "String",
"raw_pass_type": "const String&",
"raw_return_type": "String",
"type": string_type,
"raw_type": string_type,
"raw_pass_type": ("const %s&" % string_type),
"raw_return_type": string_type,
}
@ -203,6 +232,7 @@ def create_primitive_type_definition(type):
"default_value": defaults[type]
}
type_definitions = {}
type_definitions["number"] = create_primitive_type_definition("number")
type_definitions["integer"] = create_primitive_type_definition("integer")
@ -210,6 +240,7 @@ type_definitions["boolean"] = create_primitive_type_definition("boolean")
type_definitions["object"] = create_object_type_definition()
type_definitions["any"] = create_any_type_definition()
def wrap_array_definition(type):
return {
"return_type": "std::unique_ptr<protocol::Array<%s>>" % type["raw_type"],
@ -242,9 +273,6 @@ def create_type_definitions():
else:
type_definitions[domain["domain"] + "." + type["id"]] = create_primitive_type_definition(type["type"])
patch_full_qualified_refs()
create_type_definitions()
def type_definition(name):
return type_definitions[name]
@ -266,39 +294,54 @@ def join_arrays(dict, keys):
return result
if os.path.exists(__file__):
current_script_timestamp = os.path.getmtime(__file__)
else:
current_script_timestamp = 0
def has_disable(commands):
for command in commands:
if command["name"] == "disable":
return True
return False
def is_up_to_date(file, template):
if not os.path.exists(file):
return False
timestamp = os.path.getmtime(file)
return timestamp > max(os.path.getmtime(module_path + template),
current_script_timestamp, json_timestamp)
generate_domains = []
json_api = {}
json_api["domains"] = parsed_json["domains"]
for domain in parsed_json["domains"]:
generate_domains.append(domain["domain"])
if include_file:
input_file = open(include_file, "r")
json_string = input_file.read()
parsed_json = json.loads(json_string)
json_api["domains"] += parsed_json["domains"]
patch_full_qualified_refs()
create_type_definitions()
def generate(class_name):
h_template_name = "/%s_h.template" % class_name
cpp_template_name = "/%s_cpp.template" % class_name
if not os.path.exists(output_dirname):
os.mkdir(output_dirname)
jinja_env = initialize_jinja_env(output_dirname)
h_template_name = "/TypeBuilder_h.template"
cpp_template_name = "/TypeBuilder_cpp.template"
h_template = jinja_env.get_template(h_template_name)
cpp_template = jinja_env.get_template(cpp_template_name)
def generate(domain):
class_name = domain["domain"]
h_file_name = output_dirname + "/" + class_name + ".h"
cpp_file_name = output_dirname + "/" + class_name + ".cpp"
if (is_up_to_date(cpp_file_name, cpp_template_name) and
is_up_to_date(h_file_name, h_template_name)):
return
template_context = {
"class_name": class_name,
"api": json_api,
"domain": domain,
"join_arrays": join_arrays,
"resolve_type": resolve_type,
"type_definition": type_definition
"type_definition": type_definition,
"has_disable": has_disable,
"export_macro": export_macro,
"output_package": output_package,
}
h_template = jinja_env.get_template(h_template_name)
cpp_template = jinja_env.get_template(cpp_template_name)
h_file = output_file(h_file_name)
cpp_file = output_file(cpp_file_name)
h_file.write(h_template.render(template_context))
@ -307,8 +350,6 @@ def generate(class_name):
cpp_file.close()
jinja_env = initialize_jinja_env(output_dirname)
generate("Backend")
generate("Dispatcher")
generate("Frontend")
generate("TypeBuilder")
for domain in json_api["domains"]:
if domain["domain"] in generate_domains:
generate(domain)

9
deps/v8_inspector/platform/inspector_protocol/Collections.h

@ -11,4 +11,13 @@
#include "platform/inspector_protocol/CollectionsWTF.h"
#endif // V8_INSPECTOR_USE_STL
// Macro that returns a compile time constant with the length of an array, but gives an error if passed a non-array.
template<typename T, size_t Size> char (&ArrayLengthHelperFunction(T (&)[Size]))[Size];
// GCC needs some help to deduce a 0 length array.
#if defined(__GNUC__)
template<typename T> char (&ArrayLengthHelperFunction(T (&)[0]))[0];
#endif
#define PROTOCOL_ARRAY_LENGTH(array) sizeof(::ArrayLengthHelperFunction(array))
#endif // !defined(Collections_h)

11
deps/v8_inspector/platform/inspector_protocol/CollectionsSTL.h

@ -5,9 +5,8 @@
#ifndef CollectionsSTL_h
#define CollectionsSTL_h
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/String16.h"
#include "wtf/Compiler.h"
#include "wtf/PtrUtil.h"
#include <algorithm>
#include <map>
@ -242,12 +241,4 @@ public:
} // namespace platform
} // namespace blink
// Macro that returns a compile time constant with the length of an array, but gives an error if passed a non-array.
template<typename T, size_t Size> char (&ArrayLengthHelperFunction(T (&)[Size]))[Size];
// GCC needs some help to deduce a 0 length array.
#if COMPILER(GCC)
template<typename T> char (&ArrayLengthHelperFunction(T (&)[0]))[0];
#endif
#define PROTOCOL_ARRAY_LENGTH(array) sizeof(::ArrayLengthHelperFunction(array))
#endif // !defined(CollectionsSTL_h)

14
deps/v8_inspector/platform/inspector_protocol/CollectionsWTF.h

@ -5,7 +5,7 @@
#ifndef CollectionsWTF_h
#define CollectionsWTF_h
#include "wtf/Assertions.h"
#include "wtf/Allocator.h"
#include "wtf/HashMap.h"
#include "wtf/PtrUtil.h"
#include "wtf/Vector.h"
@ -67,12 +67,12 @@ public:
void resize(size_t s) { m_impl.resize(s); }
size_t size() const { return m_impl.size(); }
bool isEmpty() const { return m_impl.isEmpty(); }
std::unique_ptr<T>& operator[](size_t i) { return m_impl.at(i); }
const std::unique_ptr<T>& operator[](size_t i) const { return m_impl.at(i); }
std::unique_ptr<T>& at(size_t i) { return m_impl.at(i); }
const std::unique_ptr<T>& at(size_t i) const { return m_impl.at(i); }
std::unique_ptr<T>& last() { return m_impl.last(); }
const std::unique_ptr<T>& last() const { return m_impl.last(); }
T* operator[](size_t i) { return m_impl.at(i).get(); }
const T* operator[](size_t i) const { return m_impl.at(i).get(); }
T* at(size_t i) { return m_impl.at(i).get(); }
const T* at(size_t i) const { return m_impl.at(i).get(); }
T* last() { return m_impl.last().get(); }
const T* last() const { return m_impl.last(); }
void append(std::unique_ptr<T> t) { m_impl.append(std::move(t)); }
void prepend(std::unique_ptr<T> t) { m_impl.prepend(std::move(t)); }
void remove(size_t i) { m_impl.remove(i); }

173
deps/v8_inspector/platform/inspector_protocol/DispatcherBase.cpp

@ -0,0 +1,173 @@
// Copyright 2016 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.
#include "platform/inspector_protocol/DispatcherBase.h"
#include "platform/inspector_protocol/FrontendChannel.h"
#include "platform/inspector_protocol/Parser.h"
namespace blink {
namespace protocol {
// static
const char DispatcherBase::kInvalidRequest[] = "Invalid request";
DispatcherBase::WeakPtr::WeakPtr(DispatcherBase* dispatcher) : m_dispatcher(dispatcher) { }
DispatcherBase::WeakPtr::~WeakPtr()
{
if (m_dispatcher)
m_dispatcher->m_weakPtrs.remove(this);
}
DispatcherBase::Callback::Callback(std::unique_ptr<DispatcherBase::WeakPtr> backendImpl, int callId)
: m_backendImpl(std::move(backendImpl))
, m_callId(callId) { }
DispatcherBase::Callback::~Callback() = default;
void DispatcherBase::Callback::dispose()
{
m_backendImpl = nullptr;
}
void DispatcherBase::Callback::sendIfActive(std::unique_ptr<protocol::DictionaryValue> partialMessage, const ErrorString& invocationError)
{
if (!m_backendImpl->get())
return;
m_backendImpl->get()->sendResponse(m_callId, invocationError, nullptr, std::move(partialMessage));
m_backendImpl = nullptr;
}
DispatcherBase::DispatcherBase(FrontendChannel* frontendChannel)
: m_frontendChannel(frontendChannel) { }
DispatcherBase::~DispatcherBase()
{
clearFrontend();
}
// static
bool DispatcherBase::getCommandName(const String16& message, String16* result)
{
std::unique_ptr<protocol::Value> value = parseJSON(message);
if (!value)
return false;
protocol::DictionaryValue* object = DictionaryValue::cast(value.get());
if (!object)
return false;
if (!object->getString("method", result))
return false;
return true;
}
void DispatcherBase::sendResponse(int callId, const ErrorString& invocationError, ErrorSupport* errors, std::unique_ptr<protocol::DictionaryValue> result)
{
if (invocationError.length() || (errors && errors->hasErrors())) {
reportProtocolError(callId, ServerError, invocationError, errors);
return;
}
std::unique_ptr<protocol::DictionaryValue> responseMessage = DictionaryValue::create();
responseMessage->setNumber("id", callId);
responseMessage->setObject("result", std::move(result));
if (m_frontendChannel)
m_frontendChannel->sendProtocolResponse(callId, responseMessage->toJSONString());
}
void DispatcherBase::sendResponse(int callId, const ErrorString& invocationError, std::unique_ptr<protocol::DictionaryValue> result)
{
sendResponse(callId, invocationError, nullptr, std::move(result));
}
void DispatcherBase::sendResponse(int callId, const ErrorString& invocationError)
{
sendResponse(callId, invocationError, nullptr, DictionaryValue::create());
}
static void reportProtocolError(FrontendChannel* frontendChannel, int callId, DispatcherBase::CommonErrorCode code, const String16& errorMessage, ErrorSupport* errors)
{
std::unique_ptr<protocol::DictionaryValue> error = DictionaryValue::create();
error->setNumber("code", code);
error->setString("message", errorMessage);
DCHECK(error);
if (errors && errors->hasErrors())
error->setString("data", errors->errors());
std::unique_ptr<protocol::DictionaryValue> message = DictionaryValue::create();
message->setObject("error", std::move(error));
message->setNumber("id", callId);
frontendChannel->sendProtocolResponse(callId, message->toJSONString());
}
void DispatcherBase::reportProtocolError(int callId, CommonErrorCode code, const String16& errorMessage, ErrorSupport* errors)
{
if (m_frontendChannel)
::blink::protocol::reportProtocolError(m_frontendChannel, callId, code, errorMessage, errors);
}
void DispatcherBase::clearFrontend()
{
m_frontendChannel = nullptr;
for (auto& weak : m_weakPtrs)
weak.first->dispose();
m_weakPtrs.clear();
}
std::unique_ptr<DispatcherBase::WeakPtr> DispatcherBase::weakPtr()
{
std::unique_ptr<DispatcherBase::WeakPtr> weak(new DispatcherBase::WeakPtr(this));
m_weakPtrs.add(weak.get());
return weak;
}
UberDispatcher::UberDispatcher(FrontendChannel* frontendChannel)
: m_frontendChannel(frontendChannel) { }
void UberDispatcher::registerBackend(const String16& name, std::unique_ptr<protocol::DispatcherBase> dispatcher)
{
m_dispatchers.set(name, std::move(dispatcher));
}
void UberDispatcher::dispatch(const String16& message)
{
std::unique_ptr<protocol::Value> parsedMessage = parseJSON(message);
if (!parsedMessage)
return;
std::unique_ptr<protocol::DictionaryValue> messageObject = DictionaryValue::cast(std::move(parsedMessage));
if (!messageObject)
return;
int callId = 0;
protocol::Value* callIdValue = messageObject->get("id");
bool success = callIdValue->asNumber(&callId);
if (!success)
return;
protocol::Value* methodValue = messageObject->get("method");
String16 method;
success = methodValue && methodValue->asString(&method);
if (!success)
return;
size_t dotIndex = method.find(".");
if (dotIndex == kNotFound) {
reportProtocolError(m_frontendChannel, callId, DispatcherBase::MethodNotFound, "'" + method + "' wasn't found", nullptr);
return;
}
String16 domain = method.substring(0, dotIndex);
auto it = m_dispatchers.find(domain);
if (it == m_dispatchers.end()) {
reportProtocolError(m_frontendChannel, callId, DispatcherBase::MethodNotFound, "'" + method + "' wasn't found", nullptr);
return;
}
it->second->dispatch(callId, method, std::move(messageObject));
}
UberDispatcher::~UberDispatcher() = default;
} // namespace protocol
} // namespace blink

97
deps/v8_inspector/platform/inspector_protocol/DispatcherBase.h

@ -0,0 +1,97 @@
// Copyright 2016 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 DispatcherBase_h
#define DispatcherBase_h
#include "platform/inspector_protocol/BackendCallback.h"
#include "platform/inspector_protocol/Collections.h"
#include "platform/inspector_protocol/ErrorSupport.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/String16.h"
#include "platform/inspector_protocol/Values.h"
namespace blink {
namespace protocol {
class FrontendChannel;
class WeakPtr;
class PLATFORM_EXPORT DispatcherBase {
PROTOCOL_DISALLOW_COPY(DispatcherBase);
public:
static const char kInvalidRequest[];
class PLATFORM_EXPORT WeakPtr {
public:
explicit WeakPtr(DispatcherBase*);
~WeakPtr();
DispatcherBase* get() { return m_dispatcher; }
void dispose() { m_dispatcher = nullptr; }
private:
DispatcherBase* m_dispatcher;
};
class PLATFORM_EXPORT Callback : public protocol::BackendCallback {
public:
Callback(std::unique_ptr<WeakPtr> backendImpl, int callId);
virtual ~Callback();
void dispose();
protected:
void sendIfActive(std::unique_ptr<protocol::DictionaryValue> partialMessage, const ErrorString& invocationError);
private:
std::unique_ptr<WeakPtr> m_backendImpl;
int m_callId;
};
explicit DispatcherBase(FrontendChannel*);
virtual ~DispatcherBase();
enum CommonErrorCode {
ParseError = -32700,
InvalidRequest = -32600,
MethodNotFound = -32601,
InvalidParams = -32602,
InternalError = -32603,
ServerError = -32000,
};
static bool getCommandName(const String16& message, String16* result);
virtual void dispatch(int callId, const String16& method, std::unique_ptr<protocol::DictionaryValue> messageObject) = 0;
void sendResponse(int callId, const ErrorString&, ErrorSupport*, std::unique_ptr<protocol::DictionaryValue> result);
void sendResponse(int callId, const ErrorString&, std::unique_ptr<protocol::DictionaryValue> result);
void sendResponse(int callId, const ErrorString&);
void reportProtocolError(int callId, CommonErrorCode, const String16& errorMessage, ErrorSupport* errors);
void clearFrontend();
std::unique_ptr<WeakPtr> weakPtr();
private:
FrontendChannel* m_frontendChannel;
protocol::HashSet<WeakPtr*> m_weakPtrs;
};
class PLATFORM_EXPORT UberDispatcher {
PROTOCOL_DISALLOW_COPY(UberDispatcher);
public:
explicit UberDispatcher(FrontendChannel*);
void registerBackend(const String16& name, std::unique_ptr<protocol::DispatcherBase>);
void dispatch(const String16& message);
FrontendChannel* channel() { return m_frontendChannel; }
virtual ~UberDispatcher();
private:
FrontendChannel* m_frontendChannel;
protocol::HashMap<String16, std::unique_ptr<protocol::DispatcherBase>> m_dispatchers;
};
} // namespace platform
} // namespace blink
#endif // !defined(DispatcherBase_h)

365
deps/v8_inspector/platform/inspector_protocol/Dispatcher_cpp.template

@ -1,365 +0,0 @@
// This file is generated
// Copyright (c) 2016 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.
#include "platform/inspector_protocol/{{class_name}}.h"
#include "platform/inspector_protocol/Collections.h"
#include "platform/inspector_protocol/FrontendChannel.h"
#include "platform/inspector_protocol/Parser.h"
namespace blink {
namespace protocol {
using protocol::Maybe;
class DispatcherImpl;
class DispatcherImplWeakPtr {
public:
DispatcherImplWeakPtr(DispatcherImpl* dispatcher) : m_dispatcher(dispatcher) { }
~DispatcherImplWeakPtr();
DispatcherImpl* get() { return m_dispatcher; }
void dispose() { m_dispatcher = nullptr; }
private:
DispatcherImpl* m_dispatcher;
};
class DispatcherImpl : public Dispatcher {
public:
DispatcherImpl(FrontendChannel* frontendChannel)
: m_frontendChannel(frontendChannel)
{% for domain in api.domains %}
, m_{{domain.domain | lower}}Agent(0)
{% endfor %}
{
{% for domain in api.domains %}
{% for command in domain.commands %}
{% if "redirect" in command %}{% continue %}{% endif %}
{% if "handlers" in command and not ("renderer" in command["handlers"]) %}{% continue %}{% endif %}
m_dispatchMap.set("{{domain.domain}}.{{command.name}}", &DispatcherImpl::{{domain.domain}}_{{command.name}});
{% endfor %}
{% endfor %}
// Initialize common errors.
m_commonErrors.resize(LastEntry);
m_commonErrors[ParseError] = -32700;
m_commonErrors[InvalidRequest] = -32600;
m_commonErrors[MethodNotFound] = -32601;
m_commonErrors[InvalidParams] = -32602;
m_commonErrors[InternalError] = -32603;
m_commonErrors[ServerError] = -32000;
}
~DispatcherImpl() { clearFrontend(); }
virtual void clearFrontend()
{
m_frontendChannel = nullptr;
for (auto& weak : m_weakPtrs)
weak.first->dispose();
m_weakPtrs.clear();
}
std::unique_ptr<DispatcherImplWeakPtr> weakPtr()
{
std::unique_ptr<DispatcherImplWeakPtr> weak(new DispatcherImplWeakPtr(this));
m_weakPtrs.add(weak.get());
return weak;
}
virtual void dispatch(int sessionId, const String16& message);
virtual void reportProtocolError(int sessionId, int callId, CommonErrorCode, const String16& errorMessage, ErrorSupport* errors) const;
using Dispatcher::reportProtocolError;
void sendResponse(int sessionId, int callId, const ErrorString& invocationError, ErrorSupport* errors, std::unique_ptr<protocol::DictionaryValue> result);
{% for domain in api.domains %}
virtual void registerAgent(blink::protocol::Backend::{{domain.domain}}* agent) { DCHECK(!m_{{domain.domain | lower}}Agent); m_{{domain.domain | lower}}Agent = agent; }
{% endfor %}
private:
friend class DispatcherCallbackBase;
friend class DispatcherImplWeakPtr;
using CallHandler = void (DispatcherImpl::*)(int sessionId, int callId, std::unique_ptr<DictionaryValue> messageObject, ErrorSupport* errors);
using DispatchMap = protocol::HashMap<String16, CallHandler>;
{% for domain in api.domains %}
{% for command in domain.commands %}
{% if "redirect" in command %}{% continue %}{% endif %}
{% if "handlers" in command and not ("renderer" in command["handlers"]) %}{% continue %}{% endif %}
void {{domain.domain}}_{{command.name}}(int sessionId, int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
{% endfor %}
{% endfor %}
FrontendChannel* m_frontendChannel;
{% for domain in api.domains %}
Backend::{{domain.domain}}* m_{{domain.domain | lower}}Agent;
{% endfor %}
void sendResponse(int sessionId, int callId, ErrorString invocationError, std::unique_ptr<protocol::DictionaryValue> result)
{
sendResponse(sessionId, callId, invocationError, nullptr, std::move(result));
}
void sendResponse(int sessionId, int callId, ErrorString invocationError)
{
sendResponse(sessionId, callId, invocationError, nullptr, DictionaryValue::create());
}
static const char kInvalidRequest[];
DispatchMap m_dispatchMap;
protocol::Vector<int> m_commonErrors;
protocol::HashSet<DispatcherImplWeakPtr*> m_weakPtrs;
};
class PLATFORM_EXPORT DispatcherCallbackBase : public protocol::Backend::CallbackBase {
public:
DispatcherCallbackBase(std::unique_ptr<DispatcherImplWeakPtr> backendImpl, int sessionId, int id)
: m_backendImpl(std::move(backendImpl)), m_sessionId(sessionId), m_id(id) { }
virtual ~DispatcherCallbackBase() { }
void dispose() { m_backendImpl = nullptr; }
protected:
void sendIfActive(std::unique_ptr<protocol::DictionaryValue> partialMessage, const ErrorString& invocationError)
{
if (!m_backendImpl->get())
return;
m_backendImpl->get()->sendResponse(m_sessionId, m_id, invocationError, nullptr, std::move(partialMessage));
m_backendImpl = nullptr;
}
private:
std::unique_ptr<DispatcherImplWeakPtr> m_backendImpl;
int m_sessionId;
int m_id;
};
DispatcherImplWeakPtr::~DispatcherImplWeakPtr()
{
if (m_dispatcher)
m_dispatcher->m_weakPtrs.remove(this);
}
const char DispatcherImpl::kInvalidRequest[] = "Invalid request";
{% for domain in api.domains %}
{% for command in domain.commands %}
{% if "redirect" in command %}{% continue %}{% endif %}
{% if "handlers" in command and not ("renderer" in command["handlers"]) %}{% continue %}{% endif %}
{% if "async" in command %}
class PLATFORM_EXPORT {{domain.domain}}{{command.name | to_title_case}}Callback : public Backend::{{domain.domain}}::{{command.name | to_title_case}}Callback, public DispatcherCallbackBase {
public:
{{domain.domain}}{{command.name | to_title_case}}Callback(std::unique_ptr<DispatcherImplWeakPtr> backendImpl, int sessionId, int id)
: DispatcherCallbackBase(std::move(backendImpl), sessionId, id) { }
void sendSuccess(
{%- for parameter in command.returns -%}
{%- if "optional" in parameter -%}
const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}}
{%- else -%}
{{resolve_type(parameter).pass_type}} {{parameter.name}}
{%- endif -%}
{%- if not loop.last -%}, {% endif -%}
{%- endfor -%}) override
{
std::unique_ptr<protocol::DictionaryValue> resultObject = DictionaryValue::create();
{% for parameter in command.returns %}
{% if "optional" in parameter %}
if ({{parameter.name}}.isJust())
resultObject->setValue("{{parameter.name}}", toValue({{parameter.name}}.fromJust()));
{% else %}
resultObject->setValue("{{parameter.name}}", toValue({{resolve_type(parameter).to_raw_type % parameter.name}}));
{% endif %}
{% endfor %}
sendIfActive(std::move(resultObject), ErrorString());
}
void sendFailure(const ErrorString& error) override
{
DCHECK(error.length());
sendIfActive(nullptr, error);
}
};
{% endif %}
void DispatcherImpl::{{domain.domain}}_{{command.name}}(int sessionId, int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
{
if (!m_{{domain.domain | lower}}Agent)
errors->addError("{{domain.domain}} handler is not available.");
if (errors->hasErrors()) {
reportProtocolError(sessionId, callId, InvalidParams, kInvalidRequest, errors);
return;
}
{% if "parameters" in command %}
// Prepare input parameters.
protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
errors->push();
{% for property in command.parameters %}
protocol::Value* {{property.name}}Value = object ? object->get("{{property.name}}") : nullptr;
{% if property.optional %}
Maybe<{{resolve_type(property).raw_type}}> in_{{property.name}};
if ({{property.name}}Value) {
errors->setName("{{property.name}}");
in_{{property.name}} = FromValue<{{resolve_type(property).raw_type}}>::parse({{property.name}}Value, errors);
}
{% else %}
errors->setName("{{property.name}}");
{{resolve_type(property).type}} in_{{property.name}} = FromValue<{{resolve_type(property).raw_type}}>::parse({{property.name}}Value, errors);
{% endif %}
{% endfor %}
errors->pop();
if (errors->hasErrors()) {
reportProtocolError(sessionId, callId, InvalidParams, kInvalidRequest, errors);
return;
}
{% endif %}
{% if "async" in command %}
std::unique_ptr<{{domain.domain}}{{command.name | to_title_case}}Callback> callback(new {{domain.domain}}{{command.name | to_title_case}}Callback(weakPtr(), sessionId, callId));
{% elif "returns" in command %}
// Declare output parameters.
std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
{% for property in command.returns %}
{% if "optional" in property %}
Maybe<{{resolve_type(property).raw_type}}> out_{{property.name}};
{% else %}
{{resolve_type(property).type}} out_{{property.name}};
{% endif %}
{% endfor %}
{% endif %}
std::unique_ptr<DispatcherImplWeakPtr> weak = weakPtr();
ErrorString error;
m_{{domain.domain | lower}}Agent->{{command.name}}(&error
{%- for property in command.parameters -%}
{%- if "optional" in property -%}
, in_{{property.name}}
{%- else -%}
, {{resolve_type(property).to_pass_type % ("in_" + property.name)}}
{%- endif -%}
{%- endfor %}
{%- if "async" in command -%}
, std::move(callback)
{%- elif "returns" in command %}
{%- for property in command.returns -%}
, &out_{{property.name}}
{%- endfor %}
{% endif %});
{% if "returns" in command and not("async" in command) %}
if (!error.length()) {
{% for parameter in command.returns %}
{% if "optional" in parameter %}
if (out_{{parameter.name}}.isJust())
result->setValue("{{parameter.name}}", toValue(out_{{parameter.name}}.fromJust()));
{% else %}
result->setValue("{{parameter.name}}", toValue({{resolve_type(parameter).to_raw_type % ("out_" + parameter.name)}}));
{% endif %}
{% endfor %}
}
if (weak->get())
weak->get()->sendResponse(sessionId, callId, error, std::move(result));
{% elif not("async" in command) %}
if (weak->get())
weak->get()->sendResponse(sessionId, callId, error);
{% endif %}
}
{% endfor %}
{% endfor %}
std::unique_ptr<Dispatcher> Dispatcher::create(FrontendChannel* frontendChannel)
{
return wrapUnique(new DispatcherImpl(frontendChannel));
}
void DispatcherImpl::dispatch(int sessionId, const String16& message)
{
int callId = 0;
std::unique_ptr<protocol::Value> parsedMessage = parseJSON(message);
DCHECK(parsedMessage);
std::unique_ptr<protocol::DictionaryValue> messageObject = DictionaryValue::cast(std::move(parsedMessage));
DCHECK(messageObject);
protocol::Value* callIdValue = messageObject->get("id");
bool success = callIdValue->asNumber(&callId);
DCHECK(success);
protocol::Value* methodValue = messageObject->get("method");
String16 method;
success = methodValue && methodValue->asString(&method);
DCHECK(success);
protocol::HashMap<String16, CallHandler>::iterator it = m_dispatchMap.find(method);
if (it == m_dispatchMap.end()) {
reportProtocolError(sessionId, callId, MethodNotFound, "'" + method + "' wasn't found");
return;
}
protocol::ErrorSupport errors;
((*this).*(*it->second))(sessionId, callId, std::move(messageObject), &errors);
}
void DispatcherImpl::sendResponse(int sessionId, int callId, const ErrorString& invocationError, ErrorSupport* errors, std::unique_ptr<protocol::DictionaryValue> result)
{
if (invocationError.length() || (errors && errors->hasErrors())) {
reportProtocolError(sessionId, callId, ServerError, invocationError, errors);
return;
}
std::unique_ptr<protocol::DictionaryValue> responseMessage = DictionaryValue::create();
responseMessage->setNumber("id", callId);
responseMessage->setObject("result", std::move(result));
if (m_frontendChannel)
m_frontendChannel->sendProtocolResponse(sessionId, callId, std::move(responseMessage));
}
void Dispatcher::reportProtocolError(int sessionId, int callId, CommonErrorCode code, const String16& errorMessage) const
{
ErrorSupport errors;
reportProtocolError(sessionId, callId, code, errorMessage, &errors);
}
void DispatcherImpl::reportProtocolError(int sessionId, int callId, CommonErrorCode code, const String16& errorMessage, ErrorSupport* errors) const
{
DCHECK(code >=0);
DCHECK((unsigned)code < m_commonErrors.size());
DCHECK(m_commonErrors[code]);
std::unique_ptr<protocol::DictionaryValue> error = DictionaryValue::create();
error->setNumber("code", m_commonErrors[code]);
error->setString("message", errorMessage);
DCHECK(error);
if (errors && errors->hasErrors())
error->setString("data", errors->errors());
std::unique_ptr<protocol::DictionaryValue> message = DictionaryValue::create();
message->setObject("error", std::move(error));
message->setNumber("id", callId);
if (m_frontendChannel)
m_frontendChannel->sendProtocolResponse(sessionId, callId, std::move(message));
}
bool Dispatcher::getCommandName(const String16& message, String16* result)
{
std::unique_ptr<protocol::Value> value = parseJSON(message);
if (!value)
return false;
protocol::DictionaryValue* object = DictionaryValue::cast(value.get());
if (!object)
return false;
if (!object->getString("method", result))
return false;
return true;
}
} // namespace protocol
} // namespace blink

65
deps/v8_inspector/platform/inspector_protocol/Dispatcher_h.template

@ -1,65 +0,0 @@
// This file is generated
// Copyright (c) 2016 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 {{class_name}}_h
#define {{class_name}}_h
#include "platform/inspector_protocol/Backend.h"
#include "platform/inspector_protocol/TypeBuilder.h"
namespace blink {
namespace protocol {
class FrontendChannel;
class DispatcherImplWeakPtr;
class PLATFORM_EXPORT Dispatcher {
public:
static std::unique_ptr<Dispatcher> create(FrontendChannel* frontendChannel);
virtual ~Dispatcher() { }
class PLATFORM_EXPORT CallbackBase {
public:
CallbackBase(std::unique_ptr<DispatcherImplWeakPtr> backendImpl, int sessionId, int id);
virtual ~CallbackBase();
void sendFailure(const ErrorString&);
void dispose();
protected:
void sendIfActive(std::unique_ptr<protocol::DictionaryValue> partialMessage, const ErrorString& invocationError);
private:
std::unique_ptr<DispatcherImplWeakPtr> m_backendImpl;
int m_sessionId;
int m_id;
};
{% for domain in api.domains %}
virtual void registerAgent(blink::protocol::Backend::{{domain.domain}}*) = 0;
{% endfor %}
virtual void clearFrontend() = 0;
enum CommonErrorCode {
ParseError = 0,
InvalidRequest,
MethodNotFound,
InvalidParams,
InternalError,
ServerError,
LastEntry,
};
void reportProtocolError(int sessionId, int callId, CommonErrorCode, const String16& errorMessage) const;
virtual void reportProtocolError(int sessionId, int callId, CommonErrorCode, const String16& errorMessage, ErrorSupport*) const = 0;
virtual void dispatch(int sessionId, const String16& message) = 0;
static bool getCommandName(const String16& message, String16* result);
};
} // namespace protocol
} // namespace blink
#endif // !defined({{class_name}}_h)

1
deps/v8_inspector/platform/inspector_protocol/ErrorSupport.cpp

@ -5,7 +5,6 @@
#include "platform/inspector_protocol/ErrorSupport.h"
#include "platform/inspector_protocol/String16.h"
#include "wtf/Assertions.h"
namespace blink {
namespace protocol {

6
deps/v8_inspector/platform/inspector_protocol/ErrorSupport.h

@ -5,13 +5,15 @@
#ifndef ErrorSupport_h
#define ErrorSupport_h
#include "platform/PlatformExport.h"
#include "platform/inspector_protocol/Collections.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/String16.h"
namespace blink {
namespace protocol {
using ErrorString = String16;
class PLATFORM_EXPORT ErrorSupport {
public:
ErrorSupport();
@ -34,4 +36,6 @@ private:
} // namespace platform
} // namespace blink
using blink::protocol::ErrorString;
#endif // !defined(ErrorSupport_h)

35
deps/v8_inspector/platform/inspector_protocol/FrontendChannel.h

@ -1,27 +1,6 @@
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// Copyright 2016 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 FrontendChannel_h
#define FrontendChannel_h
@ -31,12 +10,12 @@
namespace blink {
namespace protocol {
class FrontendChannel {
class PLATFORM_EXPORT FrontendChannel {
public:
virtual ~FrontendChannel() { }
virtual void sendProtocolResponse(int sessionId, int callId, std::unique_ptr<protocol::DictionaryValue> message) = 0;
virtual void sendProtocolNotification(std::unique_ptr<protocol::DictionaryValue> message) = 0;
virtual void flush() = 0;
virtual void sendProtocolResponse(int callId, const String16& message) = 0;
virtual void sendProtocolNotification(const String16& message) = 0;
virtual void flushProtocolNotifications() = 0;
};
} // namespace protocol

53
deps/v8_inspector/platform/inspector_protocol/Frontend_cpp.template

@ -1,53 +0,0 @@
// This file is generated
// Copyright (c) 2016 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.
#include "platform/inspector_protocol/{{class_name}}.h"
#include "platform/inspector_protocol/String16.h"
namespace blink {
namespace protocol {
Frontend::Frontend(FrontendChannel* frontendChannel)
: m_frontendChannel(frontendChannel)
{% for domain in api.domains %}
, m_{{domain.domain | lower}}(frontendChannel)
{% endfor %}
{
}
{% for domain in api.domains %}
{% for event in domain.events %}
{% if "handlers" in event and not ("renderer" in event["handlers"]) %}{% continue %}{% endif %}
void Frontend::{{domain.domain}}::{{event.name}}(
{%- for parameter in event.parameters %}
{% if "optional" in parameter -%}
const Maybe<{{resolve_type(parameter).raw_type}}>&
{%- else -%}
{{resolve_type(parameter).pass_type}}
{%- endif %} {{parameter.name}}{%- if not loop.last -%}, {% endif -%}
{% endfor -%})
{
std::unique_ptr<protocol::DictionaryValue> jsonMessage = DictionaryValue::create();
jsonMessage->setString("method", "{{domain.domain}}.{{event.name}}");
std::unique_ptr<protocol::DictionaryValue> paramsObject = DictionaryValue::create();
{% for parameter in event.parameters %}
{% if "optional" in parameter %}
if ({{parameter.name}}.isJust())
paramsObject->setValue("{{parameter.name}}", toValue({{parameter.name}}.fromJust()));
{% else %}
paramsObject->setValue("{{parameter.name}}", toValue({{resolve_type(parameter).to_raw_type % parameter.name}}));
{% endif %}
{% endfor %}
jsonMessage->setObject("params", std::move(paramsObject));
if (m_frontendChannel)
m_frontendChannel->sendProtocolNotification(std::move(jsonMessage));
}
{% endfor %}
{% endfor %}
} // namespace protocol
} // namespace blink

57
deps/v8_inspector/platform/inspector_protocol/Frontend_h.template

@ -1,57 +0,0 @@
// This file is generated
// Copyright (c) 2016 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 {{class_name}}_h
#define {{class_name}}_h
#include "platform/inspector_protocol/FrontendChannel.h"
#include "platform/inspector_protocol/TypeBuilder.h"
namespace blink {
namespace protocol {
class PLATFORM_EXPORT Frontend {
public:
Frontend(FrontendChannel*);
FrontendChannel* channel() { return m_frontendChannel; }
{% for domain in api.domains %}
class PLATFORM_EXPORT {{domain.domain}} {
public:
static {{domain.domain}}* from(Frontend* frontend) { return &(frontend->m_{{domain.domain | lower}}) ;}
{{domain.domain}}(FrontendChannel* frontendChannel) : m_frontendChannel(frontendChannel) { }
{% for event in domain.events %}
{% if "handlers" in event and not ("renderer" in event["handlers"]) %}{% continue %}{% endif %}
void {{event.name}}(
{%- for parameter in event.parameters -%}
{%- if "optional" in parameter -%}
const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}} = Maybe<{{resolve_type(parameter).raw_type}}>()
{%- else -%}
{{resolve_type(parameter).pass_type}} {{parameter.name}}
{%- endif -%}{%- if not loop.last -%}, {% endif -%}
{%- endfor -%}
);
{% endfor %}
void flush() { m_frontendChannel->flush(); }
private:
FrontendChannel* m_frontendChannel;
};
{% endfor %}
private:
FrontendChannel* m_frontendChannel;
{% for domain in api.domains %}
{{domain.domain}} m_{{domain.domain | lower}};
{% endfor %}
};
} // namespace protocol
} // namespace blink
#endif // !defined({{class_name}}_h)

6
deps/v8_inspector/platform/inspector_protocol/Maybe.h

@ -5,8 +5,10 @@
#ifndef Maybe_h
#define Maybe_h
#include "platform/PlatformExport.h"
#include "wtf/Assertions.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/String16.h"
#include <memory>
namespace blink {
namespace protocol {

35
deps/v8_inspector/platform/inspector_protocol/Object.cpp

@ -0,0 +1,35 @@
// Copyright 2016 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.
#include "platform/inspector_protocol/Object.h"
namespace blink {
namespace protocol {
std::unique_ptr<Object> Object::parse(protocol::Value* value, ErrorSupport* errors)
{
protocol::DictionaryValue* object = DictionaryValue::cast(value);
if (!object) {
errors->addError("object expected");
return nullptr;
}
return wrapUnique(new Object(wrapUnique(static_cast<DictionaryValue*>(object->clone().release()))));
}
std::unique_ptr<protocol::DictionaryValue> Object::serialize() const
{
return DictionaryValue::cast(m_object->clone());
}
std::unique_ptr<Object> Object::clone() const
{
return wrapUnique(new Object(DictionaryValue::cast(m_object->clone())));
}
Object::Object(std::unique_ptr<protocol::DictionaryValue> object) : m_object(std::move(object)) { }
Object::~Object() { }
} // namespace protocol
} // namespace blink

30
deps/v8_inspector/platform/inspector_protocol/Object.h

@ -0,0 +1,30 @@
// Copyright 2016 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 Object_h
#define Object_h
#include "platform/inspector_protocol/ErrorSupport.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/Values.h"
namespace blink {
namespace protocol {
class PLATFORM_EXPORT Object {
public:
static std::unique_ptr<Object> parse(protocol::Value*, ErrorSupport*);
~Object();
std::unique_ptr<protocol::DictionaryValue> serialize() const;
std::unique_ptr<Object> clone() const;
private:
explicit Object(std::unique_ptr<protocol::DictionaryValue>);
std::unique_ptr<protocol::DictionaryValue> m_object;
};
} // namespace platform
} // namespace blink
#endif // !defined(Object_h)

1
deps/v8_inspector/platform/inspector_protocol/Parser.cpp

@ -6,7 +6,6 @@
#include "platform/inspector_protocol/String16.h"
#include "platform/inspector_protocol/Values.h"
#include "wtf/Assertions.h"
namespace blink {
namespace protocol {

3
deps/v8_inspector/platform/inspector_protocol/Parser.h

@ -5,9 +5,8 @@
#ifndef Parser_h
#define Parser_h
#include "platform/PlatformExport.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/String16.h"
#include "wtf/PtrUtil.h"
namespace blink {
namespace protocol {

14
deps/v8_inspector/platform/inspector_protocol/Platform.h

@ -0,0 +1,14 @@
// Copyright 2016 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 protocol_Platform_h
#define protocol_Platform_h
#if V8_INSPECTOR_USE_STL
#include "platform/inspector_protocol/PlatformSTL.h"
#else
#include "platform/inspector_protocol/PlatformWTF.h"
#endif // V8_INSPECTOR_USE_STL
#endif // !defined(protocol_Platform_h)

281
deps/v8_inspector/platform/inspector_protocol/PlatformSTL.h

@ -0,0 +1,281 @@
// Copyright (c) 2016 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 PlatformSTL_h
#define PlatformSTL_h
#include <memory>
#define PLATFORM_EXPORT
#ifndef CHECK
#define CHECK(condition) ((void) 0)
#endif
#define DCHECK(condition) ((void) 0)
#define NOTREACHED()
#define DCHECK_EQ(i, j) DCHECK(i == j)
#define DCHECK_GE(i, j) DCHECK(i >= j)
#define DCHECK_LT(i, j) DCHECK(i < j)
#define DCHECK_GT(i, j) DCHECK(i > j)
template <typename T>
inline void USE(T) { }
#define DEFINE_STATIC_LOCAL(type, name, arguments) \
static type name;
#if defined(__APPLE__) && !defined(_LIBCPP_VERSION)
namespace std {
template <typename T1, typename T2>
struct is_convertible {
private:
struct True_ {
char x[2];
};
struct False_ {
};
static True_ helper(T2 const &);
static False_ helper(...);
public:
static bool const value = (
sizeof(True_) == sizeof(is_convertible::helper(T1()))
);
};
template <bool, class T = void>
struct enable_if {
};
template <class T>
struct enable_if<true, T> {
typedef T type;
};
template<class T>
struct remove_extent {
typedef T type;
};
template<class T>
struct remove_extent<T[]> {
typedef T type;
};
template<class T, std::size_t N>
struct remove_extent<T[N]> {
typedef T type;
};
typedef decltype(nullptr) nullptr_t;
template<class T, T v>
struct integral_constant {
static constexpr T value = v;
typedef T value_type;
typedef integral_constant type;
constexpr operator value_type() const noexcept { return value; }
constexpr value_type operator()() const noexcept { return value; }
};
typedef integral_constant<bool, true> true_type;
typedef integral_constant<bool, false> false_type;
template<class T>
struct is_array : false_type {};
template<class T>
struct is_array<T[]> : true_type {};
template<class T, std::size_t N>
struct is_array<T[N]> : true_type {};
template <typename T>
struct OwnedPtrDeleter {
static void deletePtr(T* ptr)
{
static_assert(sizeof(T) > 0, "type must be complete");
delete ptr;
}
};
template <typename T>
struct OwnedPtrDeleter<T[]> {
static void deletePtr(T* ptr)
{
static_assert(sizeof(T) > 0, "type must be complete");
delete[] ptr;
}
};
template <class T, int n>
struct OwnedPtrDeleter<T[n]> {
static_assert(sizeof(T) < 0, "do not use array with size as type");
};
template <typename T> class unique_ptr {
public:
typedef typename remove_extent<T>::type ValueType;
typedef ValueType* PtrType;
unique_ptr() : m_ptr(nullptr) {}
unique_ptr(std::nullptr_t) : m_ptr(nullptr) {}
unique_ptr(unique_ptr&&);
template <typename U, typename = typename enable_if<is_convertible<U*, T*>::value>::type> unique_ptr(unique_ptr<U>&&);
~unique_ptr()
{
OwnedPtrDeleter<T>::deletePtr(m_ptr);
m_ptr = nullptr;
}
PtrType get() const { return m_ptr; }
void reset(PtrType = nullptr);
PtrType release();
ValueType& operator*() const { DCHECK(m_ptr); return *m_ptr; }
PtrType operator->() const { DCHECK(m_ptr); return m_ptr; }
ValueType& operator[](std::ptrdiff_t i) const;
bool operator!() const { return !m_ptr; }
explicit operator bool() const { return m_ptr; }
unique_ptr& operator=(std::nullptr_t) { reset(); return *this; }
unique_ptr& operator=(unique_ptr&&);
template <typename U> unique_ptr& operator=(unique_ptr<U>&&);
void swap(unique_ptr& o) { std::swap(m_ptr, o.m_ptr); }
static T* hashTableDeletedValue() { return reinterpret_cast<T*>(-1); }
explicit unique_ptr(PtrType ptr) : m_ptr(ptr) {}
private:
// We should never have two unique_ptrs for the same underlying object
// (otherwise we'll get double-destruction), so these equality operators
// should never be needed.
template <typename U> bool operator==(const unique_ptr<U>&) const
{
static_assert(!sizeof(U*), "unique_ptrs should never be equal");
return false;
}
template <typename U> bool operator!=(const unique_ptr<U>&) const
{
static_assert(!sizeof(U*), "unique_ptrs should never be equal");
return false;
}
PtrType m_ptr;
};
template <typename T> inline void unique_ptr<T>::reset(PtrType ptr)
{
PtrType p = m_ptr;
m_ptr = ptr;
OwnedPtrDeleter<T>::deletePtr(p);
}
template <typename T> inline typename unique_ptr<T>::PtrType unique_ptr<T>::release()
{
PtrType ptr = m_ptr;
m_ptr = nullptr;
return ptr;
}
template <typename T> inline typename unique_ptr<T>::ValueType& unique_ptr<T>::operator[](std::ptrdiff_t i) const
{
static_assert(is_array<T>::value, "elements access is possible for arrays only");
DCHECK(m_ptr);
DCHECK_GE(i, 0);
return m_ptr[i];
}
template <typename T> inline unique_ptr<T>::unique_ptr(unique_ptr<T>&& o)
: m_ptr(o.release())
{
}
template <typename T>
template <typename U, typename> inline unique_ptr<T>::unique_ptr(unique_ptr<U>&& o)
: m_ptr(o.release())
{
static_assert(!is_array<T>::value, "pointers to array must never be converted");
}
template <typename T> inline unique_ptr<T>& unique_ptr<T>::operator=(unique_ptr<T>&& o)
{
PtrType ptr = m_ptr;
m_ptr = o.release();
DCHECK(!ptr || m_ptr != ptr);
OwnedPtrDeleter<T>::deletePtr(ptr);
return *this;
}
template <typename T>
template <typename U> inline unique_ptr<T>& unique_ptr<T>::operator=(unique_ptr<U>&& o)
{
static_assert(!is_array<T>::value, "pointers to array must never be converted");
PtrType ptr = m_ptr;
m_ptr = o.release();
DCHECK(!ptr || m_ptr != ptr);
OwnedPtrDeleter<T>::deletePtr(ptr);
return *this;
}
template <typename T> inline void swap(unique_ptr<T>& a, unique_ptr<T>& b)
{
a.swap(b);
}
template <typename T, typename U> inline bool operator==(const unique_ptr<T>& a, U* b)
{
return a.get() == b;
}
template <typename T, typename U> inline bool operator==(T* a, const unique_ptr<U>& b)
{
return a == b.get();
}
template <typename T, typename U> inline bool operator!=(const unique_ptr<T>& a, U* b)
{
return a.get() != b;
}
template <typename T, typename U> inline bool operator!=(T* a, const unique_ptr<U>& b)
{
return a != b.get();
}
template <typename T> inline typename unique_ptr<T>::PtrType getPtr(const unique_ptr<T>& p)
{
return p.get();
}
template <typename T>
unique_ptr<T> move(unique_ptr<T>& ptr)
{
return unique_ptr<T>(ptr.release());
}
}
#endif // defined(__APPLE__) && !defined(_LIBCPP_VERSION)
template <typename T>
std::unique_ptr<T> wrapUnique(T* ptr)
{
return std::unique_ptr<T>(ptr);
}
#endif // PlatformSTL_h

14
deps/v8_inspector/platform/inspector_protocol/PlatformWTF.h

@ -0,0 +1,14 @@
// Copyright (c) 2016 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 PlatformWTF_h
#define PlatformWTF_h
#include "platform/PlatformExport.h"
#include "wtf/Assertions.h"
#include "wtf/PtrUtil.h"
#include <memory>
#endif // PlatformWTF_h

6
deps/v8_inspector/platform/inspector_protocol/String16STL.cpp

@ -4,14 +4,14 @@
#include "platform/inspector_protocol/String16STL.h"
#include "platform/inspector_protocol/Platform.h"
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <functional>
#include <locale>
#define DCHECK(k)
namespace blink {
namespace protocol {
@ -480,7 +480,7 @@ ConversionResult convertUTF8ToUTF16(
// Helper to write a three-byte UTF-8 code point to the buffer, caller must check room is available.
static inline void putUTF8Triple(char*& buffer, UChar ch)
{
DCHECK(ch >= 0x0800);
DCHECK_GE(ch, 0x0800);
*buffer++ = static_cast<char>(((ch >> 12) & 0x0F) | 0xE0);
*buffer++ = static_cast<char>(((ch >> 6) & 0x3F) | 0x80);
*buffer++ = static_cast<char>((ch & 0x3F) | 0x80);

15
deps/v8_inspector/platform/inspector_protocol/String16STL.h

@ -5,10 +5,9 @@
#ifndef String16STL_h
#define String16STL_h
#include <stdint.h>
#include <cstdlib>
#include <cstring>
#include <stdint.h>
#include <string>
#include <vector>
@ -37,6 +36,7 @@ public:
m_impl[i] = characters[i];
}
String16(const UChar* characters, size_t size) : m_impl(characters, size) { }
String16 isolatedCopy() const { return String16(m_impl); }
unsigned sizeInBytes() const { return m_impl.size() * sizeof(UChar); }
const UChar* characters16() const { return m_impl.c_str(); }
@ -103,6 +103,13 @@ public:
return m_impl.rfind(str.m_impl, start);
}
bool startWith(const String16& s) const
{
if (m_impl.length() < s.m_impl.length())
return false;
return m_impl.substr(0, s.m_impl.length()) == s.m_impl;
}
bool endsWith(UChar character) const
{
return m_impl.length() && m_impl[m_impl.length() - 1] == character;
@ -124,8 +131,8 @@ public:
}
private:
static std::string intToString(int i);
static std::string doubleToString(double d);
static std::string intToString(int);
static std::string doubleToString(double);
// presubmit: allow wstring
wstring m_impl;
mutable bool has_hash = false;

4
deps/v8_inspector/platform/inspector_protocol/String16WTF.h

@ -10,6 +10,7 @@
#include "wtf/text/StringBuilder.h"
#include "wtf/text/StringConcatenate.h"
#include "wtf/text/StringHash.h"
#include "wtf/text/StringToNumber.h"
#include "wtf/text/WTFString.h"
namespace blink {
@ -35,6 +36,7 @@ public:
operator WTF::String() const { return m_impl; }
operator WebString() { return m_impl; }
const WTF::String& impl() const { return m_impl; }
String16 isolatedCopy() const { return String16(m_impl.isolatedCopy()); }
~String16() { }
@ -73,7 +75,7 @@ private:
class String16Builder {
public:
String16Builder() { }
void append(const String16& str) { m_impl.append(str); };
void append(const String16& str) { m_impl.append(StringView(str)); };
void append(UChar c) { m_impl.append(c); };
void append(LChar c) { m_impl.append(c); };
void append(char c) { m_impl.append(c); };

232
deps/v8_inspector/platform/inspector_protocol/TypeBuilder_cpp.template

@ -4,38 +4,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "platform/inspector_protocol/{{class_name}}.h"
#include "{{output_package}}/{{domain.domain}}.h"
#include "platform/inspector_protocol/DispatcherBase.h"
namespace blink {
namespace protocol {
std::unique_ptr<Object> Object::parse(protocol::Value* value, ErrorSupport* errors)
{
protocol::DictionaryValue* object = DictionaryValue::cast(value);
if (!object) {
errors->addError("object expected");
return nullptr;
}
return wrapUnique(new Object(wrapUnique(static_cast<DictionaryValue*>(object->clone().release()))));
}
std::unique_ptr<protocol::DictionaryValue> Object::serialize() const
{
return DictionaryValue::cast(m_object->clone());
}
std::unique_ptr<Object> Object::clone() const
{
return wrapUnique(new Object(DictionaryValue::cast(m_object->clone())));
}
Object::Object(std::unique_ptr<protocol::DictionaryValue> object) : m_object(std::move(object)) { }
Object::~Object() { }
namespace {{domain.domain}} {
// ------------- Enum values from types.
{% for domain in api.domains %}
namespace {{domain.domain}} {
const char Metainfo::domainName[] = "{{domain.domain}}";
{% for type in domain.types %}
{% if "enum" in type %}
@ -103,16 +82,13 @@ std::unique_ptr<{{type.id}}> {{type.id}}::clone() const
return parse(serialize().get(), &errors);
}
{% endfor %}
} // {{domain.domain}}
{% endfor %}
// ------------- Enum values from params.
{% for domain in api.domains %}
{% for command in join_arrays(domain, ["commands", "events"]) %}
{% for param in join_arrays(command, ["parameters", "returns"]) %}
{% if "enum" in param %}
namespace {{domain.domain}} {
namespace {{command.name | to_title_case}} {
namespace {{param.name | to_title_case}}Enum {
{% for literal in param.enum %}
@ -120,11 +96,205 @@ const char* {{ literal | to_title_case}} = "{{literal}}";
{% endfor %}
} // {{param.name | to_title_case}}Enum
} // {{command.name | to_title_case }}
} // {{domain.domain}}
{% endif %}
{% endfor %}
{% endfor %}
// ------------- Frontend notifications.
{% for event in domain.events %}
{% if "handlers" in event and not ("renderer" in event["handlers"]) %}{% continue %}{% endif %}
void Frontend::{{event.name}}(
{%- for parameter in event.parameters %}
{% if "optional" in parameter -%}
const Maybe<{{resolve_type(parameter).raw_type}}>&
{%- else -%}
{{resolve_type(parameter).pass_type}}
{%- endif %} {{parameter.name}}{%- if not loop.last -%}, {% endif -%}
{% endfor -%})
{
std::unique_ptr<protocol::DictionaryValue> jsonMessage = DictionaryValue::create();
jsonMessage->setString("method", "{{domain.domain}}.{{event.name}}");
std::unique_ptr<protocol::DictionaryValue> paramsObject = DictionaryValue::create();
{% for parameter in event.parameters %}
{% if "optional" in parameter %}
if ({{parameter.name}}.isJust())
paramsObject->setValue("{{parameter.name}}", toValue({{parameter.name}}.fromJust()));
{% else %}
paramsObject->setValue("{{parameter.name}}", toValue({{resolve_type(parameter).to_raw_type % parameter.name}}));
{% endif %}
{% endfor %}
jsonMessage->setObject("params", std::move(paramsObject));
if (m_frontendChannel)
m_frontendChannel->sendProtocolNotification(jsonMessage->toJSONString());
}
{% endfor %}
// --------------------- Dispatcher.
class DispatcherImpl : public protocol::DispatcherBase {
public:
DispatcherImpl(FrontendChannel* frontendChannel, Backend* backend)
: DispatcherBase(frontendChannel)
, m_backend(backend) {
{% for command in domain.commands %}
{% if "redirect" in command %}{% continue %}{% endif %}
{% if "handlers" in command and not ("renderer" in command["handlers"]) %}{% continue %}{% endif %}
m_dispatchMap.set("{{domain.domain}}.{{command.name}}", &DispatcherImpl::{{command.name}});
{% endfor %}
}
~DispatcherImpl() override { }
void dispatch(int callId, const String16& method, std::unique_ptr<protocol::DictionaryValue> messageObject) override;
protected:
using CallHandler = void (DispatcherImpl::*)(int callId, std::unique_ptr<DictionaryValue> messageObject, ErrorSupport* errors);
using DispatchMap = protocol::HashMap<String16, CallHandler>;
DispatchMap m_dispatchMap;
{% for command in domain.commands %}
{% if "redirect" in command %}{% continue %}{% endif %}
{% if "handlers" in command and not ("renderer" in command["handlers"]) %}{% continue %}{% endif %}
void {{command.name}}(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
{% endfor %}
Backend* m_backend;
};
void DispatcherImpl::dispatch(int callId, const String16& method, std::unique_ptr<protocol::DictionaryValue> messageObject)
{
protocol::HashMap<String16, CallHandler>::iterator it = m_dispatchMap.find(method);
if (it == m_dispatchMap.end()) {
reportProtocolError(callId, MethodNotFound, "'" + method + "' wasn't found", nullptr);
return;
}
protocol::ErrorSupport errors;
((*this).*(*it->second))(callId, std::move(messageObject), &errors);
}
{% for command in domain.commands %}
{% if "redirect" in command %}{% continue %}{% endif %}
{% if "handlers" in command and not ("renderer" in command["handlers"]) %}{% continue %}{% endif %}
{% if "async" in command %}
class {{command.name | to_title_case}}CallbackImpl : public Backend::{{command.name | to_title_case}}Callback, public DispatcherBase::Callback {
public:
{{command.name | to_title_case}}CallbackImpl(std::unique_ptr<DispatcherBase::WeakPtr> backendImpl, int callId)
: DispatcherBase::Callback(std::move(backendImpl), callId) { }
void sendSuccess(
{%- for parameter in command.returns -%}
{%- if "optional" in parameter -%}
const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}}
{%- else -%}
{{resolve_type(parameter).pass_type}} {{parameter.name}}
{%- endif -%}
{%- if not loop.last -%}, {% endif -%}
{%- endfor -%}) override
{
std::unique_ptr<protocol::DictionaryValue> resultObject = DictionaryValue::create();
{% for parameter in command.returns %}
{% if "optional" in parameter %}
if ({{parameter.name}}.isJust())
resultObject->setValue("{{parameter.name}}", toValue({{parameter.name}}.fromJust()));
{% else %}
resultObject->setValue("{{parameter.name}}", toValue({{resolve_type(parameter).to_raw_type % parameter.name}}));
{% endif %}
{% endfor %}
sendIfActive(std::move(resultObject), ErrorString());
}
void sendFailure(const ErrorString& error) override
{
DCHECK(error.length());
sendIfActive(nullptr, error);
}
};
{% endif %}
void DispatcherImpl::{{command.name}}(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
{
{% if "parameters" in command %}
// Prepare input parameters.
protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
errors->push();
{% for property in command.parameters %}
protocol::Value* {{property.name}}Value = object ? object->get("{{property.name}}") : nullptr;
{% if property.optional %}
Maybe<{{resolve_type(property).raw_type}}> in_{{property.name}};
if ({{property.name}}Value) {
errors->setName("{{property.name}}");
in_{{property.name}} = FromValue<{{resolve_type(property).raw_type}}>::parse({{property.name}}Value, errors);
}
{% else %}
errors->setName("{{property.name}}");
{{resolve_type(property).type}} in_{{property.name}} = FromValue<{{resolve_type(property).raw_type}}>::parse({{property.name}}Value, errors);
{% endif %}
{% endfor %}
errors->pop();
if (errors->hasErrors()) {
reportProtocolError(callId, InvalidParams, kInvalidRequest, errors);
return;
}
{% endif %}
{% if "async" in command %}
std::unique_ptr<{{command.name | to_title_case}}CallbackImpl> callback(new {{command.name | to_title_case}}CallbackImpl(weakPtr(), callId));
{% elif "returns" in command %}
// Declare output parameters.
std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
{% for property in command.returns %}
{% if "optional" in property %}
Maybe<{{resolve_type(property).raw_type}}> out_{{property.name}};
{% else %}
{{resolve_type(property).type}} out_{{property.name}};
{% endif %}
{% endfor %}
{% endif %}
std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
ErrorString error;
m_backend->{{command.name}}(&error
{%- for property in command.parameters -%}
{%- if "optional" in property -%}
, in_{{property.name}}
{%- else -%}
, {{resolve_type(property).to_pass_type % ("in_" + property.name)}}
{%- endif -%}
{%- endfor %}
{%- if "async" in command -%}
, std::move(callback)
{%- elif "returns" in command %}
{%- for property in command.returns -%}
, &out_{{property.name}}
{%- endfor %}
{% endif %});
{% if "returns" in command and not("async" in command) %}
if (!error.length()) {
{% for parameter in command.returns %}
{% if "optional" in parameter %}
if (out_{{parameter.name}}.isJust())
result->setValue("{{parameter.name}}", toValue(out_{{parameter.name}}.fromJust()));
{% else %}
result->setValue("{{parameter.name}}", toValue({{resolve_type(parameter).to_raw_type % ("out_" + parameter.name)}}));
{% endif %}
{% endfor %}
}
if (weak->get())
weak->get()->sendResponse(callId, error, std::move(result));
{% elif not("async" in command) %}
if (weak->get())
weak->get()->sendResponse(callId, error);
{% endif %}
}
{% endfor %}
// static
void Dispatcher::wire(UberDispatcher* dispatcher, Backend* backend)
{
dispatcher->registerBackend("{{domain.domain}}", wrapUnique(new DispatcherImpl(dispatcher->channel(), backend)));
}
} // {{domain.domain}}
} // namespace protocol
} // namespace blink

165
deps/v8_inspector/platform/inspector_protocol/TypeBuilder_h.template

@ -4,41 +4,34 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef {{class_name}}_h
#define {{class_name}}_h
#ifndef protocol_{{domain.domain}}_h
#define protocol_{{domain.domain}}_h
#include "platform/PlatformExport.h"
{% if export_macro == "PLATFORM_EXPORT" %}
#include "platform/inspector_protocol/Platform.h"
{% else %}
#include "core/CoreExport.h"
{% endif %}
#include "platform/inspector_protocol/Array.h"
#include "platform/inspector_protocol/BackendCallback.h"
#include "platform/inspector_protocol/DispatcherBase.h"
#include "platform/inspector_protocol/ErrorSupport.h"
#include "platform/inspector_protocol/FrontendChannel.h"
#include "platform/inspector_protocol/Maybe.h"
#include "platform/inspector_protocol/Object.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/String16.h"
#include "platform/inspector_protocol/Values.h"
#include "platform/inspector_protocol/ValueConversions.h"
#include "wtf/Assertions.h"
#include "wtf/PtrUtil.h"
{% for name in domain.dependencies %}
#include "{{output_package}}/{{name}}.h"
{% endfor %}
namespace blink {
namespace protocol {
using ErrorString = String16;
class PLATFORM_EXPORT Object {
public:
static std::unique_ptr<Object> parse(protocol::Value* value, ErrorSupport* errors);
~Object();
std::unique_ptr<protocol::DictionaryValue> serialize() const;
std::unique_ptr<Object> clone() const;
private:
Object(std::unique_ptr<protocol::DictionaryValue> object);
std::unique_ptr<protocol::DictionaryValue> m_object;
};
{% for domain in api.domains %}
// ------------- Forward declarations and typedefs.
namespace {{domain.domain}} {
// ------------- Forward and enum declarations.
{% for type in domain.types %}
{% if type.type == "object" %}
{% if "properties" in type %}
@ -53,55 +46,38 @@ using {{type.id}} = Object;
using {{type.id}} = {{resolve_type(type).type}};
{% endif %}
{% endfor %}
} // {{domain.domain}}
{% endfor %}
// ------------- Enum values from types.
{% for domain in api.domains %}
{% for type in domain.types %}
{% if "enum" in type %}
namespace {{domain.domain}} {
namespace {{type.id}}Enum {
{% for literal in type.enum %}
PLATFORM_EXPORT extern const char* {{ literal | dash_to_camelcase}};
{{export_macro}} extern const char* {{ literal | dash_to_camelcase}};
{% endfor %}
} // {{type.id}}Enum
} // {{domain.domain}}
{% endif %}
{% endfor %}
{% endfor %}
// ------------- Enum values from params.
{% for domain in api.domains %}
{% for command in join_arrays(domain, ["commands", "events"]) %}
{% for param in join_arrays(command, ["parameters", "returns"]) %}
{% if "enum" in param %}
namespace {{domain.domain}} {
namespace {{command.name | to_title_case}} {
namespace {{param.name | to_title_case}}Enum {
{% for literal in param.enum %}
PLATFORM_EXPORT extern const char* {{ literal | dash_to_camelcase}};
{{export_macro}} extern const char* {{ literal | dash_to_camelcase}};
{% endfor %}
} // {{param.name | to_title_case}}Enum
} // {{command.name | to_title_case }}
} // {{domain.domain}}
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}
// ------------- Type and builder declarations.
{% for domain in api.domains %}
namespace {{domain.domain}} {
{% for type in domain.types %}
{% if not (type.type == "object") or not ("properties" in type) %}{% continue %}{% endif %}
{% set type_def = type_definition(domain.domain + "." + type.id)%}
// {{type.description}}
class PLATFORM_EXPORT {{type.id}} {
class {{export_macro}} {{type.id}} {
public:
static std::unique_ptr<{{type.id}}> parse(protocol::Value* value, ErrorSupport* errors);
@ -109,7 +85,7 @@ public:
{% for property in type.properties %}
{% if "enum" in property %}
struct PLATFORM_EXPORT {{property.name | to_title_case}}Enum {
struct {{export_macro}} {{property.name | to_title_case}}Enum {
{% for literal in property.enum %}
static const char* {{ literal | dash_to_camelcase}};
{% endfor %}
@ -207,12 +183,103 @@ private:
{% endfor %}
} // {{domain.domain}}
// ------------- Backend interface.
class {{export_macro}} Backend {
public:
{% for command in domain.commands %}
{% if "redirect" in command %}{% continue %}{% endif %}
{% if ("handlers" in command) and not ("renderer" in command["handlers"]) %}{% continue %}{% endif %}
{% if "async" in command %}
class {{export_macro}} {{command.name | to_title_case}}Callback : public BackendCallback {
public:
virtual void sendSuccess(
{%- for parameter in command.returns -%}
{%- if "optional" in parameter -%}
const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}}
{%- else -%}
{{resolve_type(parameter).pass_type}} {{parameter.name}}
{%- endif -%}
{%- if not loop.last -%}, {% endif -%}
{%- endfor -%}
) = 0;
};
{% endif %}
virtual void {{command.name}}(ErrorString*
{%- for parameter in command.parameters -%}
{%- if "optional" in parameter -%}
, const Maybe<{{resolve_type(parameter).raw_type}}>& in_{{parameter.name}}
{%- else -%}
, {{resolve_type(parameter).pass_type}} in_{{parameter.name}}
{%- endif -%}
{%- endfor -%}
{%- if "async" in command -%}
, std::unique_ptr<{{command.name | to_title_case}}Callback> callback
{%- else -%}
{%- for parameter in command.returns -%}
{%- if "optional" in parameter -%}
, Maybe<{{resolve_type(parameter).raw_type}}>* out_{{parameter.name}}
{%- else -%}
, {{resolve_type(parameter).type}}* out_{{parameter.name}}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
) = 0;
{% endfor %}
{% if not has_disable(domain.commands) %}
virtual void disable(ErrorString*) { }
{% endif %}
protected:
virtual ~Backend() { }
};
// ------------- Frontend interface.
class {{export_macro}} Frontend {
public:
Frontend(FrontendChannel* frontendChannel) : m_frontendChannel(frontendChannel) { }
{% for event in domain.events %}
{% if "handlers" in event and not ("renderer" in event["handlers"]) %}{% continue %}{% endif %}
void {{event.name}}(
{%- for parameter in event.parameters -%}
{%- if "optional" in parameter -%}
const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}} = Maybe<{{resolve_type(parameter).raw_type}}>()
{%- else -%}
{{resolve_type(parameter).pass_type}} {{parameter.name}}
{%- endif -%}{%- if not loop.last -%}, {% endif -%}
{%- endfor -%}
);
{% endfor %}
void flush() { m_frontendChannel->flushProtocolNotifications(); }
private:
FrontendChannel* m_frontendChannel;
};
// ------------- Dispatcher.
class {{export_macro}} Dispatcher {
public:
static void wire(UberDispatcher*, blink::protocol::{{domain.domain}}::Backend*);
private:
Dispatcher() { }
};
// ------------- Metainfo.
class {{export_macro}} Metainfo {
public:
using BackendClass = Backend;
using FrontendClass = Frontend;
using DispatcherClass = Dispatcher;
static const char domainName[];
};
} // namespace {{domain.domain}}
} // namespace protocol
} // namespace blink
using blink::protocol::ErrorString;
#endif // !defined({{class_name}}_h)
#endif // !defined(protocol_{{domain.domain}}_h)

11
deps/v8_inspector/platform/inspector_protocol/ValueConversions.h

@ -5,8 +5,8 @@
#ifndef ValueConversions_h
#define ValueConversions_h
#include "platform/PlatformExport.h"
#include "platform/inspector_protocol/ErrorSupport.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/String16.h"
#include "platform/inspector_protocol/Values.h"
@ -36,14 +36,7 @@ template<typename T> std::unique_ptr<protocol::Value> toValue(T* param)
template<typename T> std::unique_ptr<protocol::Value> toValue(const std::unique_ptr<T>& param)
{
static_assert(sizeof(T) == 0, "use raw pointer version.");
return nullptr;
}
template<typename T> std::unique_ptr<protocol::Value> toValue(std::unique_ptr<T> param)
{
static_assert(sizeof(T) == 0, "use raw pointer version.");
return nullptr;
return toValue(param.get());
}
template<typename T>

3
deps/v8_inspector/platform/inspector_protocol/Values.cpp

@ -6,7 +6,6 @@
#include "platform/inspector_protocol/Parser.h"
#include "platform/inspector_protocol/String16.h"
#include "wtf/Assertions.h"
#include <cmath>
namespace blink {
@ -346,7 +345,7 @@ void ListValue::pushValue(std::unique_ptr<protocol::Value> value)
protocol::Value* ListValue::at(size_t index)
{
CHECK(index < m_data.size());
DCHECK_LT(index, m_data.size());
return m_data[index];
}

5
deps/v8_inspector/platform/inspector_protocol/Values.h

@ -5,11 +5,10 @@
#ifndef Values_h
#define Values_h
#include "platform/PlatformExport.h"
#include "platform/inspector_protocol/Allocator.h"
#include "platform/inspector_protocol/Collections.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/String16.h"
#include "wtf/PtrUtil.h"
namespace blink {
namespace protocol {
@ -27,7 +26,7 @@ public:
static std::unique_ptr<Value> null()
{
return std::unique_ptr<Value>(new Value());
return wrapUnique(new Value());
}
enum ValueType {

115
deps/v8_inspector/platform/inspector_protocol/generate-inspector-protocol-version

@ -45,10 +45,18 @@
#
# Adding --show_changes to the command line prints out a list of valid public API changes.
import collections
import copy
import os.path
import optparse
import re
import sys
try:
import json
except ImportError:
import simplejson as json
def list_to_map(items, key):
result = {}
for item in items:
@ -56,28 +64,34 @@ def list_to_map(items, key):
result[item[key]] = item
return result
def named_list_to_map(container, name, key):
if name in container:
return list_to_map(container[name], key)
return {}
def removed(reverse):
if reverse:
return "added"
return "removed"
def required(reverse):
if reverse:
return "optional"
return "required"
def compare_schemas(schema_1, schema_2, reverse):
def compare_schemas(d_1, d_2, reverse):
errors = []
types_1 = normalize_types_in_schema(schema_1)
types_2 = normalize_types_in_schema(schema_2)
domains_1 = copy.deepcopy(d_1)
domains_2 = copy.deepcopy(d_2)
types_1 = normalize_types_in_schema(domains_1)
types_2 = normalize_types_in_schema(domains_2)
domains_by_name_1 = list_to_map(schema_1, "domain")
domains_by_name_2 = list_to_map(schema_2, "domain")
domains_by_name_1 = list_to_map(domains_1, "domain")
domains_by_name_2 = list_to_map(domains_2, "domain")
for name in domains_by_name_1:
domain_1 = domains_by_name_1[name]
@ -87,6 +101,7 @@ def compare_schemas(schema_1, schema_2, reverse):
compare_domains(domain_1, domains_by_name_2[name], types_1, types_2, errors, reverse)
return errors
def compare_domains(domain_1, domain_2, types_map_1, types_map_2, errors, reverse):
domain_name = domain_1["domain"]
commands_1 = named_list_to_map(domain_1, "commands", "name")
@ -107,6 +122,7 @@ def compare_domains(domain_1, domain_2, types_map_1, types_map_2, errors, revers
continue
compare_events(domain_name, event_1, events_2[name], types_map_1, types_map_2, errors, reverse)
def compare_commands(domain_name, command_1, command_2, types_map_1, types_map_2, errors, reverse):
context = domain_name + "." + command_1["name"]
@ -119,12 +135,14 @@ def compare_commands(domain_name, command_1, command_2, types_map_1, types_map_2
returns_2 = named_list_to_map(command_2, "returns", "name")
compare_params_list(context, "response parameter", returns_1, returns_2, types_map_1, types_map_2, 0, errors, reverse)
def compare_events(domain_name, event_1, event_2, types_map_1, types_map_2, errors, reverse):
context = domain_name + "." + event_1["name"]
params_1 = named_list_to_map(event_1, "parameters", "name")
params_2 = named_list_to_map(event_2, "parameters", "name")
compare_params_list(context, "parameter", params_1, params_2, types_map_1, types_map_2, 0, errors, reverse)
def compare_params_list(context, kind, params_1, params_2, types_map_1, types_map_2, depth, errors, reverse):
for name in params_1:
param_1 = params_1[name]
@ -141,6 +159,7 @@ def compare_params_list(context, kind, params_1, params_2, types_map_1, types_ma
type_2 = extract_type(param_2, types_map_2, errors)
compare_types(context + "." + name, kind, type_1, type_2, types_map_1, types_map_2, depth, errors, reverse)
def compare_types(context, kind, type_1, type_2, types_map_1, types_map_2, depth, errors, reverse):
if depth > 10:
return
@ -165,6 +184,7 @@ def compare_types(context, kind, type_1, type_2, types_map_1, types_map_2, depth
item_type_2 = extract_type(type_2["items"], types_map_2, errors)
compare_types(context, kind, item_type_1, item_type_2, types_map_1, types_map_2, depth + 1, errors, reverse)
def extract_type(typed_object, types_map, errors):
if "type" in typed_object:
result = { "id": "<transient>", "type": typed_object["type"] }
@ -180,13 +200,15 @@ def extract_type(typed_object, types_map, errors):
types_map[ref] = { "id": "<transient>", "type": "object" }
return types_map[ref]
def normalize_types_in_schema(schema):
def normalize_types_in_schema(domains):
types = {}
for domain in schema:
for domain in domains:
domain_name = domain["domain"]
normalize_types(domain, domain_name, types)
return types
def normalize_types(obj, domain_name, types):
if isinstance(obj, list):
for item in obj:
@ -201,12 +223,16 @@ def normalize_types(obj, domain_name, types):
else:
normalize_types(value, domain_name, types)
def load_json(filename):
input_file = open(filename, "r")
def load_schema(file, domains):
if not os.path.isfile(file):
return
input_file = open(file, "r")
json_string = input_file.read()
json_string = re.sub(":\s*true", ": True", json_string)
json_string = re.sub(":\s*false", ": False", json_string)
return eval(json_string)
parsed_json = json.loads(json_string)
domains += parsed_json["domains"]
return parsed_json["version"]
def self_test():
def create_test_schema_1():
@ -392,72 +418,61 @@ def self_test():
compare_schemas(create_test_schema_2(), create_test_schema_1(), True)))
def load_domains_and_baselines(file, domains, baseline_domains):
version = load_schema(os.path.normpath(file), domains)
suffix = "-%s.%s.json" % (version["major"], version["minor"])
baseline_file = file.replace(".json", suffix)
load_schema(os.path.normpath(baseline_file), baseline_domains)
return version
def main():
if not self_test():
sys.stderr.write("Self-test failed")
return 1
if len(sys.argv) < 4 or sys.argv[1] != "-o":
sys.stderr.write("Usage: %s -o OUTPUT_FILE INPUT_FILE [--show-changes]\n" % sys.argv[0])
cmdline_parser = optparse.OptionParser()
cmdline_parser.add_option("--show_changes")
cmdline_parser.add_option("--o")
arg_options, arg_values = cmdline_parser.parse_args()
if len(arg_values) < 1 or not arg_options.o:
sys.stderr.write("Usage: %s --o OUTPUT_FILE [--show_changes] PROTOCOL_FOLDER1 ?PROTOCOL_FOLDER2 \n" % sys.argv[0])
return 1
output_path = sys.argv[2]
output_path = arg_options.o
output_file = open(output_path, "w")
input_path = sys.argv[3]
dir_name = os.path.dirname(input_path)
schema = load_json(input_path)
major = schema["version"]["major"]
minor = schema["version"]["minor"]
version = "%s.%s" % (major, minor)
if len(dir_name) == 0:
dir_name = "."
baseline_path = os.path.normpath(dir_name + "/Inspector-" + version + ".json")
baseline_schema = load_json(baseline_path)
domains = []
baseline_domains = []
version = load_domains_and_baselines(arg_values[0], domains, baseline_domains)
if len(arg_values) > 1:
load_domains_and_baselines(arg_values[1], domains, baseline_domains)
expected_errors = [
"Debugger.globalObjectCleared: event has been removed"
]
errors = compare_schemas(baseline_schema["domains"], schema["domains"], False)
errors = compare_schemas(baseline_domains, domains, False)
unexpected_errors = []
for i in range(len(errors)):
if errors[i] not in expected_errors:
unexpected_errors.append(errors[i])
if len(unexpected_errors) > 0:
sys.stderr.write(" Compatibility with %s: FAILED\n" % version)
sys.stderr.write(" Compatibility checks FAILED\n")
for error in unexpected_errors:
sys.stderr.write( " %s\n" % error)
return 1
if len(sys.argv) > 4 and sys.argv[4] == "--show-changes":
changes = compare_schemas(
load_json(input_path)["domains"], load_json(baseline_path)["domains"], True)
if arg_options.show_changes:
changes = compare_schemas(domains, baseline_domains, True)
if len(changes) > 0:
print " Public changes since %s:" % version
for change in changes:
print " %s" % change
output_file.write("""
#ifndef InspectorProtocolVersion_h
#define InspectorProtocolVersion_h
#include "platform/inspector_protocol/String16.h"
namespace blink {
String inspectorProtocolVersion() { return "%s"; }
int inspectorProtocolVersionMajor() { return %s; }
int inspectorProtocolVersionMinor() { return %s; }
}
#endif // !defined(InspectorProtocolVersion_h)
""" % (version, major, minor))
json.dump({"version": version, "domains": domains}, output_file, indent=4, sort_keys=False, separators=(',', ': '))
output_file.close()
if __name__ == '__main__':

89
deps/v8_inspector/platform/inspector_protocol/protocol.gyp

@ -1,89 +0,0 @@
# 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.
{
'variables': {
'blink_platform_output_dir': '<(SHARED_INTERMEDIATE_DIR)/blink/platform',
'jinja_module_files': [
# jinja2/__init__.py contains version string, so sufficient for package
'../../deps/jinja2/jinja2/__init__.py',
'../../deps/markupsafe/markupsafe/__init__.py', # jinja2 dep
],
},
'targets': [
{
# GN version: //third_party/WebKit/Source/platform/inspector_protocol_sources
'target_name': 'protocol_sources',
'type': 'none',
'dependencies': [
'protocol_version'
],
'actions': [
{
'action_name': 'generateInspectorProtocolBackendSources',
'inputs': [
'<@(jinja_module_files)',
# The python script in action below.
'CodeGenerator.py',
# Input files for the script.
'../../devtools/protocol.json',
'Backend_h.template',
'Dispatcher_h.template',
'Dispatcher_cpp.template',
'Frontend_h.template',
'Frontend_cpp.template',
'TypeBuilder_h.template',
'TypeBuilder_cpp.template',
],
'outputs': [
'<(blink_platform_output_dir)/inspector_protocol/Backend.h',
'<(blink_platform_output_dir)/inspector_protocol/Dispatcher.cpp',
'<(blink_platform_output_dir)/inspector_protocol/Dispatcher.h',
'<(blink_platform_output_dir)/inspector_protocol/Frontend.cpp',
'<(blink_platform_output_dir)/inspector_protocol/Frontend.h',
'<(blink_platform_output_dir)/inspector_protocol/TypeBuilder.cpp',
'<(blink_platform_output_dir)/inspector_protocol/TypeBuilder.h',
],
'action': [
'python',
'CodeGenerator.py',
'../../devtools/protocol.json',
'--output_dir', '<(blink_platform_output_dir)/inspector_protocol',
],
'message': 'Generating Inspector protocol backend sources from protocol.json',
},
]
},
{
# GN version: //third_party/WebKit/Source/platform/inspector_protocol_version
'target_name': 'protocol_version',
'type': 'none',
'actions': [
{
'action_name': 'generateInspectorProtocolVersion',
'inputs': [
'generate-inspector-protocol-version',
'../../devtools/protocol.json',
],
'outputs': [
'<(blink_platform_output_dir)/inspector_protocol/InspectorProtocolVersion.h',
],
'variables': {
'generator_include_dirs': [
],
},
'action': [
'python',
'generate-inspector-protocol-version',
'-o',
'<@(_outputs)',
'<@(_inputs)'
],
'message': 'Validate inspector protocol for backwards compatibility and generate version file',
}
]
},
], # targets
}

6
deps/v8_inspector/platform/v8_inspector/Atomics.h

@ -7,14 +7,16 @@
#include <stdint.h>
#if COMPILER(MSVC)
#if defined(_MSC_VER)
#include <windows.h>
#endif
namespace blink {
#if COMPILER(MSVC)
#if defined(_MSC_VER)
inline int atomicIncrement(int volatile* addend) { return InterlockedIncrement(reinterpret_cast<long volatile*>(addend)); }
#else
inline int atomicAdd(int volatile* addend, int increment) { return __sync_add_and_fetch(addend, increment); }

36
deps/v8_inspector/platform/v8_inspector/InjectedScript.cpp

@ -335,7 +335,7 @@ std::unique_ptr<protocol::Runtime::ExceptionDetails> InjectedScript::createExcep
v8::Local<v8::StackTrace> stackTrace = message->GetStackTrace();
if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0)
exceptionDetailsObject->setStack(m_context->debugger()->createStackTrace(stackTrace, stackTrace->GetFrameCount())->buildInspectorObject());
exceptionDetailsObject->setStack(m_context->debugger()->createStackTrace(stackTrace)->buildInspectorObject());
return exceptionDetailsObject;
}
@ -366,18 +366,10 @@ void InjectedScript::wrapEvaluateResult(ErrorString* errorString, v8::MaybeLocal
}
}
v8::MaybeLocal<v8::Object> InjectedScript::commandLineAPI(ErrorString* errorString)
v8::Local<v8::Object> InjectedScript::commandLineAPI()
{
v8::Isolate* isolate = m_context->isolate();
if (m_commandLineAPI.IsEmpty()) {
V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value(), "installCommandLineAPI");
function.appendArgument(V8Console::createCommandLineAPI(m_context));
bool hadException = false;
v8::Local<v8::Value> extension = function.call(hadException, false);
if (hasInternalError(errorString, hadException || extension.IsEmpty() || !extension->IsObject()))
return v8::MaybeLocal<v8::Object>();
m_commandLineAPI.Reset(isolate, extension.As<v8::Object>());
}
if (m_commandLineAPI.IsEmpty())
m_commandLineAPI.Reset(m_context->isolate(), V8Console::createCommandLineAPI(m_context));
return m_commandLineAPI.Get(m_context->isolate());
}
@ -413,17 +405,8 @@ bool InjectedScript::Scope::initialize()
bool InjectedScript::Scope::installCommandLineAPI()
{
DCHECK(m_injectedScript && !m_context.IsEmpty() && m_global.IsEmpty());
v8::Local<v8::Object> extensionObject;
if (!m_injectedScript->commandLineAPI(m_errorString).ToLocal(&extensionObject))
return false;
m_extensionPrivate = V8Debugger::scopeExtensionPrivate(m_debugger->isolate());
v8::Local<v8::Object> global = m_context->Global();
if (!global->SetPrivate(m_context, m_extensionPrivate, extensionObject).FromMaybe(false)) {
*m_errorString = "Internal error";
return false;
}
m_global = global;
DCHECK(m_injectedScript && !m_context.IsEmpty() && !m_commandLineAPIScope.get());
m_commandLineAPIScope.reset(new V8Console::CommandLineAPIScope(m_context, m_injectedScript->commandLineAPI(), m_context->Global()));
return true;
}
@ -454,12 +437,7 @@ void InjectedScript::Scope::pretendUserGesture()
void InjectedScript::Scope::cleanup()
{
v8::Local<v8::Object> global;
if (m_global.ToLocal(&global)) {
DCHECK(!m_context.IsEmpty());
global->DeletePrivate(m_context, m_extensionPrivate);
m_global = v8::MaybeLocal<v8::Object>();
}
m_commandLineAPIScope.reset();
if (!m_context.IsEmpty()) {
m_context->Exit();
m_context.Clear();

10
deps/v8_inspector/platform/v8_inspector/InjectedScript.h

@ -32,11 +32,12 @@
#define InjectedScript_h
#include "platform/inspector_protocol/Allocator.h"
#include "platform/inspector_protocol/TypeBuilder.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/v8_inspector/InjectedScriptNative.h"
#include "platform/v8_inspector/InspectedContext.h"
#include "platform/v8_inspector/V8Console.h"
#include "platform/v8_inspector/V8DebuggerImpl.h"
#include "wtf/PtrUtil.h"
#include "platform/v8_inspector/protocol/Runtime.h"
#include <v8.h>
@ -114,8 +115,7 @@ public:
v8::HandleScope m_handleScope;
v8::TryCatch m_tryCatch;
v8::Local<v8::Context> m_context;
v8::Local<v8::Private> m_extensionPrivate;
v8::MaybeLocal<v8::Object> m_global;
std::unique_ptr<V8Console::CommandLineAPIScope> m_commandLineAPIScope;
bool m_ignoreExceptionsAndMuteConsole;
V8DebuggerImpl::PauseOnExceptionsState m_previousPauseOnExceptionsState;
bool m_userGesture;
@ -162,7 +162,7 @@ private:
bool canAccessInspectedWindow() const;
v8::Local<v8::Value> v8Value() const;
v8::MaybeLocal<v8::Value> wrapValue(ErrorString*, v8::Local<v8::Value>, const String16& groupName, bool forceValueType, bool generatePreview) const;
v8::MaybeLocal<v8::Object> commandLineAPI(ErrorString*);
v8::Local<v8::Object> commandLineAPI();
InspectedContext* m_context;
v8::Global<v8::Value> m_value;

1
deps/v8_inspector/platform/v8_inspector/InjectedScriptNative.cpp

@ -5,7 +5,6 @@
#include "platform/v8_inspector/InjectedScriptNative.h"
#include "platform/inspector_protocol/Values.h"
#include "wtf/Assertions.h"
namespace blink {

2
deps/v8_inspector/platform/v8_inspector/InjectedScriptNative.h

@ -6,8 +6,8 @@
#define InjectedScriptNative_h
#include "platform/inspector_protocol/Collections.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/String16.h"
#include "wtf/PtrUtil.h"
#include <v8.h>
namespace blink {

221
deps/v8_inspector/platform/v8_inspector/InjectedScriptSource.js

@ -53,20 +53,6 @@ function push(array, var_args)
array[array.length] = arguments[i];
}
/**
* @param {(!Arguments.<T>|!NodeList)} array
* @param {number=} index
* @return {!Array.<T>}
* @template T
*/
function slice(array, index)
{
var result = [];
for (var i = index || 0, j = 0; i < array.length; ++i, ++j)
result[j] = array[i];
return result;
}
/**
* @param {*} obj
* @return {string}
@ -405,7 +391,7 @@ InjectedScript.prototype = {
if (descriptor) {
if (accessorPropertiesOnly && !("get" in descriptor || "set" in descriptor))
continue;
if ("get" in descriptor && "set" in descriptor && name != "__proto__" && InjectedScriptHost.formatAccessorsAsProperties(object) && !doesAttributeHaveObservableSideEffectOnGet(object, name)) {
if ("get" in descriptor && "set" in descriptor && name != "__proto__" && InjectedScriptHost.formatAccessorsAsProperties(object, descriptor.get) && !doesAttributeHaveObservableSideEffectOnGet(object, name)) {
descriptor.value = InjectedScriptHost.suppressWarningsAndCallFunction(function(attribute) { return this[attribute]; }, object, [property]);
descriptor.isOwn = true;
delete descriptor.get;
@ -534,30 +520,6 @@ InjectedScript.prototype = {
}
},
/**
* @param {!Object} nativeCommandLineAPI
* @return {!Object}
*/
installCommandLineAPI: function(nativeCommandLineAPI)
{
// NOTE: This list contains only not native Command Line API methods. For full list: V8Console.
// NOTE: Argument names of these methods will be printed in the console, so use pretty names!
var members = [ "$", "$$", "$x", "monitorEvents", "unmonitorEvents", "getEventListeners" ];
for (var member of members)
nativeCommandLineAPI[member] = CommandLineAPIImpl[member];
var functionToStringMap = new Map([
["$", "function $(selector, [startNode]) { [Command Line API] }"],
["$$", "function $$(selector, [startNode]) { [Command Line API] }"],
["$x", "function $x(xpath, [startNode]) { [Command Line API] }"],
["monitorEvents", "function monitorEvents(object, [types]) { [Command Line API] }"],
["unmonitorEvents", "function unmonitorEvents(object, [types]) { [Command Line API] }"],
["getEventListeners", "function getEventListeners(node) { [Command Line API] }"]
]);
for (let entry of functionToStringMap)
nativeCommandLineAPI[entry[0]].toString = (() => entry[1]);
return nativeCommandLineAPI;
},
/**
* @param {*} object
* @return {boolean}
@ -618,7 +580,12 @@ InjectedScript.prototype = {
return toString(obj);
if (subtype === "node") {
var description = obj.nodeName.toLowerCase();
var description = "";
if (obj.nodeName)
description = obj.nodeName.toLowerCase();
else if (obj.constructor)
description = obj.constructor.name.toLowerCase();
switch (obj.nodeType) {
case 1 /* Node.ELEMENT_NODE */:
description += obj.id ? "#" + obj.id : "";
@ -1044,179 +1011,5 @@ InjectedScript.RemoteObject.prototype = {
__proto__: null
}
var CommandLineAPIImpl = { __proto__: null }
/**
* @param {string} selector
* @param {!Node=} opt_startNode
* @return {*}
*/
CommandLineAPIImpl.$ = function (selector, opt_startNode)
{
if (CommandLineAPIImpl._canQuerySelectorOnNode(opt_startNode))
return opt_startNode.querySelector(selector);
return inspectedGlobalObject.document.querySelector(selector);
}
/**
* @param {string} selector
* @param {!Node=} opt_startNode
* @return {*}
*/
CommandLineAPIImpl.$$ = function (selector, opt_startNode)
{
if (CommandLineAPIImpl._canQuerySelectorOnNode(opt_startNode))
return slice(opt_startNode.querySelectorAll(selector));
return slice(inspectedGlobalObject.document.querySelectorAll(selector));
}
/**
* @param {!Node=} node
* @return {boolean}
*/
CommandLineAPIImpl._canQuerySelectorOnNode = function(node)
{
return !!node && InjectedScriptHost.subtype(node) === "node" && (node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE);
}
/**
* @param {string} xpath
* @param {!Node=} opt_startNode
* @return {*}
*/
CommandLineAPIImpl.$x = function(xpath, opt_startNode)
{
var doc = (opt_startNode && opt_startNode.ownerDocument) || inspectedGlobalObject.document;
var result = doc.evaluate(xpath, opt_startNode || doc, null, XPathResult.ANY_TYPE, null);
switch (result.resultType) {
case XPathResult.NUMBER_TYPE:
return result.numberValue;
case XPathResult.STRING_TYPE:
return result.stringValue;
case XPathResult.BOOLEAN_TYPE:
return result.booleanValue;
default:
var nodes = [];
var node;
while (node = result.iterateNext())
push(nodes, node);
return nodes;
}
}
/**
* @param {!Object} object
* @param {!Array.<string>|string=} opt_types
*/
CommandLineAPIImpl.monitorEvents = function(object, opt_types)
{
if (!object || !object.addEventListener || !object.removeEventListener)
return;
var types = CommandLineAPIImpl._normalizeEventTypes(opt_types);
for (var i = 0; i < types.length; ++i) {
object.removeEventListener(types[i], CommandLineAPIImpl._logEvent, false);
object.addEventListener(types[i], CommandLineAPIImpl._logEvent, false);
}
}
/**
* @param {!Object} object
* @param {!Array.<string>|string=} opt_types
*/
CommandLineAPIImpl.unmonitorEvents = function(object, opt_types)
{
if (!object || !object.addEventListener || !object.removeEventListener)
return;
var types = CommandLineAPIImpl._normalizeEventTypes(opt_types);
for (var i = 0; i < types.length; ++i)
object.removeEventListener(types[i], CommandLineAPIImpl._logEvent, false);
}
/**
* @param {!Node} node
* @return {!Object|undefined}
*/
CommandLineAPIImpl.getEventListeners = function(node)
{
var result = nullifyObjectProto(InjectedScriptHost.getEventListeners(node));
if (!result)
return;
// TODO(dtapuska): Remove this one closure compiler is updated
// to handle EventListenerOptions and passive event listeners
// has shipped. Don't JSDoc these otherwise it will fail.
// @param {boolean} capture
// @param {boolean} passive
// @return {boolean|undefined|{capture: (boolean|undefined), passive: boolean}}
function eventListenerOptions(capture, passive)
{
return {"capture": capture, "passive": passive};
}
/**
* @param {!Node} node
* @param {string} type
* @param {function()} listener
* @param {boolean} capture
* @param {boolean} passive
*/
function removeEventListenerWrapper(node, type, listener, capture, passive)
{
node.removeEventListener(type, listener, eventListenerOptions(capture, passive));
}
/** @this {{type: string, listener: function(), useCapture: boolean, passive: boolean}} */
var removeFunc = function()
{
removeEventListenerWrapper(node, this.type, this.listener, this.useCapture, this.passive);
}
for (var type in result) {
var listeners = result[type];
for (var i = 0, listener; listener = listeners[i]; ++i) {
listener["type"] = type;
listener["remove"] = removeFunc;
}
}
return result;
}
/**
* @param {!Array.<string>|string=} types
* @return {!Array.<string>}
*/
CommandLineAPIImpl._normalizeEventTypes = function(types)
{
if (typeof types === "undefined")
types = ["mouse", "key", "touch", "pointer", "control", "load", "unload", "abort", "error", "select", "input", "change", "submit", "reset", "focus", "blur", "resize", "scroll", "search", "devicemotion", "deviceorientation"];
else if (typeof types === "string")
types = [types];
var result = [];
for (var i = 0; i < types.length; ++i) {
if (types[i] === "mouse")
push(result, "click", "dblclick", "mousedown", "mouseeenter", "mouseleave", "mousemove", "mouseout", "mouseover", "mouseup", "mouseleave", "mousewheel");
else if (types[i] === "key")
push(result, "keydown", "keyup", "keypress", "textInput");
else if (types[i] === "touch")
push(result, "touchstart", "touchmove", "touchend", "touchcancel");
else if (types[i] === "pointer")
push(result, "pointerover", "pointerout", "pointerenter", "pointerleave", "pointerdown", "pointerup", "pointermove", "pointercancel", "gotpointercapture", "lostpointercapture");
else if (types[i] === "control")
push(result, "resize", "scroll", "zoom", "focus", "blur", "select", "input", "change", "submit", "reset");
else
push(result, types[i]);
}
return result;
}
/**
* @param {!Event} event
*/
CommandLineAPIImpl._logEvent = function(event)
{
inspectedGlobalObject.console.log(event.type, event);
}
return injectedScript;
})

70
deps/v8_inspector/platform/v8_inspector/InspectorWrapper.cpp

@ -1,70 +0,0 @@
// Copyright 2015 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.
#include "platform/v8_inspector/InspectorWrapper.h"
#include "platform/v8_inspector/V8Compat.h"
#include "platform/v8_inspector/public/V8DebuggerClient.h"
#include "wtf/Assertions.h"
#include <v8-debug.h>
namespace blink {
v8::Local<v8::FunctionTemplate> InspectorWrapperBase::createWrapperTemplate(v8::Isolate* isolate, const char* className, const protocol::Vector<V8MethodConfiguration>& methods, const protocol::Vector<V8AttributeConfiguration>& attributes)
{
v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate::New(isolate);
functionTemplate->SetClassName(v8::String::NewFromUtf8(isolate, className, v8::NewStringType::kInternalized).ToLocalChecked());
v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceTemplate();
for (auto& config : attributes) {
v8::Local<v8::Name> v8name = v8::String::NewFromUtf8(isolate, config.name, v8::NewStringType::kInternalized).ToLocalChecked();
instanceTemplate->SetAccessor(v8name, config.callback);
}
for (auto& config : methods) {
v8::Local<v8::Name> v8name = v8::String::NewFromUtf8(isolate, config.name, v8::NewStringType::kInternalized).ToLocalChecked();
v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate::New(isolate, config.callback);
functionTemplate->RemovePrototype();
instanceTemplate->Set(v8name, functionTemplate, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::DontEnum | v8::ReadOnly));
}
return functionTemplate;
}
v8::Local<v8::Object> InspectorWrapperBase::createWrapper(v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context> context)
{
v8::MicrotasksScope microtasks(context->GetIsolate(), v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Function> function;
if (!constructorTemplate->GetFunction(context).ToLocal(&function))
return v8::Local<v8::Object>();
v8::Local<v8::Object> result;
if (!function->NewInstance(context).ToLocal(&result))
return v8::Local<v8::Object>();
return result;
}
void* InspectorWrapperBase::unwrap(v8::Local<v8::Context> context, v8::Local<v8::Object> object, const char* name)
{
v8::Isolate* isolate = context->GetIsolate();
DCHECK(context != v8::Debug::GetDebugContext(isolate));
v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, v8::String::NewFromUtf8(isolate, name, v8::NewStringType::kInternalized).ToLocalChecked());
v8::Local<v8::Value> value;
if (!object->GetPrivate(context, privateKey).ToLocal(&value))
return nullptr;
if (!value->IsExternal())
return nullptr;
return value.As<v8::External>()->Value();
}
v8::Local<v8::String> InspectorWrapperBase::v8InternalizedString(v8::Isolate* isolate, const char* name)
{
return v8::String::NewFromUtf8(isolate, name, v8::NewStringType::kInternalized).ToLocalChecked();
}
} // namespace blink

88
deps/v8_inspector/platform/v8_inspector/InspectorWrapper.h

@ -1,88 +0,0 @@
// Copyright 2015 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 InspectorWrapper_h
#define InspectorWrapper_h
#include "platform/inspector_protocol/Collections.h"
#include <v8.h>
namespace blink {
class InspectorWrapperBase {
public:
struct V8MethodConfiguration {
const char* name;
v8::FunctionCallback callback;
};
struct V8AttributeConfiguration {
const char* name;
v8::AccessorNameGetterCallback callback;
};
static v8::Local<v8::FunctionTemplate> createWrapperTemplate(v8::Isolate*, const char* className, const protocol::Vector<V8MethodConfiguration>& methods, const protocol::Vector<V8AttributeConfiguration>& attributes);
protected:
static v8::Local<v8::Object> createWrapper(v8::Local<v8::FunctionTemplate>, v8::Local<v8::Context>);
static void* unwrap(v8::Local<v8::Context>, v8::Local<v8::Object>, const char* name);
static v8::Local<v8::String> v8InternalizedString(v8::Isolate*, const char* name);
};
template<class T, char* const hiddenPropertyName, char* const className>
class InspectorWrapper final : public InspectorWrapperBase {
public:
class WeakCallbackData final {
public:
WeakCallbackData(v8::Isolate* isolate, T* impl, v8::Local<v8::Object> wrapper)
: m_impl(impl)
, m_persistent(isolate, wrapper)
{
m_persistent.SetWeak(this, &WeakCallbackData::weakCallback, v8::WeakCallbackType::kParameter);
}
T* m_impl;
std::unique_ptr<T> m_implOwn;
private:
static void weakCallback(const v8::WeakCallbackInfo<WeakCallbackData>& info)
{
delete info.GetParameter();
}
v8::Global<v8::Object> m_persistent;
};
static v8::Local<v8::FunctionTemplate> createWrapperTemplate(v8::Isolate* isolate, const protocol::Vector<V8MethodConfiguration>& methods, const protocol::Vector<V8AttributeConfiguration>& attributes)
{
return InspectorWrapperBase::createWrapperTemplate(isolate, className, methods, attributes);
}
static v8::Local<v8::Object> wrap(v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context> context, T* object)
{
v8::Context::Scope contextScope(context);
v8::Local<v8::Object> result = InspectorWrapperBase::createWrapper(constructorTemplate, context);
if (result.IsEmpty())
return v8::Local<v8::Object>();
v8::Isolate* isolate = context->GetIsolate();
v8::Local<v8::External> objectReference = v8::External::New(isolate, new WeakCallbackData(isolate, object, result));
v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, v8::String::NewFromUtf8(isolate, hiddenPropertyName, v8::NewStringType::kInternalized).ToLocalChecked());
result->SetPrivate(context, privateKey, objectReference);
return result;
}
static T* unwrap(v8::Local<v8::Context> context, v8::Local<v8::Object> object)
{
void* data = InspectorWrapperBase::unwrap(context, object, hiddenPropertyName);
if (!data)
return nullptr;
return reinterpret_cast<WeakCallbackData*>(data)->m_impl;
}
};
} // namespace blink
#endif // InspectorWrapper_h

3
deps/v8_inspector/platform/v8_inspector/JavaScriptCallFrame.h

@ -32,9 +32,8 @@
#define JavaScriptCallFrame_h
#include "platform/inspector_protocol/Collections.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/String16.h"
#include "wtf/PtrUtil.h"
#include "wtf/PtrUtil.h"
#include <v8.h>
namespace blink {

6
deps/v8_inspector/platform/v8_inspector/OWNERS

@ -3,3 +3,9 @@ caseq@chromium.org
dgozman@chromium.org
kozyatinskiy@chromium.org
pfeldman@chromium.org
# Changes to remote debugging protocol require devtools review to
# ensure backwards compatibility and committment to maintain.
per-file js_protocol.json=set noparent
per-file js_protocol.json=dgozman@chromium.org
per-file js_protocol.json=pfeldman@chromium.org

2
deps/v8_inspector/platform/v8_inspector/RemoteObjectId.cpp

@ -5,8 +5,8 @@
#include "platform/v8_inspector/RemoteObjectId.h"
#include "platform/inspector_protocol/Parser.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/Values.h"
#include "wtf/PtrUtil.h"
namespace blink {

4
deps/v8_inspector/platform/v8_inspector/RemoteObjectId.h

@ -5,9 +5,9 @@
#ifndef RemoteObjectId_h
#define RemoteObjectId_h
#include "platform/inspector_protocol/ErrorSupport.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/String16.h"
#include "platform/inspector_protocol/TypeBuilder.h"
#include "wtf/PtrUtil.h"
namespace blink {

4
deps/v8_inspector/platform/v8_inspector/V8Compat.h

@ -7,7 +7,7 @@
#include <v8.h>
#if V8_MAJOR_VERSION < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 1)
#if V8_MAJOR_VERSION < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2)
namespace v8 {
// In standalone V8 inspector this is expected to be noop anyways...
@ -23,6 +23,6 @@ public:
} // namespace v8
#endif // V8_MAJOR_VERSION < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 1)
#endif // V8_MAJOR_VERSION < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2)
#endif // V8Compat_h

161
deps/v8_inspector/platform/v8_inspector/V8Console.cpp

@ -4,6 +4,7 @@
#include "platform/v8_inspector/V8Console.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/String16.h"
#include "platform/v8_inspector/InjectedScript.h"
#include "platform/v8_inspector/InspectedContext.h"
@ -76,18 +77,18 @@ public:
return m_debuggerClient;
}
void addMessage(MessageType type, MessageLevel level, bool allowEmptyArguments, int skipArgumentCount)
void addMessage(MessageType type, MessageLevel level, String16 emptyText, int skipArgumentCount)
{
if (!allowEmptyArguments && !m_info.Length())
if (emptyText.isEmpty() && !m_info.Length())
return;
if (V8DebuggerClient* debuggerClient = ensureDebuggerClient())
debuggerClient->reportMessageToConsole(m_context, type, level, String16(), &m_info, skipArgumentCount, -1);
debuggerClient->reportMessageToConsole(m_context, type, level, m_info.Length() <= skipArgumentCount ? emptyText : String16(), &m_info, skipArgumentCount);
}
void addMessage(MessageType type, MessageLevel level, const String16& message)
{
if (V8DebuggerClient* debuggerClient = ensureDebuggerClient())
debuggerClient->reportMessageToConsole(m_context, type, level, message, nullptr, 0 /* skipArgumentsCount */, 1 /* maxStackSize */);
debuggerClient->reportMessageToConsole(m_context, type, level, message, nullptr, 0 /* skipArgumentsCount */);
}
void addDeprecationMessage(const char* id, const String16& message)
@ -95,7 +96,7 @@ public:
if (checkAndSetPrivateFlagOnConsole(id, false))
return;
if (V8DebuggerClient* debuggerClient = ensureDebuggerClient())
debuggerClient->reportMessageToConsole(m_context, LogMessageType, WarningMessageLevel, message, nullptr, 0 /* skipArgumentsCount */, 0 /* maxStackSize */);
debuggerClient->reportMessageToConsole(m_context, LogMessageType, WarningMessageLevel, message, nullptr, 0 /* skipArgumentsCount */);
}
bool firstArgToBoolean(bool defaultValue)
@ -191,8 +192,8 @@ public:
V8ProfilerAgentImpl* profilerAgent()
{
if (V8InspectorSessionImpl* session = currentSession()) {
if (session && session->profilerAgentImpl()->enabled())
return session->profilerAgentImpl();
if (session && session->profilerAgent()->enabled())
return session->profilerAgent();
}
return nullptr;
}
@ -200,8 +201,8 @@ public:
V8DebuggerAgentImpl* debuggerAgent()
{
if (V8InspectorSessionImpl* session = currentSession()) {
if (session && session->debuggerAgentImpl()->enabled())
return session->debuggerAgentImpl();
if (session && session->debuggerAgent()->enabled())
return session->debuggerAgent();
}
return nullptr;
}
@ -266,67 +267,67 @@ void createBoundFunctionProperty(v8::Local<v8::Context> context, v8::Local<v8::O
void V8Console::debugCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ConsoleHelper(info).addMessage(LogMessageType, DebugMessageLevel, false, 0);
ConsoleHelper(info).addMessage(LogMessageType, DebugMessageLevel, String16(), 0);
}
void V8Console::errorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ConsoleHelper(info).addMessage(LogMessageType, ErrorMessageLevel, false, 0);
ConsoleHelper(info).addMessage(LogMessageType, ErrorMessageLevel, String16(), 0);
}
void V8Console::infoCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ConsoleHelper(info).addMessage(LogMessageType, InfoMessageLevel, false, 0);
ConsoleHelper(info).addMessage(LogMessageType, InfoMessageLevel, String16(), 0);
}
void V8Console::logCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ConsoleHelper(info).addMessage(LogMessageType, LogMessageLevel, false, 0);
ConsoleHelper(info).addMessage(LogMessageType, LogMessageLevel, String16(), 0);
}
void V8Console::warnCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ConsoleHelper(info).addMessage(LogMessageType, WarningMessageLevel, false, 0);
ConsoleHelper(info).addMessage(LogMessageType, WarningMessageLevel, String16(), 0);
}
void V8Console::dirCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ConsoleHelper(info).addMessage(DirMessageType, LogMessageLevel, false, 0);
ConsoleHelper(info).addMessage(DirMessageType, LogMessageLevel, String16(), 0);
}
void V8Console::dirxmlCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ConsoleHelper(info).addMessage(DirXMLMessageType, LogMessageLevel, false, 0);
ConsoleHelper(info).addMessage(DirXMLMessageType, LogMessageLevel, String16(), 0);
}
void V8Console::tableCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ConsoleHelper(info).addMessage(TableMessageType, LogMessageLevel, false, 0);
ConsoleHelper(info).addMessage(TableMessageType, LogMessageLevel, String16(), 0);
}
void V8Console::traceCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ConsoleHelper(info).addMessage(TraceMessageType, LogMessageLevel, true, 0);
ConsoleHelper(info).addMessage(TraceMessageType, LogMessageLevel, String16("console.trace"), 0);
}
void V8Console::groupCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ConsoleHelper(info).addMessage(StartGroupMessageType, LogMessageLevel, true, 0);
ConsoleHelper(info).addMessage(StartGroupMessageType, LogMessageLevel, String16("console.group"), 0);
}
void V8Console::groupCollapsedCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ConsoleHelper(info).addMessage(StartGroupCollapsedMessageType, LogMessageLevel, true, 0);
ConsoleHelper(info).addMessage(StartGroupCollapsedMessageType, LogMessageLevel, String16("console.groupCollapsed"), 0);
}
void V8Console::groupEndCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ConsoleHelper(info).addMessage(EndGroupMessageType, LogMessageLevel, true, 0);
ConsoleHelper(info).addMessage(EndGroupMessageType, LogMessageLevel, String16("console.groupEnd"), 0);
}
void V8Console::clearCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ConsoleHelper(info).addMessage(ClearMessageType, LogMessageLevel, true, 0);
ConsoleHelper(info).addMessage(ClearMessageType, LogMessageLevel, String16("console.clear"), 0);
}
void V8Console::countCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
@ -356,7 +357,7 @@ void V8Console::assertCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
ConsoleHelper helper(info);
if (helper.firstArgToBoolean(false))
return;
helper.addMessage(AssertMessageType, ErrorMessageLevel, true, 1);
helper.addMessage(AssertMessageType, ErrorMessageLevel, String16("console.assert"), 1);
if (V8DebuggerAgentImpl* debuggerAgent = helper.debuggerAgent())
debuggerAgent->breakProgramOnException(protocol::Debugger::Paused::ReasonEnum::Assert, nullptr);
}
@ -448,7 +449,7 @@ void V8Console::memoryGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&
{
if (V8DebuggerClient* client = ConsoleHelper(info).ensureDebuggerClient()) {
v8::Local<v8::Value> memoryValue;
if (!client->memoryInfo(info.GetIsolate(), info.GetIsolate()->GetCurrentContext(), info.Holder()).ToLocal(&memoryValue))
if (!client->memoryInfo(info.GetIsolate(), info.GetIsolate()->GetCurrentContext()).ToLocal(&memoryValue))
return;
info.GetReturnValue().Set(memoryValue);
}
@ -597,7 +598,7 @@ static void inspectImpl(const v8::FunctionCallbackInfo<v8::Value>& info, bool co
if (copyToClipboard)
hints->setBoolean("copyToClipboard", true);
if (V8InspectorSessionImpl* session = helper.currentSession())
session->runtimeAgentImpl()->inspect(std::move(wrappedObject), std::move(hints));
session->runtimeAgent()->inspect(std::move(wrappedObject), std::move(hints));
}
void V8Console::inspectCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
@ -656,6 +657,9 @@ v8::Local<v8::Object> V8Console::createConsole(InspectedContext* inspectedContex
createBoundFunctionProperty(context, console, "timeEnd", V8Console::timeEndCallback);
createBoundFunctionProperty(context, console, "timeStamp", V8Console::timeStampCallback);
bool success = console->SetPrototype(context, v8::Object::New(isolate)).FromMaybe(false);
DCHECK(success);
if (hasMemoryAttribute)
console->SetAccessorProperty(toV8StringInternalized(isolate, "memory"), v8::Function::New(isolate, V8Console::memoryGetterCallback, console), v8::Function::New(isolate, V8Console::memorySetterCallback), static_cast<v8::PropertyAttribute>(v8::None), v8::DEFAULT);
@ -663,6 +667,12 @@ v8::Local<v8::Object> V8Console::createConsole(InspectedContext* inspectedContex
return console;
}
void V8Console::clearInspectedContextIfNeeded(v8::Local<v8::Context> context, v8::Local<v8::Object> console)
{
v8::Isolate* isolate = context->GetIsolate();
console->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::External::New(isolate, nullptr));
}
v8::Local<v8::Object> V8Console::createCommandLineAPI(InspectedContext* inspectedContext)
{
v8::Local<v8::Context> context = inspectedContext->context();
@ -693,38 +703,101 @@ v8::Local<v8::Object> V8Console::createCommandLineAPI(InspectedContext* inspecte
createBoundFunctionProperty(context, commandLineAPI, "$3", V8Console::inspectedObject3);
createBoundFunctionProperty(context, commandLineAPI, "$4", V8Console::inspectedObject4);
inspectedContext->debugger()->client()->installAdditionalCommandLineAPI(context, commandLineAPI);
commandLineAPI->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::External::New(isolate, inspectedContext));
return commandLineAPI;
}
void V8Console::clearInspectedContextIfNeeded(v8::Local<v8::Context> context, v8::Local<v8::Object> console)
static bool isCommandLineAPIGetter(const String16& name)
{
v8::Isolate* isolate = context->GetIsolate();
console->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::External::New(isolate, nullptr));
if (name.length() != 2)
return false;
// $0 ... $4, $_
return name[0] == '$' && ((name[1] >= '0' && name[1] <= '4') || name[1] == '_');
}
bool V8Debugger::isCommandLineAPIMethod(const String16& name)
void V8Console::CommandLineAPIScope::accessorGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
static protocol::HashSet<String16> methods;
if (methods.size() == 0) {
const char* members[] = { "$", "$$", "$x", "dir", "dirxml", "keys", "values", "profile", "profileEnd",
"monitorEvents", "unmonitorEvents", "inspect", "copy", "clear", "getEventListeners",
"debug", "undebug", "monitor", "unmonitor", "table" };
for (size_t i = 0; i < PROTOCOL_ARRAY_LENGTH(members); ++i)
methods.add(members[i]);
CommandLineAPIScope* scope = static_cast<CommandLineAPIScope*>(info.Data().As<v8::External>()->Value());
DCHECK(scope);
v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
if (scope->m_cleanup) {
bool removed = info.Holder()->Delete(context, name).FromMaybe(false);
DCHECK(removed);
return;
}
v8::Local<v8::Object> commandLineAPI = scope->m_commandLineAPI;
v8::Local<v8::Value> value;
if (!commandLineAPI->Get(context, name).ToLocal(&value))
return;
if (isCommandLineAPIGetter(toProtocolStringWithTypeCheck(name))) {
DCHECK(value->IsFunction());
v8::MicrotasksScope microtasks(info.GetIsolate(), v8::MicrotasksScope::kDoNotRunMicrotasks);
if (value.As<v8::Function>()->Call(context, commandLineAPI, 0, nullptr).ToLocal(&value))
info.GetReturnValue().Set(value);
} else {
info.GetReturnValue().Set(value);
}
return methods.find(name) != methods.end();
}
bool V8Debugger::isCommandLineAPIGetter(const String16& name)
void V8Console::CommandLineAPIScope::accessorSetterCallback(v8::Local<v8::Name> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
{
protocol::HashSet<String16> getters;
if (getters.size() == 0) {
const char* members[] = { "$0", "$1", "$2", "$3", "$4", "$_" };
for (size_t i = 0; i < PROTOCOL_ARRAY_LENGTH(members); ++i)
getters.add(members[i]);
CommandLineAPIScope* scope = static_cast<CommandLineAPIScope*>(info.Data().As<v8::External>()->Value());
v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
if (!info.Holder()->Delete(context, name).FromMaybe(false))
return;
if (!info.Holder()->CreateDataProperty(context, name, value).FromMaybe(false))
return;
bool removed = scope->m_installedMethods->Delete(context, name).FromMaybe(false);
DCHECK(removed);
}
V8Console::CommandLineAPIScope::CommandLineAPIScope(v8::Local<v8::Context> context, v8::Local<v8::Object> commandLineAPI, v8::Local<v8::Object> global)
: m_context(context)
, m_commandLineAPI(commandLineAPI)
, m_global(global)
, m_installedMethods(v8::Set::New(context->GetIsolate()))
, m_cleanup(false)
{
v8::Local<v8::Array> names;
if (!m_commandLineAPI->GetOwnPropertyNames(context).ToLocal(&names))
return;
v8::Local<v8::External> externalThis = v8::External::New(context->GetIsolate(), this);
for (size_t i = 0; i < names->Length(); ++i) {
v8::Local<v8::Value> name;
if (!names->Get(context, i).ToLocal(&name) || !name->IsName())
continue;
if (m_global->Has(context, name).FromMaybe(true))
continue;
if (!m_installedMethods->Add(context, name).ToLocal(&m_installedMethods))
continue;
if (!m_global->SetAccessor(context, v8::Local<v8::Name>::Cast(name), CommandLineAPIScope::accessorGetterCallback,
CommandLineAPIScope::accessorSetterCallback, externalThis,
v8::DEFAULT, v8::DontEnum).FromMaybe(false)) {
bool removed = m_installedMethods->Delete(context, name).FromMaybe(false);
DCHECK(removed);
continue;
}
}
}
V8Console::CommandLineAPIScope::~CommandLineAPIScope()
{
m_cleanup = true;
v8::Local<v8::Array> names = m_installedMethods->AsArray();
for (size_t i = 0; i < names->Length(); ++i) {
v8::Local<v8::Value> name;
if (!names->Get(m_context, i).ToLocal(&name) || !name->IsName())
continue;
if (name->IsString()) {
v8::Local<v8::Value> descriptor;
bool success = m_global->GetOwnPropertyDescriptor(m_context, v8::Local<v8::String>::Cast(name)).ToLocal(&descriptor);
DCHECK(success);
}
}
return getters.find(name) != getters.end();
}
} // namespace blink

22
deps/v8_inspector/platform/v8_inspector/V8Console.h

@ -5,6 +5,7 @@
#ifndef V8Console_h
#define V8Console_h
#include "platform/inspector_protocol/Allocator.h"
#include <v8.h>
namespace blink {
@ -16,8 +17,25 @@ class InspectedContext;
class V8Console {
public:
static v8::Local<v8::Object> createConsole(InspectedContext*, bool hasMemoryAttribute);
static v8::Local<v8::Object> createCommandLineAPI(InspectedContext*);
static void clearInspectedContextIfNeeded(v8::Local<v8::Context>, v8::Local<v8::Object> console);
static v8::Local<v8::Object> createCommandLineAPI(InspectedContext*);
class CommandLineAPIScope {
PROTOCOL_DISALLOW_COPY(CommandLineAPIScope);
public:
CommandLineAPIScope(v8::Local<v8::Context>, v8::Local<v8::Object> commandLineAPI, v8::Local<v8::Object> global);
~CommandLineAPIScope();
private:
static void accessorGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&);
static void accessorSetterCallback(v8::Local<v8::Name>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&);
v8::Local<v8::Context> m_context;
v8::Local<v8::Object> m_commandLineAPI;
v8::Local<v8::Object> m_global;
v8::Local<v8::Set> m_installedMethods;
bool m_cleanup;
};
private:
static void debugCallback(const v8::FunctionCallbackInfo<v8::Value>&);
@ -43,7 +61,7 @@ private:
static void timeCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void timeEndCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void timeStampCallback(const v8::FunctionCallbackInfo<v8::Value>&);
// TODO(philipj): There is no spec for the Memory Info API, see blink-dev:
// TODO(foolip): There is no spec for the Memory Info API, see blink-dev:
// https://groups.google.com/a/chromium.org/d/msg/blink-dev/g5YRCGpC9vs/b4OJz71NmPwJ
static void memoryGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void memorySetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);

39
deps/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.cpp

@ -155,12 +155,12 @@ static std::unique_ptr<protocol::Debugger::Location> buildProtocolLocation(const
.setColumnNumber(columnNumber).build();
}
V8DebuggerAgentImpl::V8DebuggerAgentImpl(V8InspectorSessionImpl* session)
V8DebuggerAgentImpl::V8DebuggerAgentImpl(V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel, protocol::DictionaryValue* state)
: m_debugger(session->debugger())
, m_session(session)
, m_enabled(false)
, m_state(nullptr)
, m_frontend(nullptr)
, m_state(state)
, m_frontend(frontendChannel)
, m_isolate(m_debugger->isolate())
, m_breakReason(protocol::Debugger::Paused::ReasonEnum::Other)
, m_scheduledDebuggerStep(NoStep)
@ -223,7 +223,6 @@ void V8DebuggerAgentImpl::enable(ErrorString* errorString)
}
enable();
DCHECK(m_frontend);
}
void V8DebuggerAgentImpl::disable(ErrorString*)
@ -272,19 +271,6 @@ void V8DebuggerAgentImpl::internalSetAsyncCallStackDepth(int depth)
}
}
void V8DebuggerAgentImpl::setInspectorState(protocol::DictionaryValue* state)
{
m_state = state;
}
void V8DebuggerAgentImpl::clearFrontend()
{
ErrorString error;
disable(&error);
DCHECK(m_frontend);
m_frontend = nullptr;
}
void V8DebuggerAgentImpl::restore()
{
DCHECK(!m_enabled);
@ -1027,6 +1013,7 @@ void V8DebuggerAgentImpl::asyncTaskStarted(void* task)
if (!m_maxAsyncCallStackDepth)
return;
m_currentTasks.append(task);
V8StackTraceImpl* stack = m_asyncTaskStacks.get(task);
// Needs to support following order of events:
// - asyncTaskScheduled
@ -1035,7 +1022,7 @@ void V8DebuggerAgentImpl::asyncTaskStarted(void* task)
// - asyncTaskCanceled <-- canceled before finished
// <-- async stack requested here -->
// - asyncTaskFinished
m_currentStacks.append(stack ? stack->clone() : nullptr);
m_currentStacks.append(stack ? stack->cloneImpl() : nullptr);
}
void V8DebuggerAgentImpl::asyncTaskFinished(void* task)
@ -1046,6 +1033,9 @@ void V8DebuggerAgentImpl::asyncTaskFinished(void* task)
if (!m_currentStacks.size())
return;
DCHECK(m_currentTasks.last() == task);
m_currentTasks.removeLast();
m_currentStacks.removeLast();
if (!m_recurringTasks.contains(task))
m_asyncTaskStacks.remove(task);
@ -1056,6 +1046,7 @@ void V8DebuggerAgentImpl::allAsyncTasksCanceled()
m_asyncTaskStacks.clear();
m_recurringTasks.clear();
m_currentStacks.clear();
m_currentTasks.clear();
}
void V8DebuggerAgentImpl::setBlackboxPatterns(ErrorString* errorString, std::unique_ptr<protocol::Array<String16>> patterns)
@ -1079,7 +1070,7 @@ void V8DebuggerAgentImpl::setBlackboxPatterns(ErrorString* errorString, std::uni
bool V8DebuggerAgentImpl::setBlackboxPattern(ErrorString* errorString, const String16& pattern)
{
std::unique_ptr<V8Regex> regex = wrapUnique(new V8Regex(m_debugger, pattern, true /** caseSensitive */, false /** multiline */));
std::unique_ptr<V8Regex> regex(new V8Regex(m_debugger, pattern, true /** caseSensitive */, false /** multiline */));
if (!regex->isValid()) {
*errorString = "Pattern parser error: " + regex->errorMessage();
return false;
@ -1283,9 +1274,9 @@ void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScr
const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr;
const bool* deprecatedCommentWasUsedParam = deprecatedCommentWasUsed ? &deprecatedCommentWasUsed : nullptr;
if (parsedScript.success)
m_frontend->scriptParsed(parsedScript.scriptId, scriptURL, script.startLine(), script.startColumn(), script.endLine(), script.endColumn(), executionContextId, script.hash(), isContentScriptParam, isInternalScriptParam, isLiveEditParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam);
m_frontend.scriptParsed(parsedScript.scriptId, scriptURL, script.startLine(), script.startColumn(), script.endLine(), script.endColumn(), executionContextId, script.hash(), isContentScriptParam, isInternalScriptParam, isLiveEditParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam);
else
m_frontend->scriptFailedToParse(parsedScript.scriptId, scriptURL, script.startLine(), script.startColumn(), script.endLine(), script.endColumn(), executionContextId, script.hash(), isContentScriptParam, isInternalScriptParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam);
m_frontend.scriptFailedToParse(parsedScript.scriptId, scriptURL, script.startLine(), script.startColumn(), script.endLine(), script.endColumn(), executionContextId, script.hash(), isContentScriptParam, isInternalScriptParam, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam);
m_scripts.set(parsedScript.scriptId, script);
@ -1311,7 +1302,7 @@ void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScr
breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.condition);
std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoint(cookie.first, parsedScript.scriptId, breakpoint, UserBreakpointSource);
if (location)
m_frontend->breakpointResolved(cookie.first, std::move(location));
m_frontend.breakpointResolved(cookie.first, std::move(location));
}
}
@ -1371,7 +1362,7 @@ V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8
}
ErrorString errorString;
m_frontend->paused(currentCallFrames(&errorString), m_breakReason, std::move(m_breakAuxData), std::move(hitBreakpointIds), currentAsyncStackTrace());
m_frontend.paused(currentCallFrames(&errorString), m_breakReason, std::move(m_breakAuxData), std::move(hitBreakpointIds), currentAsyncStackTrace());
m_scheduledDebuggerStep = NoStep;
m_javaScriptPauseScheduled = false;
m_steppingFromFramework = false;
@ -1392,7 +1383,7 @@ void V8DebuggerAgentImpl::didContinue()
JavaScriptCallFrames emptyCallFrames;
m_pausedCallFrames.swap(emptyCallFrames);
clearBreakDetails();
m_frontend->resumed();
m_frontend.resumed();
}
void V8DebuggerAgentImpl::breakProgram(const String16& breakReason, std::unique_ptr<protocol::DictionaryValue> data)

19
deps/v8_inspector/platform/v8_inspector/V8DebuggerAgentImpl.h

@ -6,11 +6,9 @@
#define V8DebuggerAgentImpl_h
#include "platform/inspector_protocol/Collections.h"
#include "platform/inspector_protocol/Dispatcher.h"
#include "platform/inspector_protocol/Frontend.h"
#include "platform/inspector_protocol/String16.h"
#include "platform/v8_inspector/V8DebuggerImpl.h"
#include "platform/v8_inspector/public/V8DebuggerAgent.h"
#include "platform/v8_inspector/protocol/Debugger.h"
namespace blink {
@ -26,7 +24,7 @@ class DictionaryValue;
using protocol::Maybe;
class V8DebuggerAgentImpl : public V8DebuggerAgent {
class V8DebuggerAgentImpl : public protocol::Debugger::Backend {
PROTOCOL_DISALLOW_COPY(V8DebuggerAgentImpl);
public:
enum SkipPauseRequest {
@ -43,17 +41,13 @@ public:
MonitorCommandBreakpointSource
};
explicit V8DebuggerAgentImpl(V8InspectorSessionImpl*);
V8DebuggerAgentImpl(V8InspectorSessionImpl*, protocol::FrontendChannel*, protocol::DictionaryValue* state);
~V8DebuggerAgentImpl() override;
void setInspectorState(protocol::DictionaryValue*) override;
void setFrontend(protocol::Frontend::Debugger* frontend) override { m_frontend = frontend; }
void clearFrontend() override;
void restore() override;
void disable(ErrorString*) override;
void restore();
// Part of the protocol.
void enable(ErrorString*) override;
void disable(ErrorString*) override;
void setBreakpointsActive(ErrorString*, bool active) override;
void setSkipAllPauses(ErrorString*, bool skipped) override;
void setBreakpointByUrl(ErrorString*,
@ -212,7 +206,7 @@ private:
V8InspectorSessionImpl* m_session;
bool m_enabled;
protocol::DictionaryValue* m_state;
protocol::Frontend::Debugger* m_frontend;
protocol::Debugger::Frontend m_frontend;
v8::Isolate* m_isolate;
v8::Global<v8::Context> m_pausedContext;
JavaScriptCallFrames m_pausedCallFrames;
@ -237,6 +231,7 @@ private:
AsyncTaskToStackTrace m_asyncTaskStacks;
protocol::HashSet<void*> m_recurringTasks;
int m_maxAsyncCallStackDepth;
protocol::Vector<void*> m_currentTasks;
protocol::Vector<std::unique_ptr<V8StackTraceImpl>> m_currentStacks;
std::unique_ptr<V8Regex> m_blackboxPattern;
protocol::HashMap<String16, protocol::Vector<std::pair<int, int>>> m_blackboxedPositions;

23
deps/v8_inspector/platform/v8_inspector/V8DebuggerImpl.cpp

@ -158,8 +158,8 @@ V8DebuggerAgentImpl* V8DebuggerImpl::findEnabledDebuggerAgent(int contextGroupId
if (!contextGroupId)
return nullptr;
V8InspectorSessionImpl* session = m_sessions.get(contextGroupId);
if (session && session->debuggerAgentImpl()->enabled())
return session->debuggerAgentImpl();
if (session && session->debuggerAgent()->enabled())
return session->debuggerAgent();
return nullptr;
}
@ -457,7 +457,7 @@ static V8DebuggerImpl* toV8DebuggerImpl(v8::Local<v8::Value> data)
void V8DebuggerImpl::breakProgramCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
DCHECK(2 == info.Length());
DCHECK_EQ(info.Length(), 2);
V8DebuggerImpl* thisPtr = toV8DebuggerImpl(info.Data());
v8::Local<v8::Context> pausedContext = thisPtr->m_isolate->GetCurrentContext();
v8::Local<v8::Value> exception;
@ -572,12 +572,7 @@ void V8DebuggerImpl::handleV8AsyncTaskEvent(V8DebuggerAgentImpl* agent, v8::Loca
String16 type = toProtocolStringWithTypeCheck(callInternalGetterFunction(eventData, "type"));
String16 name = toProtocolStringWithTypeCheck(callInternalGetterFunction(eventData, "name"));
int id = callInternalGetterFunction(eventData, "id")->ToInteger(m_isolate)->Value();
m_pausedContext = context;
m_executionState = executionState;
agent->didReceiveV8AsyncTaskEvent(context, type, name, id);
m_pausedContext.Clear();
m_executionState.Clear();
}
V8DebuggerParsedScript V8DebuggerImpl::createParsedScript(v8::Local<v8::Object> object, bool success)
@ -730,16 +725,16 @@ v8::Local<v8::Script> V8DebuggerImpl::compileInternalScript(v8::Local<v8::Contex
return script;
}
std::unique_ptr<V8StackTrace> V8DebuggerImpl::createStackTrace(v8::Local<v8::StackTrace> stackTrace, size_t maxStackSize)
std::unique_ptr<V8StackTrace> V8DebuggerImpl::createStackTrace(v8::Local<v8::StackTrace> stackTrace)
{
V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(m_isolate->GetCurrentContext());
return V8StackTraceImpl::create(agent, stackTrace, maxStackSize);
return V8StackTraceImpl::create(agent, stackTrace, V8StackTrace::maxCallStackSizeToCapture);
}
std::unique_ptr<V8InspectorSession> V8DebuggerImpl::connect(int contextGroupId)
std::unique_ptr<V8InspectorSession> V8DebuggerImpl::connect(int contextGroupId, protocol::FrontendChannel* channel, V8InspectorSessionClient* client, const String16* state)
{
DCHECK(!m_sessions.contains(contextGroupId));
std::unique_ptr<V8InspectorSessionImpl> session = V8InspectorSessionImpl::create(this, contextGroupId);
std::unique_ptr<V8InspectorSessionImpl> session = V8InspectorSessionImpl::create(this, contextGroupId, channel, client, state);
m_sessions.set(contextGroupId, session.get());
return std::move(session);
}
@ -769,7 +764,7 @@ void V8DebuggerImpl::contextCreated(const V8ContextInfo& info)
m_contexts.get(info.contextGroupId)->set(contextId, std::move(contextOwner));
if (V8InspectorSessionImpl* session = m_sessions.get(info.contextGroupId))
session->runtimeAgentImpl()->reportExecutionContextCreated(inspectedContext);
session->runtimeAgent()->reportExecutionContextCreated(inspectedContext);
}
void V8DebuggerImpl::contextDestroyed(v8::Local<v8::Context> context)
@ -781,7 +776,7 @@ void V8DebuggerImpl::contextDestroyed(v8::Local<v8::Context> context)
InspectedContext* inspectedContext = m_contexts.get(contextGroupId)->get(contextId);
if (V8InspectorSessionImpl* session = m_sessions.get(contextGroupId))
session->runtimeAgentImpl()->reportExecutionContextDestroyed(inspectedContext);
session->runtimeAgent()->reportExecutionContextDestroyed(inspectedContext);
m_contexts.get(contextGroupId)->remove(contextId);
if (m_contexts.get(contextGroupId)->isEmpty())

9
deps/v8_inspector/platform/v8_inspector/V8DebuggerImpl.h

@ -31,11 +31,12 @@
#ifndef V8DebuggerImpl_h
#define V8DebuggerImpl_h
#include "platform/inspector_protocol/TypeBuilder.h"
#include "platform/inspector_protocol/Maybe.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/v8_inspector/JavaScriptCallFrame.h"
#include "platform/v8_inspector/V8DebuggerScript.h"
#include "platform/v8_inspector/protocol/Debugger.h"
#include "platform/v8_inspector/public/V8Debugger.h"
#include "wtf/PtrUtil.h"
#include <v8-debug.h>
#include <v8.h>
@ -106,7 +107,7 @@ public:
v8::Local<v8::Context> regexContext();
// V8Debugger implementation
std::unique_ptr<V8InspectorSession> connect(int contextGroupId) override;
std::unique_ptr<V8InspectorSession> connect(int contextGroupId, protocol::FrontendChannel*, V8InspectorSessionClient*, const String16* state) override;
void contextCreated(const V8ContextInfo&) override;
void contextDestroyed(v8::Local<v8::Context>) override;
void resetContextGroup(int contextGroupId) override;
@ -114,7 +115,7 @@ public:
void didExecuteScript(v8::Local<v8::Context>) override;
void idleStarted() override;
void idleFinished() override;
std::unique_ptr<V8StackTrace> createStackTrace(v8::Local<v8::StackTrace>, size_t maxStackSize) override;
std::unique_ptr<V8StackTrace> createStackTrace(v8::Local<v8::StackTrace>) override;
std::unique_ptr<V8StackTrace> captureStackTrace(size_t maxStackSize) override;
using ContextByIdMap = protocol::HashMap<int, std::unique_ptr<InspectedContext>>;

2
deps/v8_inspector/platform/v8_inspector/V8FunctionCall.cpp

@ -30,11 +30,11 @@
#include "platform/v8_inspector/V8FunctionCall.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/v8_inspector/V8Compat.h"
#include "platform/v8_inspector/V8DebuggerImpl.h"
#include "platform/v8_inspector/V8StringUtil.h"
#include "platform/v8_inspector/public/V8DebuggerClient.h"
#include "wtf/PtrUtil.h"
#include <v8.h>

38
deps/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.cpp

@ -28,7 +28,7 @@ static const char samplingHeapProfilerInterval[] = "samplingHeapProfilerInterval
class HeapSnapshotProgress final : public v8::ActivityControl {
public:
HeapSnapshotProgress(protocol::Frontend::HeapProfiler* frontend)
HeapSnapshotProgress(protocol::HeapProfiler::Frontend* frontend)
: m_frontend(frontend) { }
ControlOption ReportProgressValue(int done, int total) override
{
@ -40,7 +40,7 @@ public:
return kContinue;
}
private:
protocol::Frontend::HeapProfiler* m_frontend;
protocol::HeapProfiler::Frontend* m_frontend;
};
class GlobalObjectNameResolver final : public v8::HeapProfiler::ObjectNameResolver {
@ -81,7 +81,7 @@ private:
class HeapSnapshotOutputStream final : public v8::OutputStream {
public:
HeapSnapshotOutputStream(protocol::Frontend::HeapProfiler* frontend)
HeapSnapshotOutputStream(protocol::HeapProfiler::Frontend* frontend)
: m_frontend(frontend) { }
void EndOfStream() override { }
int GetChunkSize() override { return 102400; }
@ -92,7 +92,7 @@ public:
return kContinue;
}
private:
protocol::Frontend::HeapProfiler* m_frontend;
protocol::HeapProfiler::Frontend* m_frontend;
};
v8::Local<v8::Object> objectByHeapObjectId(v8::Isolate* isolate, int id)
@ -117,7 +117,7 @@ private:
class HeapStatsStream final : public v8::OutputStream {
public:
HeapStatsStream(protocol::Frontend::HeapProfiler* frontend)
HeapStatsStream(protocol::HeapProfiler::Frontend* frontend)
: m_frontend(frontend)
{
}
@ -132,7 +132,7 @@ public:
WriteResult WriteHeapStatsChunk(v8::HeapStatsUpdate* updateData, int count) override
{
DCHECK(count > 0);
DCHECK_GT(count, 0);
std::unique_ptr<protocol::Array<int>> statsDiff = protocol::Array<int>::create();
for (int i = 0; i < count; ++i) {
statsDiff->addItem(updateData[i].index);
@ -144,14 +144,16 @@ public:
}
private:
protocol::Frontend::HeapProfiler* m_frontend;
protocol::HeapProfiler::Frontend* m_frontend;
};
} // namespace
V8HeapProfilerAgentImpl::V8HeapProfilerAgentImpl(V8InspectorSessionImpl* session)
V8HeapProfilerAgentImpl::V8HeapProfilerAgentImpl(V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel, protocol::DictionaryValue* state)
: m_session(session)
, m_isolate(session->debugger()->isolate())
, m_frontend(frontendChannel)
, m_state(state)
, m_hasTimer(false)
{
}
@ -160,18 +162,10 @@ V8HeapProfilerAgentImpl::~V8HeapProfilerAgentImpl()
{
}
void V8HeapProfilerAgentImpl::clearFrontend()
{
ErrorString error;
disable(&error);
DCHECK(m_frontend);
m_frontend = nullptr;
}
void V8HeapProfilerAgentImpl::restore()
{
if (m_state->booleanProperty(HeapProfilerAgentState::heapProfilerEnabled, false))
m_frontend->resetProfiles();
m_frontend.resetProfiles();
if (m_state->booleanProperty(HeapProfilerAgentState::heapObjectsTrackingEnabled, false))
startTrackingHeapObjectsInternal(m_state->booleanProperty(HeapProfilerAgentState::allocationTrackingEnabled, false));
#if V8_MAJOR_VERSION >= 5
@ -232,7 +226,7 @@ void V8HeapProfilerAgentImpl::takeHeapSnapshot(ErrorString* errorString, const p
}
std::unique_ptr<HeapSnapshotProgress> progress;
if (reportProgress.fromMaybe(false))
progress = wrapUnique(new HeapSnapshotProgress(m_frontend));
progress = wrapUnique(new HeapSnapshotProgress(&m_frontend));
GlobalObjectNameResolver resolver(m_session);
const v8::HeapSnapshot* snapshot = profiler->TakeHeapSnapshot(progress.get(), &resolver);
@ -240,7 +234,7 @@ void V8HeapProfilerAgentImpl::takeHeapSnapshot(ErrorString* errorString, const p
*errorString = "Failed to take heap snapshot";
return;
}
HeapSnapshotOutputStream stream(m_frontend);
HeapSnapshotOutputStream stream(&m_frontend);
snapshot->Serialize(&stream);
const_cast<v8::HeapSnapshot*>(snapshot)->Delete();
}
@ -308,11 +302,9 @@ void V8HeapProfilerAgentImpl::getHeapObjectId(ErrorString* errorString, const St
void V8HeapProfilerAgentImpl::requestHeapStatsUpdate()
{
if (!m_frontend)
return;
HeapStatsStream stream(m_frontend);
HeapStatsStream stream(&m_frontend);
v8::SnapshotObjectId lastSeenObjectId = m_isolate->GetHeapProfiler()->GetHeapStats(&stream);
m_frontend->lastSeenObjectId(lastSeenObjectId, m_session->debugger()->client()->currentTimeMS());
m_frontend.lastSeenObjectId(lastSeenObjectId, m_session->debugger()->client()->currentTimeMS());
}
// static

17
deps/v8_inspector/platform/v8_inspector/V8HeapProfilerAgentImpl.h

@ -6,7 +6,10 @@
#define V8HeapProfilerAgentImpl_h
#include "platform/inspector_protocol/Allocator.h"
#include "platform/v8_inspector/public/V8HeapProfilerAgent.h"
#include "platform/inspector_protocol/String16.h"
#include "platform/v8_inspector/protocol/HeapProfiler.h"
#include <v8.h>
namespace blink {
@ -14,16 +17,12 @@ class V8InspectorSessionImpl;
using protocol::Maybe;
class V8HeapProfilerAgentImpl : public V8HeapProfilerAgent {
class V8HeapProfilerAgentImpl : public protocol::HeapProfiler::Backend {
PROTOCOL_DISALLOW_COPY(V8HeapProfilerAgentImpl);
public:
explicit V8HeapProfilerAgentImpl(V8InspectorSessionImpl*);
V8HeapProfilerAgentImpl(V8InspectorSessionImpl*, protocol::FrontendChannel*, protocol::DictionaryValue* state);
~V8HeapProfilerAgentImpl() override;
void setInspectorState(protocol::DictionaryValue* state) override { m_state = state; }
void setFrontend(protocol::Frontend::HeapProfiler* frontend) override { m_frontend = frontend; }
void clearFrontend() override;
void restore() override;
void restore();
void collectGarbage(ErrorString*) override;
@ -50,7 +49,7 @@ private:
V8InspectorSessionImpl* m_session;
v8::Isolate* m_isolate;
protocol::Frontend::HeapProfiler* m_frontend;
protocol::HeapProfiler::Frontend m_frontend;
protocol::DictionaryValue* m_state;
bool m_hasTimer;
};

69
deps/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.cpp

@ -10,7 +10,6 @@
#include "platform/v8_inspector/V8DebuggerImpl.h"
#include "platform/v8_inspector/V8StringUtil.h"
#include "platform/v8_inspector/public/V8DebuggerClient.h"
#include "platform/v8_inspector/public/V8EventListenerInfo.h"
namespace blink {
@ -49,9 +48,7 @@ v8::Local<v8::Object> V8InjectedScriptHost::create(v8::Local<v8::Context> contex
setFunctionProperty(context, injectedScriptHost, "subtype", V8InjectedScriptHost::subtypeCallback, debuggerExternal);
setFunctionProperty(context, injectedScriptHost, "collectionEntries", V8InjectedScriptHost::collectionEntriesCallback, debuggerExternal);
setFunctionProperty(context, injectedScriptHost, "getInternalProperties", V8InjectedScriptHost::getInternalPropertiesCallback, debuggerExternal);
setFunctionProperty(context, injectedScriptHost, "getEventListeners", V8InjectedScriptHost::getEventListenersCallback, debuggerExternal);
setFunctionProperty(context, injectedScriptHost, "suppressWarningsAndCallFunction", V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback, debuggerExternal);
setFunctionProperty(context, injectedScriptHost, "setNonEnumProperty", V8InjectedScriptHost::setNonEnumPropertyCallback, debuggerExternal);
setFunctionProperty(context, injectedScriptHost, "bind", V8InjectedScriptHost::bindCallback, debuggerExternal);
setFunctionProperty(context, injectedScriptHost, "proxyTargetValue", V8InjectedScriptHost::proxyTargetValueCallback, debuggerExternal);
setFunctionProperty(context, injectedScriptHost, "prototype", V8InjectedScriptHost::prototypeCallback, debuggerExternal);
@ -69,9 +66,13 @@ void V8InjectedScriptHost::internalConstructorNameCallback(const v8::FunctionCal
void V8InjectedScriptHost::formatAccessorsAsProperties(const v8::FunctionCallbackInfo<v8::Value>& info)
{
if (info.Length() < 1)
DCHECK_EQ(info.Length(), 2);
info.GetReturnValue().Set(false);
if (!info[1]->IsFunction())
return;
// Check that function is user-defined.
if (info[1].As<v8::Function>()->ScriptId() != v8::UnboundScript::kNoScriptId)
return;
info.GetReturnValue().Set(unwrapDebugger(info)->client()->formatAccessorsAsProperties(info[0]));
}
@ -153,48 +154,6 @@ void V8InjectedScriptHost::getInternalPropertiesCallback(const v8::FunctionCallb
info.GetReturnValue().Set(properties);
}
static v8::Local<v8::Array> wrapListenerFunctions(v8::Isolate* isolate, const V8EventListenerInfoList& listeners, const String16& type)
{
v8::Local<v8::Array> result = v8::Array::New(isolate);
size_t handlersCount = listeners.size();
for (size_t i = 0, outputIndex = 0; i < handlersCount; ++i) {
if (listeners[i].eventType != type)
continue;
v8::Local<v8::Object> function = listeners[i].handler;
v8::Local<v8::Object> listenerEntry = v8::Object::New(isolate);
listenerEntry->Set(toV8StringInternalized(isolate, "listener"), function);
listenerEntry->Set(toV8StringInternalized(isolate, "useCapture"), v8::Boolean::New(isolate, listeners[i].useCapture));
listenerEntry->Set(toV8StringInternalized(isolate, "passive"), v8::Boolean::New(isolate, listeners[i].passive));
result->Set(v8::Number::New(isolate, outputIndex++), listenerEntry);
}
return result;
}
void V8InjectedScriptHost::getEventListenersCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
if (info.Length() < 1)
return;
V8DebuggerClient* client = unwrapDebugger(info)->client();
V8EventListenerInfoList listenerInfo;
// eventListeners call can produce message on ErrorEvent during lazy event listener compilation.
client->muteWarningsAndDeprecations();
client->eventListeners(info[0], listenerInfo);
client->unmuteWarningsAndDeprecations();
v8::Local<v8::Object> result = v8::Object::New(info.GetIsolate());
protocol::HashSet<String16> types;
for (auto& info : listenerInfo)
types.add(info.eventType);
for (const auto& it : types) {
v8::Local<v8::Array> listeners = wrapListenerFunctions(info.GetIsolate(), listenerInfo, it.first);
if (!listeners->Length())
continue;
result->Set(toV8String(info.GetIsolate(), it.first), listeners);
}
info.GetReturnValue().Set(result);
}
void V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
if (info.Length() < 2 || info.Length() > 3 || !info[0]->IsFunction()) {
@ -235,17 +194,6 @@ void V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback(const v8::Fun
client->unmuteWarningsAndDeprecations();
}
void V8InjectedScriptHost::setNonEnumPropertyCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
if (info.Length() < 3 || !info[0]->IsObject() || !info[1]->IsString())
return;
v8::Local<v8::Object> object = info[0].As<v8::Object>();
v8::Maybe<bool> success = object->DefineOwnProperty(info.GetIsolate()->GetCurrentContext(), info[1].As<v8::String>(), info[2], v8::DontEnum);
USE(success);
DCHECK(!success.IsNothing());
}
void V8InjectedScriptHost::bindCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
if (info.Length() < 2 || !info[1]->IsString())
@ -278,9 +226,4 @@ void V8InjectedScriptHost::prototypeCallback(const v8::FunctionCallbackInfo<v8::
info.GetReturnValue().Set(info[0].As<v8::Object>()->GetPrototype());
}
v8::Local<v8::Private> V8Debugger::scopeExtensionPrivate(v8::Isolate* isolate)
{
return v8::Private::ForApi(isolate, toV8StringInternalized(isolate, "V8Debugger#scopeExtension"));
}
} // namespace blink

4
deps/v8_inspector/platform/v8_inspector/V8InjectedScriptHost.h

@ -27,13 +27,9 @@ private:
static void formatAccessorsAsProperties(const v8::FunctionCallbackInfo<v8::Value>&);
static void isTypedArrayCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void subtypeCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void generatorObjectDetailsCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void collectionEntriesCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void getInternalPropertiesCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void getEventListenersCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void suppressWarningsAndCallFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void setNonEnumPropertyCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void setFunctionVariableValueCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void bindCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void proxyTargetValueCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void prototypeCallback(const v8::FunctionCallbackInfo<v8::Value>&);

113
deps/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.cpp

@ -4,6 +4,7 @@
#include "platform/v8_inspector/V8InspectorSessionImpl.h"
#include "platform/inspector_protocol/Parser.h"
#include "platform/v8_inspector/InjectedScript.h"
#include "platform/v8_inspector/InspectedContext.h"
#include "platform/v8_inspector/RemoteObjectId.h"
@ -19,53 +20,81 @@ namespace blink {
const char V8InspectorSession::backtraceObjectGroup[] = "backtrace";
std::unique_ptr<V8InspectorSessionImpl> V8InspectorSessionImpl::create(V8DebuggerImpl* debugger, int contextGroupId)
// static
bool V8InspectorSession::isV8ProtocolMethod(const String16& method)
{
return wrapUnique(new V8InspectorSessionImpl(debugger, contextGroupId));
return method.startWith("Debugger.") || method.startWith("HeapProfiler.") || method.startWith("Profiler.") || method.startWith("Runtime.");
}
V8InspectorSessionImpl::V8InspectorSessionImpl(V8DebuggerImpl* debugger, int contextGroupId)
std::unique_ptr<V8InspectorSessionImpl> V8InspectorSessionImpl::create(V8DebuggerImpl* debugger, int contextGroupId, protocol::FrontendChannel* channel, V8InspectorSessionClient* client, const String16* state)
{
return wrapUnique(new V8InspectorSessionImpl(debugger, contextGroupId, channel, client, state));
}
V8InspectorSessionImpl::V8InspectorSessionImpl(V8DebuggerImpl* debugger, int contextGroupId, protocol::FrontendChannel* channel, V8InspectorSessionClient* client, const String16* savedState)
: m_contextGroupId(contextGroupId)
, m_debugger(debugger)
, m_client(nullptr)
, m_client(client)
, m_customObjectFormatterEnabled(false)
, m_instrumentationCounter(0)
, m_runtimeAgent(wrapUnique(new V8RuntimeAgentImpl(this)))
, m_debuggerAgent(wrapUnique(new V8DebuggerAgentImpl(this)))
, m_heapProfilerAgent(wrapUnique(new V8HeapProfilerAgentImpl(this)))
, m_profilerAgent(wrapUnique(new V8ProfilerAgentImpl(this)))
, m_dispatcher(channel)
, m_state(nullptr)
, m_runtimeAgent(nullptr)
, m_debuggerAgent(nullptr)
, m_heapProfilerAgent(nullptr)
, m_profilerAgent(nullptr)
{
if (savedState) {
std::unique_ptr<protocol::Value> state = protocol::parseJSON(*savedState);
if (state)
m_state = protocol::DictionaryValue::cast(std::move(state));
if (!m_state)
m_state = protocol::DictionaryValue::create();
} else {
m_state = protocol::DictionaryValue::create();
}
V8InspectorSessionImpl::~V8InspectorSessionImpl()
{
discardInjectedScripts();
m_debugger->disconnect(this);
}
m_runtimeAgent = wrapUnique(new V8RuntimeAgentImpl(this, channel, agentState(protocol::Runtime::Metainfo::domainName)));
protocol::Runtime::Dispatcher::wire(&m_dispatcher, m_runtimeAgent.get());
V8DebuggerAgent* V8InspectorSessionImpl::debuggerAgent()
{
return m_debuggerAgent.get();
}
m_debuggerAgent = wrapUnique(new V8DebuggerAgentImpl(this, channel, agentState(protocol::Debugger::Metainfo::domainName)));
protocol::Debugger::Dispatcher::wire(&m_dispatcher, m_debuggerAgent.get());
V8HeapProfilerAgent* V8InspectorSessionImpl::heapProfilerAgent()
{
return m_heapProfilerAgent.get();
}
m_profilerAgent = wrapUnique(new V8ProfilerAgentImpl(this, channel, agentState(protocol::Profiler::Metainfo::domainName)));
protocol::Profiler::Dispatcher::wire(&m_dispatcher, m_profilerAgent.get());
V8ProfilerAgent* V8InspectorSessionImpl::profilerAgent()
{
return m_profilerAgent.get();
m_heapProfilerAgent = wrapUnique(new V8HeapProfilerAgentImpl(this, channel, agentState(protocol::HeapProfiler::Metainfo::domainName)));
protocol::HeapProfiler::Dispatcher::wire(&m_dispatcher, m_heapProfilerAgent.get());
if (savedState) {
m_runtimeAgent->restore();
m_debuggerAgent->restore();
m_heapProfilerAgent->restore();
m_profilerAgent->restore();
}
}
V8RuntimeAgent* V8InspectorSessionImpl::runtimeAgent()
V8InspectorSessionImpl::~V8InspectorSessionImpl()
{
return m_runtimeAgent.get();
ErrorString errorString;
m_profilerAgent->disable(&errorString);
m_heapProfilerAgent->disable(&errorString);
m_debuggerAgent->disable(&errorString);
m_runtimeAgent->disable(&errorString);
discardInjectedScripts();
m_debugger->disconnect(this);
}
void V8InspectorSessionImpl::setClient(V8InspectorSessionClient* client)
protocol::DictionaryValue* V8InspectorSessionImpl::agentState(const String16& name)
{
m_client = client;
protocol::DictionaryValue* state = m_state->getObject(name);
if (!state) {
std::unique_ptr<protocol::DictionaryValue> newState = protocol::DictionaryValue::create();
state = newState.get();
m_state->setObject(name, std::move(newState));
}
return state;
}
void V8InspectorSessionImpl::reset()
@ -203,14 +232,24 @@ void V8InspectorSessionImpl::reportAllContexts(V8RuntimeAgentImpl* agent)
void V8InspectorSessionImpl::changeInstrumentationCounter(int delta)
{
DCHECK(m_instrumentationCounter + delta >= 0);
if (!m_instrumentationCounter && m_client)
DCHECK_GE(m_instrumentationCounter + delta, 0);
if (!m_instrumentationCounter)
m_client->startInstrumenting();
m_instrumentationCounter += delta;
if (!m_instrumentationCounter && m_client)
if (!m_instrumentationCounter)
m_client->stopInstrumenting();
}
void V8InspectorSessionImpl::dispatchProtocolMessage(const String16& message)
{
m_dispatcher.dispatch(message);
}
String16 V8InspectorSessionImpl::stateJSON()
{
return m_state->toJSONString();
}
void V8InspectorSessionImpl::addInspectedObject(std::unique_ptr<V8InspectorSession::Inspectable> inspectable)
{
m_inspectedObjects.prepend(std::move(inspectable));
@ -251,6 +290,18 @@ void V8InspectorSessionImpl::setSkipAllPauses(bool skip)
m_debuggerAgent->setSkipAllPauses(&errorString, skip);
}
void V8InspectorSessionImpl::resume()
{
ErrorString errorString;
m_debuggerAgent->resume(&errorString);
}
void V8InspectorSessionImpl::stepOver()
{
ErrorString errorString;
m_debuggerAgent->stepOver(&errorString);
}
void V8InspectorSessionImpl::asyncTaskScheduled(const String16& taskName, void* task, bool recurring)
{
m_debuggerAgent->asyncTaskScheduled(taskName, task, recurring);

29
deps/v8_inspector/platform/v8_inspector/V8InspectorSessionImpl.h

@ -7,12 +7,12 @@
#include "platform/inspector_protocol/Allocator.h"
#include "platform/inspector_protocol/Collections.h"
#include "platform/inspector_protocol/DispatcherBase.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/String16.h"
#include "platform/inspector_protocol/TypeBuilder.h"
#include "platform/v8_inspector/protocol/Runtime.h"
#include "platform/v8_inspector/public/V8InspectorSession.h"
#include "platform/v8_inspector/public/V8InspectorSessionClient.h"
#include "platform/v8_inspector/public/V8RuntimeAgent.h"
#include "wtf/PtrUtil.h"
#include <v8.h>
@ -29,14 +29,14 @@ class V8RuntimeAgentImpl;
class V8InspectorSessionImpl : public V8InspectorSession {
PROTOCOL_DISALLOW_COPY(V8InspectorSessionImpl);
public:
static std::unique_ptr<V8InspectorSessionImpl> create(V8DebuggerImpl*, int contextGroupId);
static std::unique_ptr<V8InspectorSessionImpl> create(V8DebuggerImpl*, int contextGroupId, protocol::FrontendChannel*, V8InspectorSessionClient*, const String16* state);
~V8InspectorSessionImpl();
V8DebuggerImpl* debugger() const { return m_debugger; }
V8InspectorSessionClient* client() const { return m_client; }
V8DebuggerAgentImpl* debuggerAgentImpl() { return m_debuggerAgent.get(); }
V8ProfilerAgentImpl* profilerAgentImpl() { return m_profilerAgent.get(); }
V8RuntimeAgentImpl* runtimeAgentImpl() { return m_runtimeAgent.get(); }
V8DebuggerAgentImpl* debuggerAgent() { return m_debuggerAgent.get(); }
V8ProfilerAgentImpl* profilerAgent() { return m_profilerAgent.get(); }
V8RuntimeAgentImpl* runtimeAgent() { return m_runtimeAgent.get(); }
int contextGroupId() const { return m_contextGroupId; }
InjectedScript* findInjectedScript(ErrorString*, int contextId);
@ -48,17 +48,16 @@ public:
void changeInstrumentationCounter(int delta);
// V8InspectorSession implementation.
void setClient(V8InspectorSessionClient*) override;
void dispatchProtocolMessage(const String16& message) override;
String16 stateJSON() override;
void addInspectedObject(std::unique_ptr<V8InspectorSession::Inspectable>) override;
V8DebuggerAgent* debuggerAgent() override;
V8HeapProfilerAgent* heapProfilerAgent() override;
V8ProfilerAgent* profilerAgent() override;
V8RuntimeAgent* runtimeAgent() override;
void schedulePauseOnNextStatement(const String16& breakReason, std::unique_ptr<protocol::DictionaryValue> data) override;
void cancelPauseOnNextStatement() override;
void breakProgram(const String16& breakReason, std::unique_ptr<protocol::DictionaryValue> data) override;
void breakProgramOnException(const String16& breakReason, std::unique_ptr<protocol::DictionaryValue> data) override;
void setSkipAllPauses(bool) override;
void resume() override;
void stepOver() override;
void asyncTaskScheduled(const String16& taskName, void* task, bool recurring) override;
void asyncTaskCanceled(void* task) override;
void asyncTaskStarted(void* task) override;
@ -73,7 +72,8 @@ public:
static const unsigned kInspectedObjectBufferSize = 5;
private:
V8InspectorSessionImpl(V8DebuggerImpl*, int contextGroupId);
V8InspectorSessionImpl(V8DebuggerImpl*, int contextGroupId, protocol::FrontendChannel*, V8InspectorSessionClient*, const String16* state);
protocol::DictionaryValue* agentState(const String16& name);
int m_contextGroupId;
V8DebuggerImpl* m_debugger;
@ -81,6 +81,9 @@ private:
bool m_customObjectFormatterEnabled;
int m_instrumentationCounter;
protocol::UberDispatcher m_dispatcher;
std::unique_ptr<protocol::DictionaryValue> m_state;
std::unique_ptr<V8RuntimeAgentImpl> m_runtimeAgent;
std::unique_ptr<V8DebuggerAgentImpl> m_debuggerAgent;
std::unique_ptr<V8HeapProfilerAgentImpl> m_heapProfilerAgent;

20
deps/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.cpp

@ -121,11 +121,11 @@ public:
String16 m_title;
};
V8ProfilerAgentImpl::V8ProfilerAgentImpl(V8InspectorSessionImpl* session)
V8ProfilerAgentImpl::V8ProfilerAgentImpl(V8InspectorSessionImpl* session, protocol::FrontendChannel* frontendChannel, protocol::DictionaryValue* state)
: m_session(session)
, m_isolate(m_session->debugger()->isolate())
, m_state(nullptr)
, m_frontend(nullptr)
, m_state(state)
, m_frontend(frontendChannel)
, m_enabled(false)
, m_recordingCPUProfile(false)
{
@ -139,18 +139,16 @@ void V8ProfilerAgentImpl::consoleProfile(const String16& title)
{
if (!m_enabled)
return;
DCHECK(m_frontend);
String16 id = nextProfileId();
m_startedProfiles.append(ProfileDescriptor(id, title));
startProfiling(id);
m_frontend->consoleProfileStarted(id, currentDebugLocation(m_session->debugger()), title);
m_frontend.consoleProfileStarted(id, currentDebugLocation(m_session->debugger()), title);
}
void V8ProfilerAgentImpl::consoleProfileEnd(const String16& title)
{
if (!m_enabled)
return;
DCHECK(m_frontend);
String16 id;
String16 resolvedTitle;
// Take last started profile if no title was passed.
@ -176,7 +174,7 @@ void V8ProfilerAgentImpl::consoleProfileEnd(const String16& title)
if (!profile)
return;
std::unique_ptr<protocol::Debugger::Location> location = currentDebugLocation(m_session->debugger());
m_frontend->consoleProfileFinished(id, std::move(location), std::move(profile), resolvedTitle);
m_frontend.consoleProfileFinished(id, std::move(location), std::move(profile), resolvedTitle);
}
void V8ProfilerAgentImpl::enable(ErrorString*)
@ -211,14 +209,6 @@ void V8ProfilerAgentImpl::setSamplingInterval(ErrorString* error, int interval)
m_isolate->GetCpuProfiler()->SetSamplingInterval(interval);
}
void V8ProfilerAgentImpl::clearFrontend()
{
ErrorString error;
disable(&error);
DCHECK(m_frontend);
m_frontend = nullptr;
}
void V8ProfilerAgentImpl::restore()
{
DCHECK(!m_enabled);

15
deps/v8_inspector/platform/v8_inspector/V8ProfilerAgentImpl.h

@ -6,9 +6,8 @@
#define V8ProfilerAgentImpl_h
#include "platform/inspector_protocol/Allocator.h"
#include "platform/inspector_protocol/Frontend.h"
#include "platform/inspector_protocol/String16.h"
#include "platform/v8_inspector/public/V8ProfilerAgent.h"
#include "platform/v8_inspector/protocol/Profiler.h"
namespace v8 {
class Isolate;
@ -18,18 +17,14 @@ namespace blink {
class V8InspectorSessionImpl;
class V8ProfilerAgentImpl : public V8ProfilerAgent {
class V8ProfilerAgentImpl : public protocol::Profiler::Backend {
PROTOCOL_DISALLOW_COPY(V8ProfilerAgentImpl);
public:
explicit V8ProfilerAgentImpl(V8InspectorSessionImpl*);
V8ProfilerAgentImpl(V8InspectorSessionImpl*, protocol::FrontendChannel*, protocol::DictionaryValue* state);
~V8ProfilerAgentImpl() override;
bool enabled() const { return m_enabled; }
void setInspectorState(protocol::DictionaryValue* state) override { m_state = state; }
void setFrontend(protocol::Frontend::Profiler* frontend) override { m_frontend = frontend; }
void clearFrontend() override;
void restore() override;
void restore();
void enable(ErrorString*) override;
void disable(ErrorString*) override;
@ -51,7 +46,7 @@ private:
V8InspectorSessionImpl* m_session;
v8::Isolate* m_isolate;
protocol::DictionaryValue* m_state;
protocol::Frontend::Profiler* m_frontend;
protocol::Profiler::Frontend m_frontend;
bool m_enabled;
bool m_recordingCPUProfile;
class ProfileDescriptor;

1
deps/v8_inspector/platform/v8_inspector/V8Regex.cpp

@ -4,7 +4,6 @@
#include "platform/v8_inspector/V8Regex.h"
#include "platform/inspector_protocol/Collections.h"
#include "platform/v8_inspector/V8Compat.h"
#include "platform/v8_inspector/V8DebuggerImpl.h"
#include "platform/v8_inspector/V8StringUtil.h"

34
deps/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.cpp

@ -56,10 +56,10 @@ static bool hasInternalError(ErrorString* errorString, bool hasError)
return hasError;
}
V8RuntimeAgentImpl::V8RuntimeAgentImpl(V8InspectorSessionImpl* session)
V8RuntimeAgentImpl::V8RuntimeAgentImpl(V8InspectorSessionImpl* session, protocol::FrontendChannel* FrontendChannel, protocol::DictionaryValue* state)
: m_session(session)
, m_state(nullptr)
, m_frontend(nullptr)
, m_state(state)
, m_frontend(FrontendChannel)
, m_debugger(session->debugger())
, m_enabled(false)
{
@ -343,29 +343,11 @@ void V8RuntimeAgentImpl::runScript(ErrorString* errorString,
scope.injectedScript()->wrapEvaluateResult(errorString, maybeResultValue, scope.tryCatch(), objectGroup.fromMaybe(""), false, false, result, nullptr, exceptionDetails);
}
void V8RuntimeAgentImpl::setInspectorState(protocol::DictionaryValue* state)
{
m_state = state;
}
void V8RuntimeAgentImpl::setFrontend(protocol::Frontend::Runtime* frontend)
{
m_frontend = frontend;
}
void V8RuntimeAgentImpl::clearFrontend()
{
ErrorString error;
disable(&error);
DCHECK(m_frontend);
m_frontend = nullptr;
}
void V8RuntimeAgentImpl::restore()
{
if (!m_state->booleanProperty(V8RuntimeAgentImplState::runtimeEnabled, false))
return;
m_frontend->executionContextsCleared();
m_frontend.executionContextsCleared();
ErrorString error;
enable(&error);
if (m_state->booleanProperty(V8RuntimeAgentImplState::customObjectFormatterEnabled, false))
@ -402,7 +384,7 @@ void V8RuntimeAgentImpl::reset()
for (auto& idContext : *contexts)
idContext.second->setReported(false);
}
m_frontend->executionContextsCleared();
m_frontend.executionContextsCleared();
}
}
@ -417,21 +399,21 @@ void V8RuntimeAgentImpl::reportExecutionContextCreated(InspectedContext* context
.setName(context->humanReadableName())
.setOrigin(context->origin())
.setFrameId(context->frameId()).build();
m_frontend->executionContextCreated(std::move(description));
m_frontend.executionContextCreated(std::move(description));
}
void V8RuntimeAgentImpl::reportExecutionContextDestroyed(InspectedContext* context)
{
if (m_enabled && context->isReported()) {
context->setReported(false);
m_frontend->executionContextDestroyed(context->contextId());
m_frontend.executionContextDestroyed(context->contextId());
}
}
void V8RuntimeAgentImpl::inspect(std::unique_ptr<protocol::Runtime::RemoteObject> objectToInspect, std::unique_ptr<protocol::DictionaryValue> hints)
{
if (m_enabled)
m_frontend->inspectRequested(std::move(objectToInspect), std::move(hints));
m_frontend.inspectRequested(std::move(objectToInspect), std::move(hints));
}
} // namespace blink

19
deps/v8_inspector/platform/v8_inspector/V8RuntimeAgentImpl.h

@ -32,8 +32,10 @@
#define V8RuntimeAgentImpl_h
#include "platform/inspector_protocol/Allocator.h"
#include "platform/inspector_protocol/Frontend.h"
#include "platform/v8_inspector/public/V8RuntimeAgent.h"
#include "platform/inspector_protocol/String16.h"
#include "platform/v8_inspector/protocol/Runtime.h"
#include <v8.h>
namespace blink {
@ -49,17 +51,12 @@ class DictionaryValue;
using protocol::Maybe;
class V8RuntimeAgentImpl : public V8RuntimeAgent {
class V8RuntimeAgentImpl : public protocol::Runtime::Backend {
PROTOCOL_DISALLOW_COPY(V8RuntimeAgentImpl);
public:
explicit V8RuntimeAgentImpl(V8InspectorSessionImpl*);
V8RuntimeAgentImpl(V8InspectorSessionImpl*, protocol::FrontendChannel*, protocol::DictionaryValue* state);
~V8RuntimeAgentImpl() override;
// State management methods.
void setInspectorState(protocol::DictionaryValue*) override;
void setFrontend(protocol::Frontend::Runtime*) override;
void clearFrontend() override;
void restore() override;
void restore();
// Part of the protocol.
void enable(ErrorString*) override;
@ -122,7 +119,7 @@ public:
private:
V8InspectorSessionImpl* m_session;
protocol::DictionaryValue* m_state;
protocol::Frontend::Runtime* m_frontend;
protocol::Runtime::Frontend m_frontend;
V8DebuggerImpl* m_debugger;
bool m_enabled;
protocol::HashMap<String16, std::unique_ptr<v8::Global<v8::Script>>> m_compiledScripts;

33
deps/v8_inspector/platform/v8_inspector/V8StackTraceImpl.cpp

@ -4,11 +4,11 @@
#include "platform/v8_inspector/V8StackTraceImpl.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/String16.h"
#include "platform/v8_inspector/V8DebuggerAgentImpl.h"
#include "platform/v8_inspector/V8DebuggerImpl.h"
#include "platform/v8_inspector/V8StringUtil.h"
#include "wtf/PtrUtil.h"
#include <v8-debug.h>
#include <v8-profiler.h>
@ -72,7 +72,7 @@ V8StackTraceImpl::Frame::~Frame()
{
}
// buildInspectorObject() and ScriptCallStack's toTracedValue() should set the same fields.
// buildInspectorObject() and SourceLocation's toTracedValue() should set the same fields.
// If either of them is modified, the other should be also modified.
std::unique_ptr<protocol::Runtime::CallFrame> V8StackTraceImpl::Frame::buildInspectorObject() const
{
@ -85,6 +85,11 @@ std::unique_ptr<protocol::Runtime::CallFrame> V8StackTraceImpl::Frame::buildInsp
.build();
}
V8StackTraceImpl::Frame V8StackTraceImpl::Frame::isolatedCopy() const
{
return Frame(m_functionName.isolatedCopy(), m_scriptId.isolatedCopy(), m_scriptName.isolatedCopy(), m_lineNumber, m_columnNumber);
}
std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(V8DebuggerAgentImpl* agent, v8::Local<v8::StackTrace> stackTrace, size_t maxStackSize, const String16& description)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
@ -107,7 +112,7 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(V8DebuggerAgentImpl*
if (stackTrace.IsEmpty() && !asyncCallChain)
return nullptr;
std::unique_ptr<V8StackTraceImpl> result(new V8StackTraceImpl(description, frames, asyncCallChain ? asyncCallChain->clone() : nullptr));
std::unique_ptr<V8StackTraceImpl> result(new V8StackTraceImpl(description, frames, asyncCallChain ? asyncCallChain->cloneImpl() : nullptr));
// Crop to not exceed maxAsyncCallChainDepth.
V8StackTraceImpl* deepest = result.get();
@ -135,10 +140,28 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture(V8DebuggerAgentImpl*
return V8StackTraceImpl::create(agent, stackTrace, maxStackSize, description);
}
std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::clone()
std::unique_ptr<V8StackTrace> V8StackTraceImpl::clone()
{
return cloneImpl();
}
std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::cloneImpl()
{
protocol::Vector<Frame> framesCopy(m_frames);
return wrapUnique(new V8StackTraceImpl(m_description, framesCopy, m_parent ? m_parent->clone() : nullptr));
return wrapUnique(new V8StackTraceImpl(m_description, framesCopy, m_parent ? m_parent->cloneImpl() : nullptr));
}
std::unique_ptr<V8StackTrace> V8StackTraceImpl::isolatedCopy()
{
return isolatedCopyImpl();
}
std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::isolatedCopyImpl()
{
protocol::Vector<Frame> frames;
for (size_t i = 0; i < m_frames.size(); i++)
frames.append(m_frames.at(i).isolatedCopy());
return wrapUnique(new V8StackTraceImpl(m_description.isolatedCopy(), frames, m_parent ? m_parent->isolatedCopyImpl() : nullptr));
}
V8StackTraceImpl::V8StackTraceImpl(const String16& description, protocol::Vector<Frame>& frames, std::unique_ptr<V8StackTraceImpl> parent)

8
deps/v8_inspector/platform/v8_inspector/V8StackTraceImpl.h

@ -6,8 +6,8 @@
#define V8StackTraceImpl_h
#include "platform/inspector_protocol/Collections.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/v8_inspector/public/V8StackTrace.h"
#include "wtf/PtrUtil.h"
namespace blink {
@ -31,6 +31,7 @@ public:
const String16& sourceURL() const { return m_scriptName; }
int lineNumber() const { return m_lineNumber; }
int columnNumber() const { return m_columnNumber; }
Frame isolatedCopy() const;
private:
friend class V8StackTraceImpl;
@ -47,7 +48,10 @@ public:
static std::unique_ptr<V8StackTraceImpl> create(V8DebuggerAgentImpl*, v8::Local<v8::StackTrace>, size_t maxStackSize, const String16& description = String16());
static std::unique_ptr<V8StackTraceImpl> capture(V8DebuggerAgentImpl*, size_t maxStackSize, const String16& description = String16());
std::unique_ptr<V8StackTraceImpl> clone();
std::unique_ptr<V8StackTrace> clone() override;
std::unique_ptr<V8StackTraceImpl> cloneImpl();
std::unique_ptr<V8StackTrace> isolatedCopy() override;
std::unique_ptr<V8StackTraceImpl> isolatedCopyImpl();
std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObjectForTail(V8DebuggerAgentImpl*) const;
~V8StackTraceImpl() override;

22
deps/v8_inspector/platform/v8_inspector/injected_script_externs.js

@ -7,12 +7,6 @@ function InjectedScriptHostClass()
{
}
/**
* @param {*} objectId
* @param {!Object} hints
*/
InjectedScriptHostClass.prototype.inspect = function(objectId, hints) {}
/**
* @param {*} obj
* @return {string}
@ -21,9 +15,10 @@ InjectedScriptHostClass.prototype.internalConstructorName = function(obj) {}
/**
* @param {*} obj
* @param {function()|undefined} func
* @return {boolean}
*/
InjectedScriptHostClass.prototype.formatAccessorsAsProperties = function(obj) {}
InjectedScriptHostClass.prototype.formatAccessorsAsProperties = function(obj, func) {}
/**
* @param {*} obj
@ -49,12 +44,6 @@ InjectedScriptHostClass.prototype.collectionEntries = function(obj) {}
*/
InjectedScriptHostClass.prototype.getInternalProperties = function(obj) {}
/**
* @param {!EventTarget} target
* @return {!Object|undefined}
*/
InjectedScriptHostClass.prototype.getEventListeners = function(target) {}
/**
* @param {!Function} fn
* @param {*} receiver
@ -63,13 +52,6 @@ InjectedScriptHostClass.prototype.getEventListeners = function(target) {}
*/
InjectedScriptHostClass.prototype.suppressWarningsAndCallFunction = function(fn, receiver, argv) {}
/**
* @param {!Object} obj
* @param {string} key
* @param {*} value
*/
InjectedScriptHostClass.prototype.setNonEnumProperty = function(obj, key, value) {}
/**
* @param {*} value
* @param {string} groupName

1866
deps/v8_inspector/platform/v8_inspector/js_protocol-1.1.json

File diff suppressed because it is too large

976
deps/v8_inspector/platform/v8_inspector/js_protocol.json

@ -0,0 +1,976 @@
{
"version": { "major": "1", "minor": "1" },
"domains": [{
"domain": "Runtime",
"description": "Runtime domain exposes JavaScript runtime by means of remote evaluation and mirror objects. Evaluation results are returned as mirror object that expose object type, string representation and unique identifier that can be used for further object reference. Original objects are maintained in memory unless they are either explicitly released or are released along with the other objects in their object group.",
"types": [
{
"id": "ScriptId",
"type": "string",
"description": "Unique script identifier."
},
{
"id": "RemoteObjectId",
"type": "string",
"description": "Unique object identifier."
},
{
"id": "RemoteObject",
"type": "object",
"description": "Mirror object referencing original JavaScript object.",
"properties": [
{ "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol"], "description": "Object type." },
{ "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "map", "set", "iterator", "generator", "error"], "description": "Object subtype hint. Specified for <code>object</code> type values only." },
{ "name": "className", "type": "string", "optional": true, "description": "Object class (constructor) name. Specified for <code>object</code> type values only." },
{ "name": "value", "type": "any", "optional": true, "description": "Remote object value in case of primitive values or JSON values (if it was requested), or description string if the value can not be JSON-stringified (like NaN, Infinity, -Infinity, -0)." },
{ "name": "description", "type": "string", "optional": true, "description": "String representation of the object." },
{ "name": "objectId", "$ref": "RemoteObjectId", "optional": true, "description": "Unique object identifier (for non-primitive values)." },
{ "name": "preview", "$ref": "ObjectPreview", "optional": true, "description": "Preview containing abbreviated property values. Specified for <code>object</code> type values only.", "hidden": true },
{ "name": "customPreview", "$ref": "CustomPreview", "optional": true, "hidden": true}
]
},
{
"id": "CustomPreview",
"type": "object",
"hidden": true,
"properties": [
{ "name": "header", "type": "string"},
{ "name": "hasBody", "type": "boolean"},
{ "name": "formatterObjectId", "$ref": "RemoteObjectId"},
{ "name": "bindRemoteObjectFunctionId", "$ref": "RemoteObjectId" },
{ "name": "configObjectId", "$ref": "RemoteObjectId", "optional": true }
]
},
{
"id": "ObjectPreview",
"type": "object",
"hidden": true,
"description": "Object containing abbreviated remote object value.",
"properties": [
{ "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol"], "description": "Object type." },
{ "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "map", "set", "iterator", "generator", "error"], "description": "Object subtype hint. Specified for <code>object</code> type values only." },
{ "name": "description", "type": "string", "optional": true, "description": "String representation of the object." },
{ "name": "overflow", "type": "boolean", "description": "True iff some of the properties or entries of the original object did not fit." },
{ "name": "properties", "type": "array", "items": { "$ref": "PropertyPreview" }, "description": "List of the properties." },
{ "name": "entries", "type": "array", "items": { "$ref": "EntryPreview" }, "optional": true, "description": "List of the entries. Specified for <code>map</code> and <code>set</code> subtype values only." }
]
},
{
"id": "PropertyPreview",
"type": "object",
"hidden": true,
"properties": [
{ "name": "name", "type": "string", "description": "Property name." },
{ "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol", "accessor"], "description": "Object type. Accessor means that the property itself is an accessor property." },
{ "name": "value", "type": "string", "optional": true, "description": "User-friendly property value string." },
{ "name": "valuePreview", "$ref": "ObjectPreview", "optional": true, "description": "Nested value preview." },
{ "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "map", "set", "iterator", "generator", "error"], "description": "Object subtype hint. Specified for <code>object</code> type values only." }
]
},
{
"id": "EntryPreview",
"type": "object",
"hidden": true,
"properties": [
{ "name": "key", "$ref": "ObjectPreview", "optional": true, "description": "Preview of the key. Specified for map-like collection entries." },
{ "name": "value", "$ref": "ObjectPreview", "description": "Preview of the value." }
]
},
{
"id": "PropertyDescriptor",
"type": "object",
"description": "Object property descriptor.",
"properties": [
{ "name": "name", "type": "string", "description": "Property name or symbol description." },
{ "name": "value", "$ref": "RemoteObject", "optional": true, "description": "The value associated with the property." },
{ "name": "writable", "type": "boolean", "optional": true, "description": "True if the value associated with the property may be changed (data descriptors only)." },
{ "name": "get", "$ref": "RemoteObject", "optional": true, "description": "A function which serves as a getter for the property, or <code>undefined</code> if there is no getter (accessor descriptors only)." },
{ "name": "set", "$ref": "RemoteObject", "optional": true, "description": "A function which serves as a setter for the property, or <code>undefined</code> if there is no setter (accessor descriptors only)." },
{ "name": "configurable", "type": "boolean", "description": "True if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object." },
{ "name": "enumerable", "type": "boolean", "description": "True if this property shows up during enumeration of the properties on the corresponding object." },
{ "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if the result was thrown during the evaluation." },
{ "name": "isOwn", "optional": true, "type": "boolean", "description": "True if the property is owned for the object.", "hidden": true },
{ "name": "symbol", "$ref": "RemoteObject", "optional": true, "description": "Property symbol object, if the property is of the <code>symbol</code> type.", "hidden": true }
]
},
{
"id": "InternalPropertyDescriptor",
"type": "object",
"description": "Object internal property descriptor. This property isn't normally visible in JavaScript code.",
"properties": [
{ "name": "name", "type": "string", "description": "Conventional property name." },
{ "name": "value", "$ref": "RemoteObject", "optional": true, "description": "The value associated with the property." }
],
"hidden": true
},
{
"id": "CallArgument",
"type": "object",
"description": "Represents function call argument. Either remote object id <code>objectId</code> or primitive <code>value</code> or neither of (for undefined) them should be specified.",
"properties": [
{ "name": "value", "type": "any", "optional": true, "description": "Primitive value, or description string if the value can not be JSON-stringified (like NaN, Infinity, -Infinity, -0)." },
{ "name": "objectId", "$ref": "RemoteObjectId", "optional": true, "description": "Remote object handle." },
{ "name": "type", "optional": true, "hidden": true, "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol"], "description": "Object type." }
]
},
{
"id": "ExecutionContextId",
"type": "integer",
"description": "Id of an execution context."
},
{
"id": "ExecutionContextDescription",
"type": "object",
"description": "Description of an isolated world.",
"properties": [
{ "name": "id", "$ref": "ExecutionContextId", "description": "Unique id of the execution context. It can be used to specify in which execution context script evaluation should be performed." },
{ "name": "isDefault", "type": "boolean", "description": "Whether context is the default page context (as opposite to e.g. context of content script).", "hidden": true },
{ "name": "origin", "type": "string", "description": "Execution context origin.", "hidden": true},
{ "name": "name", "type": "string", "description": "Human readable name describing given context.", "hidden": true},
{ "name": "frameId", "type": "string", "description": "Id of the owning frame. May be an empty string if the context is not associated with a frame." }
]
},
{
"id": "ExceptionDetails",
"type": "object",
"description": "Detailed information on exception (or error) that was thrown during script compilation or execution.",
"properties": [
{ "name": "text", "type": "string", "description": "Exception text." },
{ "name": "url", "type": "string", "optional": true, "description": "URL of the message origin." },
{ "name": "scriptId", "type": "string", "optional": true, "description": "Script ID of the message origin." },
{ "name": "line", "type": "integer", "optional": true, "description": "Line number in the resource that generated this message." },
{ "name": "column", "type": "integer", "optional": true, "description": "Column number in the resource that generated this message." },
{ "name": "stack", "$ref": "StackTrace", "optional": true, "description": "JavaScript stack trace for assertions and error messages." }
]
},
{
"id": "CallFrame",
"type": "object",
"description": "Stack entry for runtime errors and assertions.",
"properties": [
{ "name": "functionName", "type": "string", "description": "JavaScript function name." },
{ "name": "scriptId", "$ref": "ScriptId", "description": "JavaScript script id." },
{ "name": "url", "type": "string", "description": "JavaScript script name or url." },
{ "name": "lineNumber", "type": "integer", "description": "JavaScript script line number." },
{ "name": "columnNumber", "type": "integer", "description": "JavaScript script column number." }
]
},
{
"id": "StackTrace",
"type": "object",
"description": "Call frames for assertions or error messages.",
"properties": [
{ "name": "description", "type": "string", "optional": true, "description": "String label of this stack trace. For async traces this may be a name of the function that initiated the async call." },
{ "name": "callFrames", "type": "array", "items": { "$ref": "CallFrame" }, "description": "JavaScript function name." },
{ "name": "parent", "$ref": "StackTrace", "optional": true, "hidden": true, "hidden": true, "description": "Asynchronous JavaScript stack trace that preceded this stack, if available." }
]
}
],
"commands": [
{
"name": "evaluate",
"parameters": [
{ "name": "expression", "type": "string", "description": "Expression to evaluate." },
{ "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." },
{ "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Determines whether Command Line API should be available during the evaluation.", "hidden": true },
{ "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether evaluation should stop on exceptions and mute console. Overrides setPauseOnException state.", "hidden": true },
{ "name": "contextId", "$ref": "ExecutionContextId", "optional": true, "description": "Specifies in which isolated context to perform evaluation. Each content script lives in an isolated context and this parameter may be used to specify one of those contexts. If the parameter is omitted or 0 the evaluation will be performed in the context of the inspected page." },
{ "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object that should be sent by value." },
{ "name": "generatePreview", "type": "boolean", "optional": true, "hidden": true, "description": "Whether preview should be generated for the result." },
{ "name": "userGesture", "type": "boolean", "optional": true, "hidden": true, "description": "Whether execution should be treated as initiated by user in the UI." }
],
"returns": [
{ "name": "result", "$ref": "RemoteObject", "description": "Evaluation result." },
{ "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if the result was thrown during the evaluation." },
{ "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "hidden": true, "description": "Exception details."}
],
"description": "Evaluates expression on global object."
},
{
"name": "callFunctionOn",
"parameters": [
{ "name": "objectId", "$ref": "RemoteObjectId", "description": "Identifier of the object to call function on." },
{ "name": "functionDeclaration", "type": "string", "description": "Declaration of the function to call." },
{ "name": "arguments", "type": "array", "items": { "$ref": "CallArgument", "description": "Call argument." }, "optional": true, "description": "Call arguments. All call arguments must belong to the same JavaScript world as the target object." },
{ "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether function call should stop on exceptions and mute console. Overrides setPauseOnException state.", "hidden": true },
{ "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object which should be sent by value." },
{ "name": "generatePreview", "type": "boolean", "optional": true, "hidden": true, "description": "Whether preview should be generated for the result." },
{ "name": "userGesture", "type": "boolean", "optional": true, "hidden": true, "description": "Whether execution should be treated as initiated by user in the UI." }
],
"returns": [
{ "name": "result", "$ref": "RemoteObject", "description": "Call result." },
{ "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if the result was thrown during the evaluation." }
],
"description": "Calls function with given declaration on the given object. Object group of the result is inherited from the target object."
},
{
"name": "getProperties",
"parameters": [
{ "name": "objectId", "$ref": "RemoteObjectId", "description": "Identifier of the object to return properties for." },
{ "name": "ownProperties", "optional": true, "type": "boolean", "description": "If true, returns properties belonging only to the element itself, not to its prototype chain." },
{ "name": "accessorPropertiesOnly", "optional": true, "type": "boolean", "description": "If true, returns accessor properties (with getter/setter) only; internal properties are not returned either.", "hidden": true },
{ "name": "generatePreview", "type": "boolean", "optional": true, "hidden": true, "description": "Whether preview should be generated for the results." }
],
"returns": [
{ "name": "result", "type": "array", "items": { "$ref": "PropertyDescriptor" }, "description": "Object properties." },
{ "name": "internalProperties", "optional": true, "type": "array", "items": { "$ref": "InternalPropertyDescriptor" }, "description": "Internal object properties (only of the element itself).", "hidden": true },
{ "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "hidden": true, "description": "Exception details."}
],
"description": "Returns properties of a given object. Object group of the result is inherited from the target object."
},
{
"name": "releaseObject",
"parameters": [
{ "name": "objectId", "$ref": "RemoteObjectId", "description": "Identifier of the object to release." }
],
"description": "Releases remote object with given id."
},
{
"name": "releaseObjectGroup",
"parameters": [
{ "name": "objectGroup", "type": "string", "description": "Symbolic object group name." }
],
"description": "Releases all remote objects that belong to a given group."
},
{
"name": "run",
"hidden": true,
"description": "Tells inspected instance(worker or page) that it can run in case it was started paused."
},
{
"name": "enable",
"description": "Enables reporting of execution contexts creation by means of <code>executionContextCreated</code> event. When the reporting gets enabled the event will be sent immediately for each existing execution context."
},
{
"name": "disable",
"hidden": true,
"description": "Disables reporting of execution contexts creation."
},
{
"name": "setCustomObjectFormatterEnabled",
"parameters": [
{
"name": "enabled",
"type": "boolean"
}
],
"hidden": true
},
{
"name": "compileScript",
"hidden": true,
"parameters": [
{ "name": "expression", "type": "string", "description": "Expression to compile." },
{ "name": "sourceURL", "type": "string", "description": "Source url to be set for the script." },
{ "name": "persistScript", "type": "boolean", "description": "Specifies whether the compiled script should be persisted." },
{ "name": "executionContextId", "$ref": "ExecutionContextId", "description": "Specifies in which isolated context to perform script run. Each content script lives in an isolated context and this parameter is used to specify one of those contexts." }
],
"returns": [
{ "name": "scriptId", "$ref": "ScriptId", "optional": true, "description": "Id of the script." },
{ "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "description": "Exception details."}
],
"description": "Compiles expression."
},
{
"name": "runScript",
"hidden": true,
"parameters": [
{ "name": "scriptId", "$ref": "ScriptId", "description": "Id of the script to run." },
{ "name": "executionContextId", "$ref": "ExecutionContextId", "description": "Specifies in which isolated context to perform script run. Each content script lives in an isolated context and this parameter is used to specify one of those contexts." },
{ "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." },
{ "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether script run should stop on exceptions and mute console. Overrides setPauseOnException state." },
{ "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Determines whether Command Line API should be available during the evaluation." }
],
"returns": [
{ "name": "result", "$ref": "RemoteObject", "description": "Run result." },
{ "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "description": "Exception details."}
],
"description": "Runs script with given id in a given context."
}
],
"events": [
{
"name": "executionContextCreated",
"parameters": [
{ "name": "context", "$ref": "ExecutionContextDescription", "description": "A newly created execution contex." }
],
"description": "Issued when new execution context is created."
},
{
"name": "executionContextDestroyed",
"parameters": [
{ "name": "executionContextId", "$ref": "ExecutionContextId", "description": "Id of the destroyed context" }
],
"description": "Issued when execution context is destroyed."
},
{
"name": "executionContextsCleared",
"description": "Issued when all executionContexts were cleared in browser"
},
{
"name": "inspectRequested",
"parameters": [
{ "name": "object", "$ref": "RemoteObject" },
{ "name": "hints", "type": "object" }
],
"hidden": true
}
]
},
{
"domain": "Debugger",
"description": "Debugger domain exposes JavaScript debugging capabilities. It allows setting and removing breakpoints, stepping through execution, exploring stack traces, etc.",
"dependencies": ["Runtime"],
"types": [
{
"id": "BreakpointId",
"type": "string",
"description": "Breakpoint identifier."
},
{
"id": "CallFrameId",
"type": "string",
"description": "Call frame identifier."
},
{
"id": "Location",
"type": "object",
"properties": [
{ "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Script identifier as reported in the <code>Debugger.scriptParsed</code>." },
{ "name": "lineNumber", "type": "integer", "description": "Line number in the script (0-based)." },
{ "name": "columnNumber", "type": "integer", "optional": true, "description": "Column number in the script (0-based)." }
],
"description": "Location in the source code."
},
{
"id": "ScriptPosition",
"hidden": true,
"type": "object",
"properties": [
{ "name": "line", "type": "integer" },
{ "name": "column", "type": "integer" }
],
"description": "Location in the source code."
},
{
"id": "FunctionDetails",
"hidden": true,
"type": "object",
"properties": [
{ "name": "location", "$ref": "Location", "optional": true, "description": "Location of the function, none for native functions." },
{ "name": "functionName", "type": "string", "description": "Name of the function." },
{ "name": "isGenerator", "type": "boolean", "description": "Whether this is a generator function." },
{ "name": "scopeChain", "type": "array", "optional": true, "items": { "$ref": "Scope" }, "description": "Scope chain for this closure." }
],
"description": "Information about the function."
},
{
"id": "GeneratorObjectDetails",
"hidden": true,
"type": "object",
"properties": [
{ "name": "function", "$ref": "Runtime.RemoteObject", "description": "Generator function." },
{ "name": "functionName", "type": "string", "description": "Name of the generator function." },
{ "name": "status", "type": "string", "enum": ["running", "suspended", "closed"], "description": "Current generator object status." },
{ "name": "location", "$ref": "Location", "optional": true, "description": "If suspended, location where generator function was suspended (e.g. location of the last 'yield'). Otherwise, location of the generator function." }
],
"description": "Information about the generator object."
},
{
"id": "CollectionEntry",
"hidden": true,
"type": "object",
"properties": [
{ "name": "key", "$ref": "Runtime.RemoteObject", "optional": true, "description": "Entry key of a map-like collection, otherwise not provided." },
{ "name": "value", "$ref": "Runtime.RemoteObject", "description": "Entry value." }
],
"description": "Collection entry."
},
{
"id": "CallFrame",
"type": "object",
"properties": [
{ "name": "callFrameId", "$ref": "CallFrameId", "description": "Call frame identifier. This identifier is only valid while the virtual machine is paused." },
{ "name": "functionName", "type": "string", "description": "Name of the JavaScript function called on this call frame." },
{ "name": "functionLocation", "$ref": "Location", "optional": true, "hidden": true, "description": "Location in the source code." },
{ "name": "location", "$ref": "Location", "description": "Location in the source code." },
{ "name": "scopeChain", "type": "array", "items": { "$ref": "Scope" }, "description": "Scope chain for this call frame." },
{ "name": "this", "$ref": "Runtime.RemoteObject", "description": "<code>this</code> object for this call frame." },
{ "name": "returnValue", "$ref": "Runtime.RemoteObject", "optional": true, "hidden": true, "description": "The value being returned, if the function is at return point." }
],
"description": "JavaScript call frame. Array of call frames form the call stack."
},
{
"id": "Scope",
"type": "object",
"properties": [
{ "name": "type", "type": "string", "enum": ["global", "local", "with", "closure", "catch", "block", "script"], "description": "Scope type." },
{ "name": "object", "$ref": "Runtime.RemoteObject", "description": "Object representing the scope. For <code>global</code> and <code>with</code> scopes it represents the actual object; for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties." },
{ "name": "name", "type": "string", "optional": true, "hidden": true },
{ "name": "startLocation", "$ref": "Location", "optional": true, "hidden": true, "description": "Location in the source code where scope starts" },
{ "name": "endLocation", "$ref": "Location", "optional": true, "hidden": true, "description": "Location in the source code where scope ends" }
],
"description": "Scope description."
},
{
"id": "SetScriptSourceError",
"type": "object",
"properties": [
{ "name": "message", "type": "string", "description": "Compiler error message" },
{ "name": "lineNumber", "type": "integer", "description": "Compile error line number (1-based)" },
{ "name": "columnNumber", "type": "integer", "description": "Compile error column number (1-based)" }
],
"description": "Error data for setScriptSource command. Contains uncompilable script source error.",
"hidden": true
},
{
"id": "SearchMatch",
"type": "object",
"description": "Search match for resource.",
"properties": [
{ "name": "lineNumber", "type": "number", "description": "Line number in resource content." },
{ "name": "lineContent", "type": "string", "description": "Line with match content." }
],
"hidden": true
}
],
"commands": [
{
"name": "enable",
"description": "Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received."
},
{
"name": "disable",
"description": "Disables debugger for given page."
},
{
"name": "setBreakpointsActive",
"parameters": [
{ "name": "active", "type": "boolean", "description": "New value for breakpoints active state." }
],
"description": "Activates / deactivates all breakpoints on the page."
},
{
"name": "setSkipAllPauses",
"hidden": true,
"parameters": [
{ "name": "skipped", "type": "boolean", "description": "New value for skip pauses state." }
],
"description": "Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc)."
},
{
"name": "setBreakpointByUrl",
"parameters": [
{ "name": "lineNumber", "type": "integer", "description": "Line number to set breakpoint at." },
{ "name": "url", "type": "string", "optional": true, "description": "URL of the resources to set breakpoint on." },
{ "name": "urlRegex", "type": "string", "optional": true, "description": "Regex pattern for the URLs of the resources to set breakpoints on. Either <code>url</code> or <code>urlRegex</code> must be specified." },
{ "name": "columnNumber", "type": "integer", "optional": true, "description": "Offset in the line to set breakpoint at." },
{ "name": "condition", "type": "string", "optional": true, "description": "Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true." }
],
"returns": [
{ "name": "breakpointId", "$ref": "BreakpointId", "description": "Id of the created breakpoint for further reference." },
{ "name": "locations", "type": "array", "items": { "$ref": "Location" }, "description": "List of the locations this breakpoint resolved into upon addition." }
],
"description": "Sets JavaScript breakpoint at given location specified either by URL or URL regex. Once this command is issued, all existing parsed scripts will have breakpoints resolved and returned in <code>locations</code> property. Further matching script parsing will result in subsequent <code>breakpointResolved</code> events issued. This logical breakpoint will survive page reloads."
},
{
"name": "setBreakpoint",
"parameters": [
{ "name": "location", "$ref": "Location", "description": "Location to set breakpoint in." },
{ "name": "condition", "type": "string", "optional": true, "description": "Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true." }
],
"returns": [
{ "name": "breakpointId", "$ref": "BreakpointId", "description": "Id of the created breakpoint for further reference." },
{ "name": "actualLocation", "$ref": "Location", "description": "Location this breakpoint resolved into." }
],
"description": "Sets JavaScript breakpoint at a given location."
},
{
"name": "removeBreakpoint",
"parameters": [
{ "name": "breakpointId", "$ref": "BreakpointId" }
],
"description": "Removes JavaScript breakpoint."
},
{
"name": "continueToLocation",
"parameters": [
{ "name": "location", "$ref": "Location", "description": "Location to continue to." },
{ "name": "interstatementLocation", "type": "boolean", "optional": true, "hidden": true, "description": "Allows breakpoints at the intemediate positions inside statements." }
],
"description": "Continues execution until specific location is reached."
},
{
"name": "stepOver",
"description": "Steps over the statement."
},
{
"name": "stepInto",
"description": "Steps into the function call."
},
{
"name": "stepOut",
"description": "Steps out of the function call."
},
{
"name": "pause",
"description": "Stops on the next JavaScript statement."
},
{
"name": "resume",
"description": "Resumes JavaScript execution."
},
{
"name": "searchInContent",
"parameters": [
{ "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Id of the script to search in." },
{ "name": "query", "type": "string", "description": "String to search for." },
{ "name": "caseSensitive", "type": "boolean", "optional": true, "description": "If true, search is case sensitive." },
{ "name": "isRegex", "type": "boolean", "optional": true, "description": "If true, treats string parameter as regex." }
],
"returns": [
{ "name": "result", "type": "array", "items": { "$ref": "SearchMatch" }, "description": "List of search matches." }
],
"description": "Searches for given string in script content."
},
{
"name": "canSetScriptSource",
"returns": [
{ "name": "result", "type": "boolean", "description": "True if <code>setScriptSource</code> is supported." }
],
"description": "Always returns true."
},
{
"name": "setScriptSource",
"parameters": [
{ "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Id of the script to edit." },
{ "name": "scriptSource", "type": "string", "description": "New content of the script." },
{ "name": "preview", "type": "boolean", "optional": true, "description": " If true the change will not actually be applied. Preview mode may be used to get result description without actually modifying the code.", "hidden": true }
],
"returns": [
{ "name": "callFrames", "type": "array", "optional": true, "items": { "$ref": "CallFrame" }, "description": "New stack trace in case editing has happened while VM was stopped." },
{ "name": "stackChanged", "type": "boolean", "optional": true, "description": "Whether current call stack was modified after applying the changes.", "hidden": true },
{ "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any.", "hidden": true },
{ "name": "compileError", "optional": true, "$ref": "SetScriptSourceError", "description": "Error data if any." }
],
"description": "Edits JavaScript source live."
},
{
"name": "restartFrame",
"parameters": [
{ "name": "callFrameId", "$ref": "CallFrameId", "description": "Call frame identifier to evaluate on." }
],
"returns": [
{ "name": "callFrames", "type": "array", "items": { "$ref": "CallFrame" }, "description": "New stack trace." },
{ "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any." }
],
"hidden": true,
"description": "Restarts particular call frame from the beginning."
},
{
"name": "getScriptSource",
"parameters": [
{ "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Id of the script to get source for." }
],
"returns": [
{ "name": "scriptSource", "type": "string", "description": "Script source." }
],
"description": "Returns source for the script with given id."
},
{
"name": "getFunctionDetails",
"hidden": true,
"parameters": [
{ "name": "functionId", "$ref": "Runtime.RemoteObjectId", "description": "Id of the function to get details for." }
],
"returns": [
{ "name": "details", "$ref": "FunctionDetails", "description": "Information about the function." }
],
"description": "Returns detailed information on given function."
},
{
"name": "getGeneratorObjectDetails",
"hidden": true,
"parameters": [
{ "name": "objectId", "$ref": "Runtime.RemoteObjectId", "description": "Id of the generator object to get details for." }
],
"returns": [
{ "name": "details", "$ref": "GeneratorObjectDetails", "description": "Information about the generator object." }
],
"description": "Returns detailed information on given generator object."
},
{
"name": "getCollectionEntries",
"hidden": true,
"parameters": [
{ "name": "objectId", "$ref": "Runtime.RemoteObjectId", "description": "Id of the collection to get entries for." }
],
"returns": [
{ "name": "entries", "type": "array", "items": { "$ref": "CollectionEntry" }, "description": "Array of collection entries." }
],
"description": "Returns entries of given collection."
},
{
"name": "setPauseOnExceptions",
"parameters": [
{ "name": "state", "type": "string", "enum": ["none", "uncaught", "all"], "description": "Pause on exceptions mode." }
],
"description": "Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or no exceptions. Initial pause on exceptions state is <code>none</code>."
},
{
"name": "evaluateOnCallFrame",
"parameters": [
{ "name": "callFrameId", "$ref": "CallFrameId", "description": "Call frame identifier to evaluate on." },
{ "name": "expression", "type": "string", "description": "Expression to evaluate." },
{ "name": "objectGroup", "type": "string", "optional": true, "description": "String object group name to put result into (allows rapid releasing resulting object handles using <code>releaseObjectGroup</code>)." },
{ "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Specifies whether command line API should be available to the evaluated expression, defaults to false.", "hidden": true },
{ "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether evaluation should stop on exceptions and mute console. Overrides setPauseOnException state.", "hidden": true },
{ "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object that should be sent by value." },
{ "name": "generatePreview", "type": "boolean", "optional": true, "hidden": true, "description": "Whether preview should be generated for the result." }
],
"returns": [
{ "name": "result", "$ref": "Runtime.RemoteObject", "description": "Object wrapper for the evaluation result." },
{ "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if the result was thrown during the evaluation." },
{ "name": "exceptionDetails", "$ref": "Runtime.ExceptionDetails", "optional": true, "hidden": true, "description": "Exception details."}
],
"description": "Evaluates expression on a given call frame."
},
{
"name": "setVariableValue",
"parameters": [
{ "name": "scopeNumber", "type": "integer", "description": "0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' scope types are allowed. Other scopes could be manipulated manually." },
{ "name": "variableName", "type": "string", "description": "Variable name." },
{ "name": "newValue", "$ref": "Runtime.CallArgument", "description": "New variable value." },
{ "name": "callFrameId", "$ref": "CallFrameId", "description": "Id of callframe that holds variable." }
],
"hidden": true,
"description": "Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually."
},
{
"name": "getBacktrace",
"returns": [
{ "name": "callFrames", "type": "array", "items": { "$ref": "CallFrame" }, "description": "Call stack the virtual machine stopped on." },
{ "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any." }
],
"hidden": true,
"description": "Returns call stack including variables changed since VM was paused. VM must be paused."
},
{
"name": "setAsyncCallStackDepth",
"parameters": [
{ "name": "maxDepth", "type": "integer", "description": "Maximum depth of async call stacks. Setting to <code>0</code> will effectively disable collecting async call stacks (default)." }
],
"hidden": true,
"description": "Enables or disables async call stacks tracking."
},
{
"name": "setBlackboxPatterns",
"parameters": [
{ "name": "patterns", "type": "array", "items": { "type": "string" }, "description": "Array of regexps that will be used to check script url for blackbox state." }
],
"hidden": true,
"description": "Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in scripts with url matching one of the patterns. VM will try to leave blackboxed script by performing 'step in' several times, finally resorting to 'step out' if unsuccessful."
},
{
"name": "setBlackboxedRanges",
"parameters": [
{ "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Id of the script." },
{ "name": "positions", "type": "array", "items": { "$ref": "ScriptPosition" } }
],
"hidden": true,
"description": "Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. Positions array contains positions where blackbox state is changed. First interval isn't blackboxed. Array should be sorted."
}
],
"events": [
{
"name": "scriptParsed",
"parameters": [
{ "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Identifier of the script parsed." },
{ "name": "url", "type": "string", "description": "URL or name of the script parsed (if any)." },
{ "name": "startLine", "type": "integer", "description": "Line offset of the script within the resource with given URL (for script tags)." },
{ "name": "startColumn", "type": "integer", "description": "Column offset of the script within the resource with given URL." },
{ "name": "endLine", "type": "integer", "description": "Last line of the script." },
{ "name": "endColumn", "type": "integer", "description": "Length of the last line of the script." },
{ "name": "executionContextId", "$ref": "Runtime.ExecutionContextId", "description": "Specifies script creation context.", "hidden": true },
{ "name": "hash", "type": "string", "hidden": true, "description": "Content hash of the script."},
{ "name": "isContentScript", "type": "boolean", "optional": true, "description": "Determines whether this script is a user extension script." },
{ "name": "isInternalScript", "type": "boolean", "optional": true, "description": "Determines whether this script is an internal script.", "hidden": true },
{ "name": "isLiveEdit", "type": "boolean", "optional": true, "description": "True, if this script is generated as a result of the live edit operation.", "hidden": true },
{ "name": "sourceMapURL", "type": "string", "optional": true, "description": "URL of source map associated with script (if any)." },
{ "name": "hasSourceURL", "type": "boolean", "optional": true, "description": "True, if this script has sourceURL.", "hidden": true },
{ "name": "deprecatedCommentWasUsed", "type": "boolean", "optional": true, "hidden": true, "description": "True, if '//@ sourceURL' or '//@ sourceMappingURL' was used."}
],
"description": "Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger."
},
{
"name": "scriptFailedToParse",
"parameters": [
{ "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Identifier of the script parsed." },
{ "name": "url", "type": "string", "description": "URL or name of the script parsed (if any)." },
{ "name": "startLine", "type": "integer", "description": "Line offset of the script within the resource with given URL (for script tags)." },
{ "name": "startColumn", "type": "integer", "description": "Column offset of the script within the resource with given URL." },
{ "name": "endLine", "type": "integer", "description": "Last line of the script." },
{ "name": "endColumn", "type": "integer", "description": "Length of the last line of the script." },
{ "name": "executionContextId", "$ref": "Runtime.ExecutionContextId", "description": "Specifies script creation context.", "hidden": true },
{ "name": "hash", "type": "string", "hidden": true, "description": "Content hash of the script."},
{ "name": "isContentScript", "type": "boolean", "optional": true, "description": "Determines whether this script is a user extension script." },
{ "name": "isInternalScript", "type": "boolean", "optional": true, "description": "Determines whether this script is an internal script.", "hidden": true },
{ "name": "sourceMapURL", "type": "string", "optional": true, "description": "URL of source map associated with script (if any)." },
{ "name": "hasSourceURL", "type": "boolean", "optional": true, "description": "True, if this script has sourceURL.", "hidden": true },
{ "name": "deprecatedCommentWasUsed", "type": "boolean", "optional": true, "hidden": true, "description": "True, if '//@ sourceURL' or '//@ sourceMappingURL' was used."}
],
"description": "Fired when virtual machine fails to parse the script."
},
{
"name": "breakpointResolved",
"parameters": [
{ "name": "breakpointId", "$ref": "BreakpointId", "description": "Breakpoint unique identifier." },
{ "name": "location", "$ref": "Location", "description": "Actual breakpoint location." }
],
"description": "Fired when breakpoint is resolved to an actual script and location."
},
{
"name": "paused",
"parameters": [
{ "name": "callFrames", "type": "array", "items": { "$ref": "CallFrame" }, "description": "Call stack the virtual machine stopped on." },
{ "name": "reason", "type": "string", "enum": [ "XHR", "DOM", "EventListener", "exception", "assert", "CSPViolation", "debugCommand", "promiseRejection", "other" ], "description": "Pause reason." },
{ "name": "data", "type": "object", "optional": true, "description": "Object containing break-specific auxiliary properties." },
{ "name": "hitBreakpoints", "type": "array", "optional": true, "items": { "type": "string" }, "description": "Hit breakpoints IDs", "hidden": true },
{ "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any.", "hidden": true }
],
"description": "Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria."
},
{
"name": "resumed",
"description": "Fired when the virtual machine resumed execution."
}
]
},
{
"domain": "Profiler",
"dependencies": ["Runtime", "Debugger"],
"hidden": true,
"types": [
{
"id": "CPUProfileNode",
"type": "object",
"description": "CPU Profile node. Holds callsite information, execution statistics and child nodes.",
"properties": [
{ "name": "functionName", "type": "string", "description": "Function name." },
{ "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Script identifier." },
{ "name": "url", "type": "string", "description": "URL." },
{ "name": "lineNumber", "type": "integer", "description": "1-based line number of the function start position." },
{ "name": "columnNumber", "type": "integer", "description": "1-based column number of the function start position." },
{ "name": "hitCount", "type": "integer", "description": "Number of samples where this node was on top of the call stack." },
{ "name": "callUID", "type": "number", "description": "Call UID." },
{ "name": "children", "type": "array", "items": { "$ref": "CPUProfileNode" }, "description": "Child nodes." },
{ "name": "deoptReason", "type": "string", "description": "The reason of being not optimized. The function may be deoptimized or marked as don't optimize."},
{ "name": "id", "type": "integer", "description": "Unique id of the node." },
{ "name": "positionTicks", "type": "array", "items": { "$ref": "PositionTickInfo" }, "description": "An array of source position ticks." }
]
},
{
"id": "CPUProfile",
"type": "object",
"description": "Profile.",
"properties": [
{ "name": "head", "$ref": "CPUProfileNode" },
{ "name": "startTime", "type": "number", "description": "Profiling start time in seconds." },
{ "name": "endTime", "type": "number", "description": "Profiling end time in seconds." },
{ "name": "samples", "optional": true, "type": "array", "items": { "type": "integer" }, "description": "Ids of samples top nodes." },
{ "name": "timestamps", "optional": true, "type": "array", "items": { "type": "number" }, "description": "Timestamps of the samples in microseconds." }
]
},
{
"id": "PositionTickInfo",
"type": "object",
"description": "Specifies a number of samples attributed to a certain source position.",
"properties": [
{ "name": "line", "type": "integer", "description": "Source line number (1-based)." },
{ "name": "ticks", "type": "integer", "description": "Number of samples attributed to the source line." }
]
}
],
"commands": [
{
"name": "enable"
},
{
"name": "disable"
},
{
"name": "setSamplingInterval",
"parameters": [
{ "name": "interval", "type": "integer", "description": "New sampling interval in microseconds." }
],
"description": "Changes CPU profiler sampling interval. Must be called before CPU profiles recording started."
},
{
"name": "start"
},
{
"name": "stop",
"returns": [
{ "name": "profile", "$ref": "CPUProfile", "description": "Recorded profile." }
]
}
],
"events": [
{
"name": "consoleProfileStarted",
"parameters": [
{ "name": "id", "type": "string" },
{ "name": "location", "$ref": "Debugger.Location", "description": "Location of console.profile()." },
{ "name": "title", "type": "string", "optional": true, "description": "Profile title passed as argument to console.profile()." }
],
"description": "Sent when new profile recodring is started using console.profile() call."
},
{
"name": "consoleProfileFinished",
"parameters": [
{ "name": "id", "type": "string" },
{ "name": "location", "$ref": "Debugger.Location", "description": "Location of console.profileEnd()." },
{ "name": "profile", "$ref": "CPUProfile" },
{ "name": "title", "type": "string", "optional": true, "description": "Profile title passed as argunet to console.profile()." }
]
}
]
},
{
"domain": "HeapProfiler",
"dependencies": ["Runtime"],
"hidden": true,
"types": [
{
"id": "HeapSnapshotObjectId",
"type": "string",
"description": "Heap snapshot object id."
},
{
"id": "SamplingHeapProfileNode",
"type": "object",
"description": "Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes.",
"properties": [
{ "name": "functionName", "type": "string", "description": "Function name." },
{ "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Script identifier." },
{ "name": "url", "type": "string", "description": "URL." },
{ "name": "lineNumber", "type": "integer", "description": "1-based line number of the function start position." },
{ "name": "columnNumber", "type": "integer", "description": "1-based column number of the function start position." },
{ "name": "selfSize", "type": "number", "description": "Allocations size in bytes for the node excluding children." },
{ "name": "children", "type": "array", "items": { "$ref": "SamplingHeapProfileNode" }, "description": "Child nodes." }
]
},
{
"id": "SamplingHeapProfile",
"type": "object",
"description": "Profile.",
"properties": [
{ "name": "head", "$ref": "SamplingHeapProfileNode" }
]
}
],
"commands": [
{
"name": "enable"
},
{
"name": "disable"
},
{
"name": "startTrackingHeapObjects",
"parameters": [
{ "name": "trackAllocations", "type": "boolean", "optional": true }
]
},
{
"name": "stopTrackingHeapObjects",
"parameters": [
{ "name": "reportProgress", "type": "boolean", "optional": true, "description": "If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken when the tracking is stopped." }
]
},
{
"name": "takeHeapSnapshot",
"parameters": [
{ "name": "reportProgress", "type": "boolean", "optional": true, "description": "If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken." }
]
},
{
"name": "collectGarbage"
},
{
"name": "getObjectByHeapObjectId",
"parameters": [
{ "name": "objectId", "$ref": "HeapSnapshotObjectId" },
{ "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." }
],
"returns": [
{ "name": "result", "$ref": "Runtime.RemoteObject", "description": "Evaluation result." }
]
},
{
"name": "addInspectedHeapObject",
"parameters": [
{ "name": "heapObjectId", "$ref": "HeapSnapshotObjectId", "description": "Heap snapshot object id to be accessible by means of $x command line API." }
],
"description": "Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions)."
},
{
"name": "getHeapObjectId",
"parameters": [
{ "name": "objectId", "$ref": "Runtime.RemoteObjectId", "description": "Identifier of the object to get heap object id for." }
],
"returns": [
{ "name": "heapSnapshotObjectId", "$ref": "HeapSnapshotObjectId", "description": "Id of the heap snapshot object corresponding to the passed remote object id." }
]
},
{
"name": "startSampling",
"parameters": [
{ "name": "samplingInterval", "type": "number", "optional": true, "description": "Average sample interval in bytes. Poisson distribution is used for the intervals. The default value is 32768 bytes." }
]
},
{
"name": "stopSampling",
"returns": [
{ "name": "profile", "$ref": "SamplingHeapProfile", "description": "Recorded sampling heap profile." }
]
}
],
"events": [
{
"name": "addHeapSnapshotChunk",
"parameters": [
{ "name": "chunk", "type": "string" }
]
},
{
"name": "resetProfiles"
},
{
"name": "reportHeapSnapshotProgress",
"parameters": [
{ "name": "done", "type": "integer" },
{ "name": "total", "type": "integer" },
{ "name": "finished", "type": "boolean", "optional": true }
]
},
{
"name": "lastSeenObjectId",
"description": "If heap objects tracking has been started then backend regulary sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event.",
"parameters": [
{ "name": "lastSeenObjectId", "type": "integer" },
{ "name": "timestamp", "type": "number" }
]
},
{
"name": "heapStatsUpdate",
"description": "If heap objects tracking has been started then backend may send update for one or more fragments",
"parameters": [
{ "name": "statsUpdate", "type": "array", "items": { "type": "integer" }, "description": "An array of triplets. Each triplet describes a fragment. The first integer is the fragment index, the second integer is a total count of objects for the fragment, the third integer is a total size of the objects for the fragment."}
]
}
]
}]
}

3
deps/v8_inspector/platform/v8_inspector/public/V8ContentSearchUtil.h

@ -5,9 +5,8 @@
#ifndef V8ContentSearchUtil_h
#define V8ContentSearchUtil_h
#include "platform/PlatformExport.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/String16.h"
#include "platform/inspector_protocol/TypeBuilder.h"
namespace blink {

24
deps/v8_inspector/platform/v8_inspector/public/V8Debugger.h

@ -5,9 +5,8 @@
#ifndef V8Debugger_h
#define V8Debugger_h
#include "platform/PlatformExport.h"
#include "platform/inspector_protocol/Frontend.h"
#include "wtf/PtrUtil.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/String16.h"
#include <v8.h>
@ -16,23 +15,16 @@ namespace blink {
class V8ContextInfo;
class V8DebuggerClient;
class V8InspectorSession;
class V8InspectorSessionClient;
class V8StackTrace;
namespace protocol {
class DictionaryValue;
class FrontendChannel;
}
class PLATFORM_EXPORT V8Debugger {
public:
template <typename T>
class Agent {
public:
virtual void setInspectorState(protocol::DictionaryValue*) = 0;
virtual void setFrontend(T*) = 0;
virtual void clearFrontend() = 0;
virtual void restore() = 0;
};
static std::unique_ptr<V8Debugger> create(v8::Isolate*, V8DebuggerClient*);
virtual ~V8Debugger() { }
@ -48,14 +40,10 @@ public:
virtual void idleStarted() = 0;
virtual void idleFinished() = 0;
virtual std::unique_ptr<V8InspectorSession> connect(int contextGroupId) = 0;
virtual std::unique_ptr<V8InspectorSession> connect(int contextGroupId, protocol::FrontendChannel*, V8InspectorSessionClient*, const String16* state) = 0;
virtual bool isPaused() = 0;
static v8::Local<v8::Private> scopeExtensionPrivate(v8::Isolate*);
static bool isCommandLineAPIMethod(const String16& name);
static bool isCommandLineAPIGetter(const String16& name);
virtual std::unique_ptr<V8StackTrace> createStackTrace(v8::Local<v8::StackTrace>, size_t maxStackSize) = 0;
virtual std::unique_ptr<V8StackTrace> createStackTrace(v8::Local<v8::StackTrace>) = 0;
virtual std::unique_ptr<V8StackTrace> captureStackTrace(size_t maxStackSize) = 0;
};

24
deps/v8_inspector/platform/v8_inspector/public/V8DebuggerAgent.h

@ -1,24 +0,0 @@
// Copyright 2015 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 V8DebuggerAgent_h
#define V8DebuggerAgent_h
#include "platform/PlatformExport.h"
#include "platform/inspector_protocol/Dispatcher.h"
#include "platform/v8_inspector/public/V8Debugger.h"
namespace blink {
class V8RuntimeAgent;
class PLATFORM_EXPORT V8DebuggerAgent : public protocol::Backend::Debugger, public V8Debugger::Agent<protocol::Frontend::Debugger> {
public:
virtual ~V8DebuggerAgent() { }
};
} // namespace blink
#endif // V8DebuggerAgent_h

9
deps/v8_inspector/platform/v8_inspector/public/V8DebuggerClient.h

@ -5,11 +5,10 @@
#ifndef V8DebuggerClient_h
#define V8DebuggerClient_h
#include "platform/PlatformExport.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/v8_inspector/public/ConsoleAPITypes.h"
#include "platform/v8_inspector/public/ConsoleTypes.h"
#include "platform/v8_inspector/public/V8ContextInfo.h"
#include "platform/v8_inspector/public/V8EventListenerInfo.h"
#include <v8.h>
@ -26,7 +25,6 @@ public:
virtual void unmuteConsole() = 0;
virtual void beginUserGesture() = 0;
virtual void endUserGesture() = 0;
virtual void eventListeners(v8::Local<v8::Value>, V8EventListenerInfoList&) = 0;
virtual bool callingContextCanAccessContext(v8::Local<v8::Context> calling, v8::Local<v8::Context> target) = 0;
virtual String16 valueSubtype(v8::Local<v8::Value>) = 0;
virtual bool formatAccessorsAsProperties(v8::Local<v8::Value>) = 0;
@ -35,13 +33,14 @@ public:
virtual int ensureDefaultContextInGroup(int contextGroupId) = 0;
virtual bool isInspectableHeapObject(v8::Local<v8::Object>) = 0;
virtual void reportMessageToConsole(v8::Local<v8::Context>, MessageType, MessageLevel, const String16& message, const v8::FunctionCallbackInfo<v8::Value>* arguments, unsigned skipArgumentCount, int maxStackSize) = 0;
virtual void installAdditionalCommandLineAPI(v8::Local<v8::Context>, v8::Local<v8::Object>) = 0;
virtual void reportMessageToConsole(v8::Local<v8::Context>, MessageType, MessageLevel, const String16& message, const v8::FunctionCallbackInfo<v8::Value>* arguments, unsigned skipArgumentCount) = 0;
virtual void consoleTime(const String16& title) = 0;
virtual void consoleTimeEnd(const String16& title) = 0;
virtual void consoleTimeStamp(const String16& title) = 0;
virtual v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*, v8::Local<v8::Context>, v8::Local<v8::Object> creationContext) = 0;
virtual v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*, v8::Local<v8::Context>) = 0;
typedef void (*TimerCallback)(void*);
virtual void startRepeatingTimer(double, TimerCallback, void* data) = 0;

36
deps/v8_inspector/platform/v8_inspector/public/V8EventListenerInfo.h

@ -1,36 +0,0 @@
// Copyright 2015 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 V8EventListenerInfo_h
#define V8EventListenerInfo_h
#include "platform/inspector_protocol/Collections.h"
#include "platform/inspector_protocol/String16.h"
#include <v8.h>
namespace blink {
class V8EventListenerInfo {
public:
V8EventListenerInfo(const String16& eventType, bool useCapture, bool passive, v8::Local<v8::Object> handler)
: eventType(eventType)
, useCapture(useCapture)
, passive(passive)
, handler(handler)
{
}
const String16 eventType;
bool useCapture;
bool passive;
v8::Local<v8::Object> handler;
};
using V8EventListenerInfoList = protocol::Vector<V8EventListenerInfo>;
} // namespace blink
#endif // V8EventListenerInfo_h

23
deps/v8_inspector/platform/v8_inspector/public/V8HeapProfilerAgent.h

@ -1,23 +0,0 @@
// Copyright 2016 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 V8HeapProfilerAgent_h
#define V8HeapProfilerAgent_h
#include "platform/PlatformExport.h"
#include "platform/inspector_protocol/Dispatcher.h"
#include "platform/v8_inspector/public/V8Debugger.h"
namespace blink {
class V8RuntimeAgent;
class PLATFORM_EXPORT V8HeapProfilerAgent : public protocol::Backend::HeapProfiler, public V8Debugger::Agent<protocol::Frontend::HeapProfiler> {
public:
virtual ~V8HeapProfilerAgent() { }
};
} // namespace blink
#endif // !defined(V8HeapProfilerAgent_h)

58
deps/v8_inspector/platform/v8_inspector/public/V8Inspector.cpp

@ -5,33 +5,16 @@
#include "platform/v8_inspector/public/V8Inspector.h"
#include "platform/inspector_protocol/Dispatcher.h"
#include "platform/inspector_protocol/DispatcherBase.h"
#include "platform/v8_inspector/V8StringUtil.h"
#include "platform/v8_inspector/public/V8Debugger.h"
#include "platform/v8_inspector/public/V8DebuggerAgent.h"
#include "platform/v8_inspector/public/V8DebuggerClient.h"
#include "platform/v8_inspector/public/V8HeapProfilerAgent.h"
#include "platform/v8_inspector/public/V8ProfilerAgent.h"
#include "platform/v8_inspector/public/V8RuntimeAgent.h"
namespace blink {
V8Inspector::V8Inspector(v8::Isolate* isolate, v8::Local<v8::Context> context)
{
m_debugger = V8Debugger::create(isolate, this);
m_session = m_debugger->connect(1);
m_session->setClient(this);
m_state = protocol::DictionaryValue::create();
m_state->setValue("runtime", protocol::DictionaryValue::create());
m_state->setValue("debugger", protocol::DictionaryValue::create());
m_state->setValue("profiler", protocol::DictionaryValue::create());
m_state->setValue("heapProfiler", protocol::DictionaryValue::create());
m_session->runtimeAgent()->setInspectorState(m_state->getObject("runtime"));
m_session->debuggerAgent()->setInspectorState(m_state->getObject("debugger"));
m_session->profilerAgent()->setInspectorState(m_state->getObject("profiler"));
m_session->heapProfilerAgent()->setInspectorState(m_state->getObject("heapProfiler"));
m_debugger->contextCreated(V8ContextInfo(context, 1, true, "",
"NodeJS Main Context", "", false));
}
@ -41,10 +24,6 @@ V8Inspector::~V8Inspector()
disconnectFrontend();
}
void V8Inspector::eventListeners(v8::Local<v8::Value> value, V8EventListenerInfoList& result)
{
}
bool V8Inspector::callingContextCanAccessContext(v8::Local<v8::Context> calling, v8::Local<v8::Context> target)
{
return true;
@ -62,44 +41,18 @@ bool V8Inspector::formatAccessorsAsProperties(v8::Local<v8::Value> value)
void V8Inspector::connectFrontend(protocol::FrontendChannel* channel)
{
DCHECK(!m_frontend);
m_frontend = wrapUnique(new protocol::Frontend(channel));
m_dispatcher = protocol::Dispatcher::create(channel);
m_dispatcher->registerAgent((protocol::Backend::Debugger*)m_session->debuggerAgent());
m_dispatcher->registerAgent(m_session->heapProfilerAgent());
m_dispatcher->registerAgent(m_session->profilerAgent());
m_dispatcher->registerAgent(m_session->runtimeAgent());
m_session->debuggerAgent()->setFrontend(
protocol::Frontend::Debugger::from(m_frontend.get()));
m_session->heapProfilerAgent()->setFrontend(
protocol::Frontend::HeapProfiler::from(m_frontend.get()));
m_session->profilerAgent()->setFrontend(
protocol::Frontend::Profiler::from(m_frontend.get()));
m_session->runtimeAgent()->setFrontend(
protocol::Frontend::Runtime::from(m_frontend.get()));
m_session = m_debugger->connect(1, channel, this, &m_state);
}
void V8Inspector::disconnectFrontend()
{
if (!m_frontend)
return;
m_dispatcher->clearFrontend();
m_dispatcher.reset();
m_session->debuggerAgent()->clearFrontend();
m_session->heapProfilerAgent()->clearFrontend();
m_session->profilerAgent()->clearFrontend();
m_session->runtimeAgent()->clearFrontend();
m_frontend.reset();
m_session.reset();
}
void V8Inspector::dispatchMessageFromFrontend(const String16& message)
{
if (m_dispatcher)
m_dispatcher->dispatch(1, message);
if (m_session)
m_session->dispatchProtocolMessage(message);
}
int V8Inspector::ensureDefaultContextInGroup(int contextGroupId)
@ -109,7 +62,6 @@ int V8Inspector::ensureDefaultContextInGroup(int contextGroupId)
void V8Inspector::muteConsole()
{
}
void V8Inspector::unmuteConsole()

14
deps/v8_inspector/platform/v8_inspector/public/V8Inspector.h

@ -5,11 +5,11 @@
#ifndef V8Inspector_h
#define V8Inspector_h
#include "platform/inspector_protocol/Platform.h"
#include "platform/v8_inspector/public/V8DebuggerClient.h"
#include "platform/v8_inspector/public/V8InspectorSessionClient.h"
#include "platform/v8_inspector/public/V8InspectorSession.h"
#include "platform/v8_inspector/public/V8InspectorSessionClient.h"
#include "wtf/PtrUtil.h"
#include <v8.h>
namespace blink {
@ -35,7 +35,6 @@ public:
void dispatchMessageFromFrontend(const String16& message);
private:
void eventListeners(v8::Local<v8::Value>, V8EventListenerInfoList&) override;
bool callingContextCanAccessContext(v8::Local<v8::Context> calling, v8::Local<v8::Context> target) override;
String16 valueSubtype(v8::Local<v8::Value>) override;
bool formatAccessorsAsProperties(v8::Local<v8::Value>) override;
@ -53,11 +52,12 @@ private:
void consoleTime(const String16& title) override { }
void consoleTimeEnd(const String16& title) override { }
void consoleTimeStamp(const String16& title) override { }
v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*, v8::Local<v8::Context>, v8::Local<v8::Object> creationContext) override
v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*, v8::Local<v8::Context>) override
{
return v8::MaybeLocal<v8::Value>();
}
void reportMessageToConsole(v8::Local<v8::Context>, MessageType, MessageLevel, const String16& message, const v8::FunctionCallbackInfo<v8::Value>* arguments, unsigned skipArgumentCount, int maxStackSize) override { }
void reportMessageToConsole(v8::Local<v8::Context>, MessageType, MessageLevel, const String16& message, const v8::FunctionCallbackInfo<v8::Value>* arguments, unsigned skipArgumentCount) override { }
void installAdditionalCommandLineAPI(v8::Local<v8::Context>, v8::Local<v8::Object>) override { }
// V8InspectorSessionClient
void startInstrumenting() override { }
@ -71,9 +71,7 @@ private:
std::unique_ptr<V8Debugger> m_debugger;
std::unique_ptr<V8InspectorSession> m_session;
std::unique_ptr<protocol::Dispatcher> m_dispatcher;
std::unique_ptr<protocol::Frontend> m_frontend;
std::unique_ptr<protocol::DictionaryValue> m_state;
String16 m_state;
};
}

16
deps/v8_inspector/platform/v8_inspector/public/V8InspectorSession.h

@ -5,9 +5,8 @@
#ifndef V8InspectorSession_h
#define V8InspectorSession_h
#include "platform/PlatformExport.h"
#include "platform/inspector_protocol/TypeBuilder.h"
#include "wtf/PtrUtil.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/v8_inspector/protocol/Runtime.h"
#include <v8.h>
@ -32,7 +31,9 @@ public:
virtual ~V8InspectorSession() { }
virtual void setClient(V8InspectorSessionClient*) = 0;
static bool isV8ProtocolMethod(const String16& method);
virtual void dispatchProtocolMessage(const String16& message) = 0;
virtual String16 stateJSON() = 0;
virtual void addInspectedObject(std::unique_ptr<Inspectable>) = 0;
// API for the embedder to report native activities.
@ -41,6 +42,8 @@ public:
virtual void breakProgram(const String16& breakReason, std::unique_ptr<protocol::DictionaryValue> data) = 0;
virtual void breakProgramOnException(const String16& breakReason, std::unique_ptr<protocol::DictionaryValue> data) = 0;
virtual void setSkipAllPauses(bool) = 0;
virtual void resume() = 0;
virtual void stepOver() = 0;
// API to report async call stacks.
virtual void asyncTaskScheduled(const String16& taskName, void* task, bool recurring) = 0;
@ -55,11 +58,6 @@ public:
virtual std::unique_ptr<protocol::Runtime::RemoteObject> wrapTable(v8::Local<v8::Context>, v8::Local<v8::Value> table, v8::Local<v8::Value> columns) = 0;
virtual v8::Local<v8::Value> findObject(ErrorString*, const String16& objectId, v8::Local<v8::Context>* = nullptr, String16* objectGroup = nullptr) = 0;
virtual void releaseObjectGroup(const String16&) = 0;
virtual V8DebuggerAgent* debuggerAgent() = 0;
virtual V8HeapProfilerAgent* heapProfilerAgent() = 0;
virtual V8ProfilerAgent* profilerAgent() = 0;
virtual V8RuntimeAgent* runtimeAgent() = 0;
};
} // namespace blink

7
deps/v8_inspector/platform/v8_inspector/public/V8InspectorSessionClient.h

@ -5,13 +5,15 @@
#ifndef V8InspectorSessionClient_h
#define V8InspectorSessionClient_h
#include "platform/PlatformExport.h"
#include "platform/inspector_protocol/FrontendChannel.h"
#include "platform/inspector_protocol/Platform.h"
#include <v8.h>
namespace blink {
class PLATFORM_EXPORT V8InspectorSessionClient {
class PLATFORM_EXPORT V8InspectorSessionClient
{
public:
virtual ~V8InspectorSessionClient() { }
virtual void startInstrumenting() = 0;
@ -24,5 +26,4 @@ public:
} // namespace blink
#endif // V8InspectorSessionClient_h

22
deps/v8_inspector/platform/v8_inspector/public/V8ProfilerAgent.h

@ -1,22 +0,0 @@
// Copyright 2015 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 V8ProfilerAgent_h
#define V8ProfilerAgent_h
#include "platform/PlatformExport.h"
#include "platform/inspector_protocol/Dispatcher.h"
#include "platform/v8_inspector/public/V8Debugger.h"
namespace blink {
class PLATFORM_EXPORT V8ProfilerAgent : public protocol::Backend::Profiler, public V8Debugger::Agent<protocol::Frontend::Profiler> {
public:
virtual ~V8ProfilerAgent() { }
};
} // namespace blink
#endif // !defined(V8ProfilerAgent_h)

23
deps/v8_inspector/platform/v8_inspector/public/V8RuntimeAgent.h

@ -1,23 +0,0 @@
// Copyright 2015 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 V8RuntimeAgent_h
#define V8RuntimeAgent_h
#include "platform/PlatformExport.h"
#include "platform/inspector_protocol/Dispatcher.h"
#include "platform/v8_inspector/public/V8Debugger.h"
namespace blink {
class InjectedScriptManager;
class PLATFORM_EXPORT V8RuntimeAgent : public protocol::Backend::Runtime, public V8Debugger::Agent<protocol::Frontend::Runtime> {
public:
virtual ~V8RuntimeAgent() { }
};
} // namespace blink
#endif // V8RuntimeAgent_h

7
deps/v8_inspector/platform/v8_inspector/public/V8StackTrace.h

@ -5,8 +5,9 @@
#ifndef V8StackTrace_h
#define V8StackTrace_h
#include "platform/inspector_protocol/TypeBuilder.h"
#include "wtf/PtrUtil.h"
#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/String16.h"
#include "platform/v8_inspector/protocol/Runtime.h"
#include <v8.h>
@ -35,6 +36,8 @@ public:
virtual ~V8StackTrace() { }
virtual std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObject() const = 0;
virtual String16 toString() const = 0;
virtual std::unique_ptr<V8StackTrace> clone() = 0;
virtual std::unique_ptr<V8StackTrace> isolatedCopy() = 0; // Safe to pass between threads.
};
} // namespace blink

189
deps/v8_inspector/platform/v8_inspector/v8_inspector.gyp

@ -3,6 +3,9 @@
# found in the LICENSE file.
{
'variables': {
'blink_platform_output_dir': '<(SHARED_INTERMEDIATE_DIR)/blink/platform',
},
'targets': [
{
# GN version: //third_party/WebKit/Source/platform:inspector_injected_script
@ -44,5 +47,191 @@
# Since this target generates header files, it needs to be a hard dependency.
'hard_dependency': 1,
},
{
# GN version: //third_party/WebKit/Source/platform:inspector_protocol_sources
'target_name': 'protocol_sources',
'type': 'none',
'dependencies': ['protocol_version'],
'variables': {
'conditions': [
['debug_devtools=="node"', {
# Node build
'jinja_module_files': [
'../../deps/jinja2/jinja2/__init__.py',
'../../deps/markupsafe/markupsafe/__init__.py', # jinja2 dep
],
}, {
'jinja_module_files': [
'<(DEPTH)/third_party/jinja2/__init__.py',
'<(DEPTH)/third_party/markupsafe/__init__.py', # jinja2 dep
],
}
],
],
},
'actions': [
{
'action_name': 'generateV8InspectorProtocolBackendSources',
'inputs': [
'<@(jinja_module_files)',
# The python script in action below.
'../inspector_protocol/CodeGenerator.py',
# Source code templates.
'../inspector_protocol/TypeBuilder_h.template',
'../inspector_protocol/TypeBuilder_cpp.template',
# Protocol definitions
'js_protocol.json',
],
'outputs': [
'<(blink_platform_output_dir)/v8_inspector/protocol/Debugger.cpp',
'<(blink_platform_output_dir)/v8_inspector/protocol/Debugger.h',
'<(blink_platform_output_dir)/v8_inspector/protocol/HeapProfiler.cpp',
'<(blink_platform_output_dir)/v8_inspector/protocol/HeapProfiler.h',
'<(blink_platform_output_dir)/v8_inspector/protocol/Profiler.cpp',
'<(blink_platform_output_dir)/v8_inspector/protocol/Profiler.h',
'<(blink_platform_output_dir)/v8_inspector/protocol/Runtime.cpp',
'<(blink_platform_output_dir)/v8_inspector/protocol/Runtime.h',
],
'action': [
'python',
'../inspector_protocol/CodeGenerator.py',
'--protocol', 'js_protocol.json',
'--string_type', 'String16',
'--export_macro', 'PLATFORM_EXPORT',
'--output_dir', '<(blink_platform_output_dir)/v8_inspector/protocol',
'--output_package', 'platform/v8_inspector/protocol',
],
'message': 'Generating protocol backend sources from json definitions.',
},
]
},
{
# GN version: //third_party/WebKit/Source/core/inspector:protocol_version
'target_name': 'protocol_version',
'type': 'none',
'actions': [
{
'action_name': 'generateV8InspectorProtocolVersion',
'inputs': [
'../inspector_protocol/generate-inspector-protocol-version',
'js_protocol.json',
],
'outputs': [
'<(blink_platform_output_dir)/v8_inspector/protocol.json',
],
'action': [
'python',
'../inspector_protocol/generate-inspector-protocol-version',
'--o',
'<@(_outputs)',
'js_protocol.json',
],
'message': 'Validate v8_inspector protocol for backwards compatibility and generate version file',
},
]
},
{
'target_name': 'v8_inspector_stl',
'type': '<(component)',
'dependencies': [
':inspector_injected_script',
':inspector_debugger_script',
':protocol_sources',
],
'defines': [
'V8_INSPECTOR_USE_STL=1'
],
'include_dirs': [
'../..',
'../../../v8/include',
'../../../v8',
'<(SHARED_INTERMEDIATE_DIR)/blink',
],
'sources': [
'<(blink_platform_output_dir)/v8_inspector/protocol/Debugger.cpp',
'<(blink_platform_output_dir)/v8_inspector/protocol/Debugger.h',
'<(blink_platform_output_dir)/v8_inspector/protocol/HeapProfiler.cpp',
'<(blink_platform_output_dir)/v8_inspector/protocol/HeapProfiler.h',
'<(blink_platform_output_dir)/v8_inspector/protocol/Profiler.cpp',
'<(blink_platform_output_dir)/v8_inspector/protocol/Profiler.h',
'<(blink_platform_output_dir)/v8_inspector/protocol/Runtime.cpp',
'<(blink_platform_output_dir)/v8_inspector/protocol/Runtime.h',
'../inspector_protocol/Allocator.h',
'../inspector_protocol/Array.h',
'../inspector_protocol/Collections.h',
'../inspector_protocol/CollectionsSTL.h',
'../inspector_protocol/DispatcherBase.cpp',
'../inspector_protocol/DispatcherBase.h',
'../inspector_protocol/ErrorSupport.cpp',
'../inspector_protocol/ErrorSupport.h',
'../inspector_protocol/Maybe.h',
'../inspector_protocol/Parser.cpp',
'../inspector_protocol/Parser.h',
'../inspector_protocol/FrontendChannel.h',
'../inspector_protocol/String16.h',
'../inspector_protocol/String16STL.cpp',
'../inspector_protocol/String16STL.h',
'../inspector_protocol/Values.cpp',
'../inspector_protocol/Values.h',
'../inspector_protocol/ValueConversions.cpp',
'../inspector_protocol/ValueConversions.h',
'Atomics.h',
'IgnoreExceptionsScope.h',
'InjectedScript.cpp',
'InjectedScript.h',
'InjectedScriptNative.cpp',
'InjectedScriptNative.h',
'InspectedContext.cpp',
'InspectedContext.h',
'JavaScriptCallFrame.cpp',
'JavaScriptCallFrame.h',
'MuteConsoleScope.h',
'ScriptBreakpoint.h',
'RemoteObjectId.cpp',
'RemoteObjectId.h',
'V8Console.cpp',
'V8Console.h',
'V8DebuggerAgentImpl.cpp',
'V8DebuggerAgentImpl.h',
'V8DebuggerImpl.cpp',
'V8DebuggerImpl.h',
'V8DebuggerScript.cpp',
'V8DebuggerScript.h',
'V8FunctionCall.cpp',
'V8FunctionCall.h',
'V8HeapProfilerAgentImpl.cpp',
'V8HeapProfilerAgentImpl.h',
'V8InjectedScriptHost.cpp',
'V8InjectedScriptHost.h',
'V8InspectorSessionImpl.cpp',
'V8InspectorSessionImpl.h',
'V8ProfilerAgentImpl.cpp',
'V8ProfilerAgentImpl.h',
'V8Regex.cpp',
'V8Regex.h',
'V8RuntimeAgentImpl.cpp',
'V8RuntimeAgentImpl.h',
'V8StackTraceImpl.cpp',
'V8StackTraceImpl.h',
'V8StringUtil.cpp',
'V8StringUtil.h',
'public/V8EventListenerInfo.h',
'public/V8ContentSearchUtil.h',
'public/V8ContextInfo.h',
'public/V8Debugger.h',
'public/V8DebuggerClient.h',
'public/V8HeapProfilerAgent.h',
'public/V8Inspector.cpp',
'public/V8Inspector.h',
'public/V8InspectorSession.h',
'public/V8StackTrace.h',
'public/V8ToProtocolValue.h',
'<(blink_platform_output_dir/v8_inspector/DebuggerScript.h',
'<(blink_platform_output_dir/v8_inspector/InjectedScriptSource.h',
],
},
], # targets
}

35
deps/v8_inspector/v8_inspector.gyp

@ -1,35 +0,0 @@
# Copyright 2016 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.
{
'includes': [
'v8_inspector.gypi',
],
'targets': [
{
'target_name': 'v8_inspector',
'type': '<(component)',
'dependencies': [
'platform/inspector_protocol/protocol.gyp:protocol_sources',
'platform/v8_inspector/v8_inspector.gyp:inspector_injected_script',
'platform/v8_inspector/v8_inspector.gyp:inspector_debugger_script',
],
'defines': [
'V8_INSPECTOR_USE_STL=1'
],
'include_dirs': [
'.',
'deps/wtf',
'../v8/include',
'../v8',
'<(SHARED_INTERMEDIATE_DIR)/blink',
],
'sources': [
'<@(v8_inspector_files)',
],
},
] # end targets
}

94
deps/v8_inspector/v8_inspector.gypi

@ -1,94 +0,0 @@
# Copyright 2016 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.
{
'variables': {
'v8_inspector_files': [
'<(SHARED_INTERMEDIATE_DIR)/blink/platform/inspector_protocol/Backend.h',
'<(SHARED_INTERMEDIATE_DIR)/blink/platform/inspector_protocol/Dispatcher.cpp',
'<(SHARED_INTERMEDIATE_DIR)/blink/platform/inspector_protocol/Dispatcher.h',
'<(SHARED_INTERMEDIATE_DIR)/blink/platform/inspector_protocol/Frontend.cpp',
'<(SHARED_INTERMEDIATE_DIR)/blink/platform/inspector_protocol/Frontend.h',
'<(SHARED_INTERMEDIATE_DIR)/blink/platform/inspector_protocol/TypeBuilder.cpp',
'<(SHARED_INTERMEDIATE_DIR)/blink/platform/inspector_protocol/TypeBuilder.h',
'platform/v8_inspector/public/V8Inspector.cpp',
'platform/v8_inspector/public/V8Inspector.h',
'platform/inspector_protocol/Allocator.h',
'platform/inspector_protocol/Array.h',
'platform/inspector_protocol/Collections.h',
'platform/inspector_protocol/CollectionsSTL.h',
'platform/inspector_protocol/ErrorSupport.cpp',
'platform/inspector_protocol/ErrorSupport.h',
'platform/inspector_protocol/Maybe.h',
'platform/inspector_protocol/Parser.cpp',
'platform/inspector_protocol/Parser.h',
'platform/inspector_protocol/FrontendChannel.h',
'platform/inspector_protocol/String16.h',
'platform/inspector_protocol/String16STL.cpp',
'platform/inspector_protocol/String16STL.h',
'platform/inspector_protocol/Values.cpp',
'platform/inspector_protocol/Values.h',
'platform/inspector_protocol/ValueConversions.cpp',
'platform/inspector_protocol/ValueConversions.h',
'platform/v8_inspector/Atomics.h',
'platform/v8_inspector/InspectorWrapper.cpp',
'platform/v8_inspector/InspectorWrapper.h',
'platform/v8_inspector/IgnoreExceptionsScope.h',
'platform/v8_inspector/InjectedScript.cpp',
'platform/v8_inspector/InjectedScript.h',
'platform/v8_inspector/InjectedScriptNative.cpp',
'platform/v8_inspector/InjectedScriptNative.h',
'platform/v8_inspector/InspectedContext.cpp',
'platform/v8_inspector/InspectedContext.h',
'platform/v8_inspector/JavaScriptCallFrame.cpp',
'platform/v8_inspector/JavaScriptCallFrame.h',
'platform/v8_inspector/MuteConsoleScope.h',
'platform/v8_inspector/ScriptBreakpoint.h',
'platform/v8_inspector/RemoteObjectId.cpp',
'platform/v8_inspector/RemoteObjectId.h',
'platform/v8_inspector/V8Console.cpp',
'platform/v8_inspector/V8Console.h',
'platform/v8_inspector/V8DebuggerAgentImpl.cpp',
'platform/v8_inspector/V8DebuggerAgentImpl.h',
'platform/v8_inspector/V8DebuggerImpl.cpp',
'platform/v8_inspector/V8DebuggerImpl.h',
'platform/v8_inspector/V8DebuggerScript.cpp',
'platform/v8_inspector/V8DebuggerScript.h',
'platform/v8_inspector/V8FunctionCall.cpp',
'platform/v8_inspector/V8FunctionCall.h',
'platform/v8_inspector/V8HeapProfilerAgentImpl.cpp',
'platform/v8_inspector/V8HeapProfilerAgentImpl.h',
'platform/v8_inspector/V8InjectedScriptHost.cpp',
'platform/v8_inspector/V8InjectedScriptHost.h',
'platform/v8_inspector/V8InspectorSessionImpl.cpp',
'platform/v8_inspector/V8InspectorSessionImpl.h',
'platform/v8_inspector/V8ProfilerAgentImpl.cpp',
'platform/v8_inspector/V8ProfilerAgentImpl.h',
'platform/v8_inspector/V8Regex.cpp',
'platform/v8_inspector/V8Regex.h',
'platform/v8_inspector/V8RuntimeAgentImpl.cpp',
'platform/v8_inspector/V8RuntimeAgentImpl.h',
'platform/v8_inspector/V8StackTraceImpl.cpp',
'platform/v8_inspector/V8StackTraceImpl.h',
'platform/v8_inspector/V8StringUtil.cpp',
'platform/v8_inspector/V8StringUtil.h',
'platform/v8_inspector/public/V8EventListenerInfo.h',
'platform/v8_inspector/public/V8ContentSearchUtil.h',
'platform/v8_inspector/public/V8ContextInfo.h',
'platform/v8_inspector/public/V8Debugger.h',
'platform/v8_inspector/public/V8DebuggerAgent.h',
'platform/v8_inspector/public/V8DebuggerClient.h',
'platform/v8_inspector/public/V8HeapProfilerAgent.h',
'platform/v8_inspector/public/V8InspectorSession.h',
'platform/v8_inspector/public/V8ProfilerAgent.h',
'platform/v8_inspector/public/V8RuntimeAgent.h',
'platform/v8_inspector/public/V8StackTrace.h',
'platform/v8_inspector/public/V8ToProtocolValue.h',
'<(SHARED_INTERMEDIATE_DIR)/blink/platform/v8_inspector/DebuggerScript.h',
'<(SHARED_INTERMEDIATE_DIR)/blink/platform/v8_inspector/InjectedScriptSource.h',
],
}
}

2
node.gyp

@ -263,7 +263,7 @@
'src/inspector-agent.h',
],
'dependencies': [
'deps/v8_inspector/v8_inspector.gyp:v8_inspector',
'deps/v8_inspector/platform/v8_inspector/v8_inspector.gyp:v8_inspector_stl',
],
'include_dirs': [
'deps/v8_inspector',

17
src/inspector_agent.cc

@ -192,7 +192,6 @@ class AgentImpl {
uv_mutex_t pause_lock_;
uv_thread_t thread_;
uv_loop_t child_loop_;
uv_tcp_t server_;
int port_;
bool wait_;
@ -237,21 +236,21 @@ class ChannelImpl final : public blink::protocol::FrontendChannel {
explicit ChannelImpl(AgentImpl* agent): agent_(agent) {}
virtual ~ChannelImpl() {}
private:
virtual void sendProtocolResponse(int sessionId, int callId,
std::unique_ptr<DictionaryValue> message)
virtual void sendProtocolResponse(int callId,
const String16& message)
override {
sendMessageToFrontend(std::move(message));
sendMessageToFrontend(message);
}
virtual void sendProtocolNotification(
std::unique_ptr<DictionaryValue> message) override {
sendMessageToFrontend(std::move(message));
const String16& message) override {
sendMessageToFrontend(message);
}
virtual void flush() override { }
virtual void flushProtocolNotifications() override { }
void sendMessageToFrontend(std::unique_ptr<DictionaryValue> message) {
agent_->Write(message->toJSONString().utf8());
void sendMessageToFrontend(const String16& message) {
agent_->Write(message.utf8());
}
AgentImpl* const agent_;

Loading…
Cancel
Save