Skip to content

Commit 5f2507d

Browse files
committed
inspector: [1/2] separate prot gw from backend
Separate the generic inspector protocol gateway from the V8-specific backend implementation. This allows other backend implementations using the same gateway. TODO: improve inspector_agent to make discovery of backend-specific impl dynamic.
1 parent f3114e2 commit 5f2507d

9 files changed

Lines changed: 249 additions & 154 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2016 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include "platform/inspector_protocol/Inspector.h"
6+
7+
namespace inspector {
8+
9+
Inspector::Inspector(v8::Isolate* isolate, v8::Local<v8::Context> context) {
10+
}
11+
12+
Inspector::~Inspector()
13+
{
14+
disconnectFrontend();
15+
}
16+
17+
} // namespace inspector
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2016 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef INSPECTOR_PROTOCOL_INSPECTOR_H
6+
#define INSPECTOR_PROTOCOL_INSPECTOR_H
7+
8+
#include "platform/inspector_protocol/Platform.h"
9+
#include "platform/inspector_protocol/Values.h"
10+
11+
#include <v8.h>
12+
13+
namespace inspector {
14+
15+
namespace protocol {
16+
class Dispatcher;
17+
class Frontend;
18+
class FrontendChannel;
19+
}
20+
21+
class Inspector {
22+
public:
23+
Inspector(v8::Isolate*, v8::Local<v8::Context>);
24+
~Inspector();
25+
26+
// Transport interface.
27+
virtual void connectFrontend(protocol::FrontendChannel*) = 0;
28+
virtual void disconnectFrontend() = 0;
29+
virtual void dispatchMessageFromFrontend(const String16& message) = 0;
30+
31+
32+
}; // class Inspector
33+
} // namespace inspector
34+
35+
#endif // INSPECTOR_PROTOCOL_INSPECTOR_H
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Copyright 2016 The Chromium Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
{
6+
'variables': {
7+
'inspector_output_dir': '<(SHARED_INTERMEDIATE_DIR)/platform/inspector_protocol',
8+
'inspector_protocol_output_dir': '<(inspector_output_dir)/protocol'
9+
},
10+
'targets': [
11+
{
12+
# GN version: //third_party/WebKit/Source/platform:inspector_protocol_sources
13+
'target_name': 'protocol_sources',
14+
'type': 'none',
15+
'dependencies': ['protocol_version'],
16+
'variables': {
17+
'conditions': [
18+
['debug_devtools=="node"', {
19+
# Node build
20+
'jinja_module_files': [
21+
'../../deps/jinja2/jinja2/__init__.py',
22+
'../../deps/markupsafe/markupsafe/__init__.py', # jinja2 dep
23+
],
24+
}, {
25+
'jinja_module_files': [
26+
'<(DEPTH)/third_party/jinja2/__init__.py',
27+
'<(DEPTH)/third_party/markupsafe/__init__.py', # jinja2 dep
28+
],
29+
}
30+
],
31+
],
32+
},
33+
'actions': [
34+
{
35+
'action_name': 'generateInspectorProtocolBackendSources',
36+
'inputs': [
37+
'<@(jinja_module_files)',
38+
# The python script in action below.
39+
'./CodeGenerator.py',
40+
# Source code templates.
41+
'./TypeBuilder_h.template',
42+
'./TypeBuilder_cpp.template',
43+
# Protocol definitions
44+
'./js_protocol.json',
45+
],
46+
'outputs': [
47+
'<(inspector_protocol_output_dir)/Debugger.cpp',
48+
'<(inspector_protocol_output_dir)/Debugger.h',
49+
'<(inspector_protocol_output_dir)/HeapProfiler.cpp',
50+
'<(inspector_protocol_output_dir)/HeapProfiler.h',
51+
'<(inspector_protocol_output_dir)/Profiler.cpp',
52+
'<(inspector_protocol_output_dir)/Profiler.h',
53+
'<(inspector_protocol_output_dir)/Runtime.cpp',
54+
'<(inspector_protocol_output_dir)/Runtime.h',
55+
],
56+
'action': [
57+
'python',
58+
'./CodeGenerator.py',
59+
'--protocol', 'js_protocol.json',
60+
'--string_type', 'String16',
61+
'--export_macro', 'PLATFORM_EXPORT',
62+
'--output_dir', '<(inspector_protocol_output_dir)',
63+
'--output_package', 'platform/inspector_protocol/protocol',
64+
],
65+
'message': 'Generating protocol backend sources from json definitions.',
66+
},
67+
]
68+
},
69+
{
70+
# GN version: //third_party/WebKit/Source/core/inspector:protocol_version
71+
'target_name': 'protocol_version',
72+
'type': 'none',
73+
'actions': [
74+
{
75+
'action_name': 'generateInspectorProtocolVersion',
76+
'inputs': [
77+
'./generate-inspector-protocol-version',
78+
'./js_protocol.json',
79+
],
80+
'outputs': [
81+
'<(inspector_output_dir)/protocol.json',
82+
],
83+
'action': [
84+
'python',
85+
'./generate-inspector-protocol-version',
86+
'--o',
87+
'<@(_outputs)',
88+
'js_protocol.json',
89+
],
90+
'message': 'Validate v8_inspector protocol for backwards compatibility and generate version file',
91+
},
92+
]
93+
},
94+
{
95+
'target_name': 'inspector',
96+
'type': '<(component)',
97+
'dependencies': [
98+
':protocol_sources',
99+
],
100+
'defines': [
101+
'V8_INSPECTOR_USE_STL=1'
102+
],
103+
'include_dirs': [
104+
'../..',
105+
'../../../v8/include',
106+
'../../../v8',
107+
'<(SHARED_INTERMEDIATE_DIR)',
108+
],
109+
'sources': [
110+
'<(inspector_protocol_output_dir)/Debugger.cpp',
111+
'<(inspector_protocol_output_dir)/Debugger.h',
112+
'<(inspector_protocol_output_dir)/HeapProfiler.cpp',
113+
'<(inspector_protocol_output_dir)/HeapProfiler.h',
114+
'<(inspector_protocol_output_dir)/Profiler.cpp',
115+
'<(inspector_protocol_output_dir)/Profiler.h',
116+
'<(inspector_protocol_output_dir)/Runtime.cpp',
117+
'<(inspector_protocol_output_dir)/Runtime.h',
118+
119+
'Allocator.h',
120+
'Array.h',
121+
'Collections.h',
122+
'CollectionsSTL.h',
123+
'DispatcherBase.cpp',
124+
'DispatcherBase.h',
125+
'ErrorSupport.cpp',
126+
'ErrorSupport.h',
127+
'Inspector.h',
128+
'Inspector.cpp',
129+
'Maybe.h',
130+
'Parser.cpp',
131+
'Parser.h',
132+
'FrontendChannel.h',
133+
'String16.h',
134+
'String16STL.cpp',
135+
'String16STL.h',
136+
'Values.cpp',
137+
'Values.h',
138+
'ValueConversions.cpp',
139+
'ValueConversions.h',
140+
141+
],
142+
},
143+
], # targets
144+
}

