Skip to content

Commit

Permalink
inspector: [1/2] separate prot gw from backend
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
joshgav committed Jun 23, 2016
1 parent f3114e2 commit 5f2507d
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 154 deletions.
17 changes: 17 additions & 0 deletions deps/v8_inspector/platform/inspector_protocol/Inspector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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/Inspector.h"

namespace inspector {

Inspector::Inspector(v8::Isolate* isolate, v8::Local<v8::Context> context) {
}

Inspector::~Inspector()
{
disconnectFrontend();
}

} // namespace inspector
35 changes: 35 additions & 0 deletions deps/v8_inspector/platform/inspector_protocol/Inspector.h
Original file line number Diff line number Diff line change
@@ -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.

#ifndef INSPECTOR_PROTOCOL_INSPECTOR_H
#define INSPECTOR_PROTOCOL_INSPECTOR_H

#include "platform/inspector_protocol/Platform.h"
#include "platform/inspector_protocol/Values.h"

#include <v8.h>

namespace inspector {

namespace protocol {
class Dispatcher;
class Frontend;
class FrontendChannel;
}

class Inspector {
public:
Inspector(v8::Isolate*, v8::Local<v8::Context>);
~Inspector();

// Transport interface.
virtual void connectFrontend(protocol::FrontendChannel*) = 0;
virtual void disconnectFrontend() = 0;
virtual void dispatchMessageFromFrontend(const String16& message) = 0;


}; // class Inspector
} // namespace inspector

#endif // INSPECTOR_PROTOCOL_INSPECTOR_H
144 changes: 144 additions & 0 deletions deps/v8_inspector/platform/inspector_protocol/inspector.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# 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': {
'inspector_output_dir': '<(SHARED_INTERMEDIATE_DIR)/platform/inspector_protocol',
'inspector_protocol_output_dir': '<(inspector_output_dir)/protocol'
},
'targets': [
{
# 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': 'generateInspectorProtocolBackendSources',
'inputs': [
'<@(jinja_module_files)',
# The python script in action below.
'./CodeGenerator.py',
# Source code templates.
'./TypeBuilder_h.template',
'./TypeBuilder_cpp.template',
# Protocol definitions
'./js_protocol.json',
],
'outputs': [
'<(inspector_protocol_output_dir)/Debugger.cpp',
'<(inspector_protocol_output_dir)/Debugger.h',
'<(inspector_protocol_output_dir)/HeapProfiler.cpp',
'<(inspector_protocol_output_dir)/HeapProfiler.h',
'<(inspector_protocol_output_dir)/Profiler.cpp',
'<(inspector_protocol_output_dir)/Profiler.h',
'<(inspector_protocol_output_dir)/Runtime.cpp',
'<(inspector_protocol_output_dir)/Runtime.h',
],
'action': [
'python',
'./CodeGenerator.py',
'--protocol', 'js_protocol.json',
'--string_type', 'String16',
'--export_macro', 'PLATFORM_EXPORT',
'--output_dir', '<(inspector_protocol_output_dir)',
'--output_package', 'platform/inspector_protocol/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': 'generateInspectorProtocolVersion',
'inputs': [
'./generate-inspector-protocol-version',
'./js_protocol.json',
],
'outputs': [
'<(inspector_output_dir)/protocol.json',
],
'action': [
'python',
'./generate-inspector-protocol-version',
'--o',
'<@(_outputs)',
'js_protocol.json',
],
'message': 'Validate v8_inspector protocol for backwards compatibility and generate version file',
},
]
},
{
'target_name': 'inspector',
'type': '<(component)',
'dependencies': [
':protocol_sources',
],
'defines': [
'V8_INSPECTOR_USE_STL=1'
],
'include_dirs': [
'../..',
'../../../v8/include',
'../../../v8',
'<(SHARED_INTERMEDIATE_DIR)',
],
'sources': [
'<(inspector_protocol_output_dir)/Debugger.cpp',
'<(inspector_protocol_output_dir)/Debugger.h',
'<(inspector_protocol_output_dir)/HeapProfiler.cpp',
'<(inspector_protocol_output_dir)/HeapProfiler.h',
'<(inspector_protocol_output_dir)/Profiler.cpp',
'<(inspector_protocol_output_dir)/Profiler.h',
'<(inspector_protocol_output_dir)/Runtime.cpp',
'<(inspector_protocol_output_dir)/Runtime.h',

'Allocator.h',
'Array.h',
'Collections.h',
'CollectionsSTL.h',
'DispatcherBase.cpp',
'DispatcherBase.h',
'ErrorSupport.cpp',
'ErrorSupport.h',
'Inspector.h',
'Inspector.cpp',
'Maybe.h',
'Parser.cpp',
'Parser.h',
'FrontendChannel.h',
'String16.h',
'String16STL.cpp',
'String16STL.h',
'Values.cpp',
'Values.h',
'ValueConversions.cpp',
'ValueConversions.h',

],
},
], # targets
}
22 changes: 13 additions & 9 deletions deps/v8_inspector/platform/v8_inspector/public/V8Inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,41 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8Inspector_h
#define V8Inspector_h
#ifndef V8_INSPECTOR_H
#define V8_INSPECTOR_H

#include "platform/inspector_protocol/Inspector.h"
#include "platform/inspector_protocol/Platform.h"

#include "platform/v8_inspector/public/V8DebuggerClient.h"
#include "platform/v8_inspector/public/V8InspectorSession.h"
#include "platform/v8_inspector/public/V8InspectorSessionClient.h"

#include <v8.h>

namespace blink {

namespace inspector {
namespace protocol {
class Dispatcher;
class Frontend;
class FrontendChannel;
}
}

namespace blink {

class V8Debugger;
class V8HeapProfilerAgent;
class V8ProfilerAgent;

class V8Inspector : public V8DebuggerClient, V8InspectorSessionClient {
class V8Inspector : public inspector::Inspector, V8DebuggerClient, V8InspectorSessionClient {
public:
V8Inspector(v8::Isolate*, v8::Local<v8::Context>);
~V8Inspector();

// Transport interface.
void connectFrontend(protocol::FrontendChannel*);
void disconnectFrontend();
void dispatchMessageFromFrontend(const String16& message);
// Transport interface inherited from Inspector.
void connectFrontend(inspector::protocol::FrontendChannel*) override;
void disconnectFrontend() override;
void dispatchMessageFromFrontend(const String16& message) override;

private:
bool callingContextCanAccessContext(v8::Local<v8::Context> calling, v8::Local<v8::Context> target) override;
Expand Down
Loading

0 comments on commit 5f2507d

Please sign in to comment.