Skip to content

Commit 7b00397

Browse files
committed
add DevTools page-agent implementation to display additional files in the source tree
1 parent 21e1db2 commit 7b00397

16 files changed

Lines changed: 3146 additions & 96 deletions

runtime/src/main/java/com/tns/AndroidJsV8Inspector.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@
1717
import java.util.LinkedList;
1818
import java.util.List;
1919
import java.util.Queue;
20-
import java.util.concurrent.ConcurrentLinkedQueue;
2120
import java.util.concurrent.LinkedBlockingQueue;
22-
import java.util.concurrent.atomic.AtomicBoolean;
2321

2422
import fi.iki.elonen.NanoHTTPD;
2523
import fi.iki.elonen.NanoWSD;
2624

2725
class AndroidJsV8Inspector {
28-
private static boolean DEBUG_LOG_ENABLED = true;
26+
private static boolean DEBUG_LOG_ENABLED = false;
2927

3028
private JsV8InspectorServer server;
3129
private Context context;
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// This file is generated
2+
3+
// Copyright (c) 2016 The Chromium Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style license that can be
5+
// found in the LICENSE file.
6+
7+
#include "src/inspector/protocol/GenericTypes.h"
8+
9+
#include "src/inspector/protocol/Protocol.h"
10+
11+
namespace v8_inspector {
12+
namespace protocol {
13+
namespace GenericTypes {
14+
15+
// ------------- Enum values from types.
16+
17+
const char Metainfo::domainName[] = "GenericTypes";
18+
const char Metainfo::commandPrefix[] = "GenericTypes.";
19+
const char Metainfo::version[] = "1.1";
20+
21+
std::unique_ptr<SearchMatch> SearchMatch::parse(protocol::Value* value, ErrorSupport* errors) {
22+
if (!value || value->type() != protocol::Value::TypeObject) {
23+
errors->addError("object expected");
24+
return nullptr;
25+
}
26+
27+
std::unique_ptr<SearchMatch> result(new SearchMatch());
28+
protocol::DictionaryValue* object = DictionaryValue::cast(value);
29+
errors->push();
30+
protocol::Value* lineNumberValue = object->get("lineNumber");
31+
errors->setName("lineNumber");
32+
result->m_lineNumber = ValueConversions<double>::parse(lineNumberValue, errors);
33+
protocol::Value* lineContentValue = object->get("lineContent");
34+
errors->setName("lineContent");
35+
result->m_lineContent = ValueConversions<String>::parse(lineContentValue, errors);
36+
errors->pop();
37+
if (errors->hasErrors()) {
38+
return nullptr;
39+
}
40+
return result;
41+
}
42+
43+
std::unique_ptr<protocol::DictionaryValue> SearchMatch::serialize() const {
44+
std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
45+
result->setValue("lineNumber", ValueConversions<double>::serialize(m_lineNumber));
46+
result->setValue("lineContent", ValueConversions<String>::serialize(m_lineContent));
47+
return result;
48+
}
49+
50+
std::unique_ptr<SearchMatch> SearchMatch::clone() const {
51+
ErrorSupport errors;
52+
return parse(serialize().get(), &errors);
53+
}
54+
55+
// ------------- Enum values from params.
56+
57+
58+
// ------------- Frontend notifications.
59+
60+
void Frontend::flush() {
61+
m_frontendChannel->flushProtocolNotifications();
62+
}
63+
64+
// --------------------- Dispatcher.
65+
66+
class DispatcherImpl : public protocol::DispatcherBase {
67+
public:
68+
DispatcherImpl(FrontendChannel* frontendChannel, Backend* backend)
69+
: DispatcherBase(frontendChannel)
70+
, m_backend(backend) {
71+
}
72+
~DispatcherImpl() override { }
73+
void dispatch(int callId, const String& method, std::unique_ptr<protocol::DictionaryValue> messageObject) override;
74+
75+
protected:
76+
using CallHandler = void (DispatcherImpl::*)(int callId, std::unique_ptr<DictionaryValue> messageObject, ErrorSupport* errors);
77+
using DispatchMap = protocol::HashMap<String, CallHandler>;
78+
DispatchMap m_dispatchMap;
79+
80+
81+
Backend* m_backend;
82+
};
83+
84+
void DispatcherImpl::dispatch(int callId, const String& method, std::unique_ptr<protocol::DictionaryValue> messageObject) {
85+
protocol::HashMap<String, CallHandler>::iterator it = m_dispatchMap.find(method);
86+
if (it == m_dispatchMap.end()) {
87+
reportProtocolError(callId, MethodNotFound, "'" + method + "' wasn't found", nullptr);
88+
return;
89+
}
90+
91+
protocol::ErrorSupport errors;
92+
(this->*(it->second))(callId, std::move(messageObject), &errors);
93+
}
94+
95+
96+
// static
97+
void Dispatcher::wire(UberDispatcher* dispatcher, Backend* backend) {
98+
dispatcher->registerBackend("GenericTypes", wrapUnique(new DispatcherImpl(dispatcher->channel(), backend)));
99+
}
100+
101+
} // GenericTypes
102+
} // namespace v8_inspector
103+
} // namespace protocol
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
// This file is generated
2+
3+
// Copyright (c) 2016 The Chromium Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style license that can be
5+
// found in the LICENSE file.
6+
7+
#ifndef v8_inspector_protocol_GenericTypes_h
8+
#define v8_inspector_protocol_GenericTypes_h
9+
10+
#include "src/inspector/protocol/Protocol.h"
11+
// For each imported domain we generate a ValueConversions struct instead of a full domain definition
12+
// and include Domain::API version from there.
13+
14+
namespace v8_inspector {
15+
namespace protocol {
16+
namespace GenericTypes {
17+
18+
// ------------- Forward and enum declarations.
19+
// Search match in a resource.
20+
class SearchMatch;
21+
22+
// ------------- Type and builder declarations.
23+
24+
// Search match in a resource.
25+
class SearchMatch {
26+
PROTOCOL_DISALLOW_COPY(SearchMatch);
27+
public:
28+
static std::unique_ptr<SearchMatch> parse(protocol::Value* value, ErrorSupport* errors);
29+
30+
~SearchMatch() { }
31+
32+
double getLineNumber() {
33+
return m_lineNumber;
34+
}
35+
void setLineNumber(double value) {
36+
m_lineNumber = value;
37+
}
38+
39+
String getLineContent() {
40+
return m_lineContent;
41+
}
42+
void setLineContent(const String& value) {
43+
m_lineContent = value;
44+
}
45+
46+
std::unique_ptr<protocol::DictionaryValue> serialize() const;
47+
std::unique_ptr<SearchMatch> clone() const;
48+
49+
template<int STATE>
50+
class SearchMatchBuilder {
51+
public:
52+
enum {
53+
NoFieldsSet = 0,
54+
LineNumberSet = 1 << 1,
55+
LineContentSet = 1 << 2,
56+
AllFieldsSet = (LineNumberSet | LineContentSet | 0)
57+
};
58+
59+
60+
SearchMatchBuilder<STATE | LineNumberSet>& setLineNumber(double value) {
61+
static_assert(!(STATE & LineNumberSet), "property lineNumber should not be set yet");
62+
m_result->setLineNumber(value);
63+
return castState<LineNumberSet>();
64+
}
65+
66+
SearchMatchBuilder<STATE | LineContentSet>& setLineContent(const String& value) {
67+
static_assert(!(STATE & LineContentSet), "property lineContent should not be set yet");
68+
m_result->setLineContent(value);
69+
return castState<LineContentSet>();
70+
}
71+
72+
std::unique_ptr<SearchMatch> build() {
73+
static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
74+
return std::move(m_result);
75+
}
76+
77+
private:
78+
friend class SearchMatch;
79+
SearchMatchBuilder() : m_result(new SearchMatch()) { }
80+
81+
template<int STEP> SearchMatchBuilder<STATE | STEP>& castState() {
82+
return *reinterpret_cast<SearchMatchBuilder<STATE | STEP>*>(this);
83+
}
84+
85+
std::unique_ptr<protocol::GenericTypes::SearchMatch> m_result;
86+
};
87+
88+
static SearchMatchBuilder<0> create() {
89+
return SearchMatchBuilder<0>();
90+
}
91+
92+
private:
93+
SearchMatch() {
94+
m_lineNumber = 0;
95+
}
96+
97+
double m_lineNumber;
98+
String m_lineContent;
99+
};
100+
101+
102+
// ------------- Backend interface.
103+
104+
class Backend {
105+
public:
106+
virtual ~Backend() { }
107+
108+
109+
virtual void disable(ErrorString*) { }
110+
};
111+
112+
// ------------- Frontend interface.
113+
114+
class Frontend {
115+
public:
116+
Frontend(FrontendChannel* frontendChannel) : m_frontendChannel(frontendChannel) { }
117+
118+
void flush();
119+
private:
120+
FrontendChannel* m_frontendChannel;
121+
};
122+
123+
// ------------- Dispatcher.
124+
125+
class Dispatcher {
126+
public:
127+
static void wire(UberDispatcher*, Backend*);
128+
129+
private:
130+
Dispatcher() { }
131+
};
132+
133+
// ------------- Metainfo.
134+
135+
class Metainfo {
136+
public:
137+
using BackendClass = Backend;
138+
using FrontendClass = Frontend;
139+
using DispatcherClass = Dispatcher;
140+
static const char domainName[];
141+
static const char commandPrefix[];
142+
static const char version[];
143+
};
144+
145+
} // namespace GenericTypes
146+
} // namespace v8_inspector
147+
} // namespace protocol
148+
149+
#endif // !defined(v8_inspector_protocol_GenericTypes_h)

0 commit comments

Comments
 (0)