deps/v8_inspector/platform/v8_inspector/js_protocol-1.1.json renamed to deps/v8_inspector/platform/inspector_protocol/js_protocol-1.1.json

File renamed without changes.

deps/v8_inspector/platform/v8_inspector/js_protocol.json renamed to deps/v8_inspector/platform/inspector_protocol/js_protocol.json

File renamed without changes.

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,41 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#ifndef V8Inspector_h
6-
#define V8Inspector_h
5+
#ifndef V8_INSPECTOR_H
6+
#define V8_INSPECTOR_H
77

8+
#include "platform/inspector_protocol/Inspector.h"
89
#include "platform/inspector_protocol/Platform.h"
10+
911
#include "platform/v8_inspector/public/V8DebuggerClient.h"
1012
#include "platform/v8_inspector/public/V8InspectorSession.h"
1113
#include "platform/v8_inspector/public/V8InspectorSessionClient.h"
1214

1315
#include <v8.h>
1416

15-
namespace blink {
16-
17+
namespace inspector {
1718
namespace protocol {
1819
class Dispatcher;
1920
class Frontend;
2021
class FrontendChannel;
2122
}
23+
}
24+
25+
namespace blink {
2226

2327
class V8Debugger;
2428
class V8HeapProfilerAgent;
2529
class V8ProfilerAgent;
2630

27-
class V8Inspector : public V8DebuggerClient, V8InspectorSessionClient {
31+
class V8Inspector : public inspector::Inspector, V8DebuggerClient, V8InspectorSessionClient {
2832
public:
2933
V8Inspector(v8::Isolate*, v8::Local<v8::Context>);
3034
~V8Inspector();
3135

32-
// Transport interface.
33-
void connectFrontend(protocol::FrontendChannel*);
34-
void disconnectFrontend();
35-
void dispatchMessageFromFrontend(const String16& message);
36+
// Transport interface inherited from Inspector.
37+
void connectFrontend(inspector::protocol::FrontendChannel*) override;
38+
void disconnectFrontend() override;
39+
void dispatchMessageFromFrontend(const String16& message) override;
3640

3741
private:
3842
bool callingContextCanAccessContext(v8::Local<v8::Context> calling, v8::Local<v8::Context> target) override;

0 commit comments

Comments
 (0)