[inspector] migrate Schema, Console, Profiler to new style
BUG=none R=dgozman@chromium.org Review-Url: https://codereview.chromium.org/2473563002 Cr-Commit-Position: refs/heads/master@{#40688}
This commit is contained in:
parent
d5055bc932
commit
8c08d423f3
@ -26,28 +26,29 @@ V8ConsoleAgentImpl::V8ConsoleAgentImpl(
|
|||||||
|
|
||||||
V8ConsoleAgentImpl::~V8ConsoleAgentImpl() {}
|
V8ConsoleAgentImpl::~V8ConsoleAgentImpl() {}
|
||||||
|
|
||||||
void V8ConsoleAgentImpl::enable(ErrorString* errorString) {
|
Response V8ConsoleAgentImpl::enable() {
|
||||||
if (m_enabled) return;
|
if (m_enabled) return Response::OK();
|
||||||
m_state->setBoolean(ConsoleAgentState::consoleEnabled, true);
|
m_state->setBoolean(ConsoleAgentState::consoleEnabled, true);
|
||||||
m_enabled = true;
|
m_enabled = true;
|
||||||
m_session->inspector()->enableStackCapturingIfNeeded();
|
m_session->inspector()->enableStackCapturingIfNeeded();
|
||||||
reportAllMessages();
|
reportAllMessages();
|
||||||
|
return Response::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8ConsoleAgentImpl::disable(ErrorString* errorString) {
|
Response V8ConsoleAgentImpl::disable() {
|
||||||
if (!m_enabled) return;
|
if (!m_enabled) return Response::OK();
|
||||||
m_session->inspector()->disableStackCapturingIfNeeded();
|
m_session->inspector()->disableStackCapturingIfNeeded();
|
||||||
m_state->setBoolean(ConsoleAgentState::consoleEnabled, false);
|
m_state->setBoolean(ConsoleAgentState::consoleEnabled, false);
|
||||||
m_enabled = false;
|
m_enabled = false;
|
||||||
|
return Response::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8ConsoleAgentImpl::clearMessages(ErrorString* errorString) {}
|
Response V8ConsoleAgentImpl::clearMessages() { return Response::OK(); }
|
||||||
|
|
||||||
void V8ConsoleAgentImpl::restore() {
|
void V8ConsoleAgentImpl::restore() {
|
||||||
if (!m_state->booleanProperty(ConsoleAgentState::consoleEnabled, false))
|
if (!m_state->booleanProperty(ConsoleAgentState::consoleEnabled, false))
|
||||||
return;
|
return;
|
||||||
ErrorString ignored;
|
enable();
|
||||||
enable(&ignored);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8ConsoleAgentImpl::messageAdded(V8ConsoleMessage* message) {
|
void V8ConsoleAgentImpl::messageAdded(V8ConsoleMessage* message) {
|
||||||
|
@ -14,7 +14,7 @@ namespace v8_inspector {
|
|||||||
class V8ConsoleMessage;
|
class V8ConsoleMessage;
|
||||||
class V8InspectorSessionImpl;
|
class V8InspectorSessionImpl;
|
||||||
|
|
||||||
using protocol::ErrorString;
|
using protocol::Response;
|
||||||
|
|
||||||
class V8ConsoleAgentImpl : public protocol::Console::Backend {
|
class V8ConsoleAgentImpl : public protocol::Console::Backend {
|
||||||
public:
|
public:
|
||||||
@ -22,9 +22,9 @@ class V8ConsoleAgentImpl : public protocol::Console::Backend {
|
|||||||
protocol::DictionaryValue* state);
|
protocol::DictionaryValue* state);
|
||||||
~V8ConsoleAgentImpl() override;
|
~V8ConsoleAgentImpl() override;
|
||||||
|
|
||||||
void enable(ErrorString*) override;
|
Response enable() override;
|
||||||
void disable(ErrorString*) override;
|
Response disable() override;
|
||||||
void clearMessages(ErrorString*) override;
|
Response clearMessages() override;
|
||||||
|
|
||||||
void restore();
|
void restore();
|
||||||
void messageAdded(V8ConsoleMessage*);
|
void messageAdded(V8ConsoleMessage*);
|
||||||
|
@ -105,8 +105,8 @@ V8InspectorSessionImpl::V8InspectorSessionImpl(V8InspectorImpl* inspector,
|
|||||||
|
|
||||||
V8InspectorSessionImpl::~V8InspectorSessionImpl() {
|
V8InspectorSessionImpl::~V8InspectorSessionImpl() {
|
||||||
ErrorString errorString;
|
ErrorString errorString;
|
||||||
m_consoleAgent->disable(&errorString);
|
m_consoleAgent->disable();
|
||||||
m_profilerAgent->disable(&errorString);
|
m_profilerAgent->disable();
|
||||||
m_heapProfilerAgent->disable(&errorString);
|
m_heapProfilerAgent->disable(&errorString);
|
||||||
m_debuggerAgent->disable(&errorString);
|
m_debuggerAgent->disable(&errorString);
|
||||||
m_runtimeAgent->disable(&errorString);
|
m_runtimeAgent->disable(&errorString);
|
||||||
|
@ -201,34 +201,34 @@ void V8ProfilerAgentImpl::consoleProfileEnd(const String16& title) {
|
|||||||
resolvedTitle);
|
resolvedTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8ProfilerAgentImpl::enable(ErrorString*) {
|
Response V8ProfilerAgentImpl::enable() {
|
||||||
if (m_enabled) return;
|
if (m_enabled) return Response::OK();
|
||||||
m_enabled = true;
|
m_enabled = true;
|
||||||
DCHECK(!m_profiler);
|
DCHECK(!m_profiler);
|
||||||
m_profiler = v8::CpuProfiler::New(m_isolate);
|
m_profiler = v8::CpuProfiler::New(m_isolate);
|
||||||
m_state->setBoolean(ProfilerAgentState::profilerEnabled, true);
|
m_state->setBoolean(ProfilerAgentState::profilerEnabled, true);
|
||||||
|
return Response::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8ProfilerAgentImpl::disable(ErrorString* errorString) {
|
Response V8ProfilerAgentImpl::disable() {
|
||||||
if (!m_enabled) return;
|
if (!m_enabled) return Response::OK();
|
||||||
for (size_t i = m_startedProfiles.size(); i > 0; --i)
|
for (size_t i = m_startedProfiles.size(); i > 0; --i)
|
||||||
stopProfiling(m_startedProfiles[i - 1].m_id, false);
|
stopProfiling(m_startedProfiles[i - 1].m_id, false);
|
||||||
m_startedProfiles.clear();
|
m_startedProfiles.clear();
|
||||||
stop(nullptr, nullptr);
|
stop(nullptr);
|
||||||
m_profiler->Dispose();
|
m_profiler->Dispose();
|
||||||
m_profiler = nullptr;
|
m_profiler = nullptr;
|
||||||
m_enabled = false;
|
m_enabled = false;
|
||||||
m_state->setBoolean(ProfilerAgentState::profilerEnabled, false);
|
m_state->setBoolean(ProfilerAgentState::profilerEnabled, false);
|
||||||
|
return Response::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8ProfilerAgentImpl::setSamplingInterval(ErrorString* error,
|
Response V8ProfilerAgentImpl::setSamplingInterval(int interval) {
|
||||||
int interval) {
|
if (m_recordingCPUProfile)
|
||||||
if (m_recordingCPUProfile) {
|
return Response::Error("Cannot change sampling interval when profiling.");
|
||||||
*error = "Cannot change sampling interval when profiling.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_state->setInteger(ProfilerAgentState::samplingInterval, interval);
|
m_state->setInteger(ProfilerAgentState::samplingInterval, interval);
|
||||||
m_profiler->SetSamplingInterval(interval);
|
m_profiler->SetSamplingInterval(interval);
|
||||||
|
return Response::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8ProfilerAgentImpl::restore() {
|
void V8ProfilerAgentImpl::restore() {
|
||||||
@ -243,39 +243,34 @@ void V8ProfilerAgentImpl::restore() {
|
|||||||
if (interval) m_profiler->SetSamplingInterval(interval);
|
if (interval) m_profiler->SetSamplingInterval(interval);
|
||||||
if (m_state->booleanProperty(ProfilerAgentState::userInitiatedProfiling,
|
if (m_state->booleanProperty(ProfilerAgentState::userInitiatedProfiling,
|
||||||
false)) {
|
false)) {
|
||||||
ErrorString error;
|
start();
|
||||||
start(&error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8ProfilerAgentImpl::start(ErrorString* error) {
|
Response V8ProfilerAgentImpl::start() {
|
||||||
if (m_recordingCPUProfile) return;
|
if (m_recordingCPUProfile) return Response::OK();
|
||||||
if (!m_enabled) {
|
if (!m_enabled) return Response::Error("Profiler is not enabled");
|
||||||
*error = "Profiler is not enabled";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_recordingCPUProfile = true;
|
m_recordingCPUProfile = true;
|
||||||
m_frontendInitiatedProfileId = nextProfileId();
|
m_frontendInitiatedProfileId = nextProfileId();
|
||||||
startProfiling(m_frontendInitiatedProfileId);
|
startProfiling(m_frontendInitiatedProfileId);
|
||||||
m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, true);
|
m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, true);
|
||||||
|
return Response::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8ProfilerAgentImpl::stop(
|
Response V8ProfilerAgentImpl::stop(
|
||||||
ErrorString* errorString,
|
|
||||||
std::unique_ptr<protocol::Profiler::Profile>* profile) {
|
std::unique_ptr<protocol::Profiler::Profile>* profile) {
|
||||||
if (!m_recordingCPUProfile) {
|
if (!m_recordingCPUProfile)
|
||||||
if (errorString) *errorString = "No recording profiles found";
|
return Response::Error("No recording profiles found");
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_recordingCPUProfile = false;
|
m_recordingCPUProfile = false;
|
||||||
std::unique_ptr<protocol::Profiler::Profile> cpuProfile =
|
std::unique_ptr<protocol::Profiler::Profile> cpuProfile =
|
||||||
stopProfiling(m_frontendInitiatedProfileId, !!profile);
|
stopProfiling(m_frontendInitiatedProfileId, !!profile);
|
||||||
if (profile) {
|
if (profile) {
|
||||||
*profile = std::move(cpuProfile);
|
*profile = std::move(cpuProfile);
|
||||||
if (!profile->get() && errorString) *errorString = "Profile is not found";
|
if (!profile->get()) return Response::Error("Profile is not found");
|
||||||
}
|
}
|
||||||
m_frontendInitiatedProfileId = String16();
|
m_frontendInitiatedProfileId = String16();
|
||||||
m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false);
|
m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false);
|
||||||
|
return Response::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
String16 V8ProfilerAgentImpl::nextProfileId() {
|
String16 V8ProfilerAgentImpl::nextProfileId() {
|
||||||
|
@ -20,7 +20,7 @@ namespace v8_inspector {
|
|||||||
|
|
||||||
class V8InspectorSessionImpl;
|
class V8InspectorSessionImpl;
|
||||||
|
|
||||||
using protocol::ErrorString;
|
using protocol::Response;
|
||||||
|
|
||||||
class V8ProfilerAgentImpl : public protocol::Profiler::Backend {
|
class V8ProfilerAgentImpl : public protocol::Profiler::Backend {
|
||||||
public:
|
public:
|
||||||
@ -31,12 +31,11 @@ class V8ProfilerAgentImpl : public protocol::Profiler::Backend {
|
|||||||
bool enabled() const { return m_enabled; }
|
bool enabled() const { return m_enabled; }
|
||||||
void restore();
|
void restore();
|
||||||
|
|
||||||
void enable(ErrorString*) override;
|
Response enable() override;
|
||||||
void disable(ErrorString*) override;
|
Response disable() override;
|
||||||
void setSamplingInterval(ErrorString*, int) override;
|
Response setSamplingInterval(int) override;
|
||||||
void start(ErrorString*) override;
|
Response start() override;
|
||||||
void stop(ErrorString*,
|
Response stop(std::unique_ptr<protocol::Profiler::Profile>*) override;
|
||||||
std::unique_ptr<protocol::Profiler::Profile>*) override;
|
|
||||||
|
|
||||||
void consoleProfile(const String16& title);
|
void consoleProfile(const String16& title);
|
||||||
void consoleProfileEnd(const String16& title);
|
void consoleProfileEnd(const String16& title);
|
||||||
|
@ -16,14 +16,14 @@ V8SchemaAgentImpl::V8SchemaAgentImpl(V8InspectorSessionImpl* session,
|
|||||||
|
|
||||||
V8SchemaAgentImpl::~V8SchemaAgentImpl() {}
|
V8SchemaAgentImpl::~V8SchemaAgentImpl() {}
|
||||||
|
|
||||||
void V8SchemaAgentImpl::getDomains(
|
Response V8SchemaAgentImpl::getDomains(
|
||||||
ErrorString*,
|
|
||||||
std::unique_ptr<protocol::Array<protocol::Schema::Domain>>* result) {
|
std::unique_ptr<protocol::Array<protocol::Schema::Domain>>* result) {
|
||||||
std::vector<std::unique_ptr<protocol::Schema::Domain>> domains =
|
std::vector<std::unique_ptr<protocol::Schema::Domain>> domains =
|
||||||
m_session->supportedDomainsImpl();
|
m_session->supportedDomainsImpl();
|
||||||
*result = protocol::Array<protocol::Schema::Domain>::create();
|
*result = protocol::Array<protocol::Schema::Domain>::create();
|
||||||
for (size_t i = 0; i < domains.size(); ++i)
|
for (size_t i = 0; i < domains.size(); ++i)
|
||||||
(*result)->addItem(std::move(domains[i]));
|
(*result)->addItem(std::move(domains[i]));
|
||||||
|
return Response::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace v8_inspector
|
} // namespace v8_inspector
|
||||||
|
@ -13,7 +13,7 @@ namespace v8_inspector {
|
|||||||
|
|
||||||
class V8InspectorSessionImpl;
|
class V8InspectorSessionImpl;
|
||||||
|
|
||||||
using protocol::ErrorString;
|
using protocol::Response;
|
||||||
|
|
||||||
class V8SchemaAgentImpl : public protocol::Schema::Backend {
|
class V8SchemaAgentImpl : public protocol::Schema::Backend {
|
||||||
public:
|
public:
|
||||||
@ -21,8 +21,7 @@ class V8SchemaAgentImpl : public protocol::Schema::Backend {
|
|||||||
protocol::DictionaryValue* state);
|
protocol::DictionaryValue* state);
|
||||||
~V8SchemaAgentImpl() override;
|
~V8SchemaAgentImpl() override;
|
||||||
|
|
||||||
void getDomains(
|
Response getDomains(
|
||||||
ErrorString*,
|
|
||||||
std::unique_ptr<protocol::Array<protocol::Schema::Domain>>*) override;
|
std::unique_ptr<protocol::Array<protocol::Schema::Domain>>*) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -330,7 +330,7 @@ def resolve_type(protocol, prop):
|
|||||||
|
|
||||||
|
|
||||||
def new_style(domain):
|
def new_style(domain):
|
||||||
domains = []
|
domains = [ "Schema", "Console", "Profiler" ]
|
||||||
return domain["domain"] in domains
|
return domain["domain"] in domains
|
||||||
|
|
||||||
|
|
||||||
|
4
third_party/inspector_protocol/README.v8
vendored
4
third_party/inspector_protocol/README.v8
vendored
@ -13,4 +13,6 @@ description.
|
|||||||
|
|
||||||
Local modifications:
|
Local modifications:
|
||||||
- This only includes the lib/ and templates/ directories, scripts, build
|
- This only includes the lib/ and templates/ directories, scripts, build
|
||||||
and the LICENSE files.
|
and the LICENSE files.
|
||||||
|
- New style domains [ "Schema", "Console", "Profiler" ] are added in
|
||||||
|
CodeGenerator.py.
|
Loading…
Reference in New Issue
Block a user