Commit 031743fc authored by Johannes Henkel's avatar Johannes Henkel Committed by Commit Bot

[DevTools] Switch the v8 inspector session state to cbor encoding.

This depends on the following patch in V8:
https://chromium-review.googlesource.com/c/v8/v8/+/1598254

Change-Id: Ic286f68b4cd4cd8be316ffe9ab9af0f6f24e413c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1604463Reviewed-by: default avatarAlexei Filippov <alph@chromium.org>
Commit-Queue: Johannes Henkel <johannes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659099}
parent 26b3cd45
...@@ -135,7 +135,8 @@ DevToolsSession::DevToolsSession( ...@@ -135,7 +135,8 @@ DevToolsSession::DevToolsSession(
inspector_backend_dispatcher_(new protocol::UberDispatcher(this)), inspector_backend_dispatcher_(new protocol::UberDispatcher(this)),
session_state_(std::move(reattach_session_state)), session_state_(std::move(reattach_session_state)),
v8_session_state_(kV8StateKey), v8_session_state_(kV8StateKey),
v8_session_state_json_(&v8_session_state_, /*default_value=*/String()) { v8_session_state_cbor_(&v8_session_state_,
/*default_value=*/std::vector<uint8_t>()) {
io_session_ = io_session_ =
new IOSession(agent_->io_task_runner_, agent_->inspector_task_runner_, new IOSession(agent_->io_task_runner_, agent_->inspector_task_runner_,
WrapCrossThreadWeakPersistent(this), std::move(io_request)); WrapCrossThreadWeakPersistent(this), std::move(io_request));
...@@ -160,9 +161,10 @@ DevToolsSession::~DevToolsSession() { ...@@ -160,9 +161,10 @@ DevToolsSession::~DevToolsSession() {
void DevToolsSession::ConnectToV8(v8_inspector::V8Inspector* inspector, void DevToolsSession::ConnectToV8(v8_inspector::V8Inspector* inspector,
int context_group_id) { int context_group_id) {
const std::vector<uint8_t>& cbor = v8_session_state_cbor_.Get();
v8_session_ = v8_session_ =
inspector->connect(context_group_id, this, inspector->connect(context_group_id, this,
ToV8InspectorStringView(v8_session_state_json_.Get())); v8_inspector::StringView(cbor.data(), cbor.size()));
} }
bool DevToolsSession::IsDetached() { bool DevToolsSession::IsDetached() {
...@@ -285,7 +287,7 @@ void DevToolsSession::SendProtocolResponse( ...@@ -285,7 +287,7 @@ void DevToolsSession::SendProtocolResponse(
return; return;
flushProtocolNotifications(); flushProtocolNotifications();
if (v8_session_) if (v8_session_)
v8_session_state_json_.Set(ToCoreString(v8_session_->stateJSON())); v8_session_state_cbor_.Set(v8_session_->state());
// Make tests more predictable by flushing all sessions before sending // Make tests more predictable by flushing all sessions before sending
// protocol response in any of them. // protocol response in any of them.
if (WebTestSupport::IsRunningWebTest()) if (WebTestSupport::IsRunningWebTest())
...@@ -356,7 +358,7 @@ void DevToolsSession::flushProtocolNotifications() { ...@@ -356,7 +358,7 @@ void DevToolsSession::flushProtocolNotifications() {
if (!notification_queue_.size()) if (!notification_queue_.size())
return; return;
if (v8_session_) if (v8_session_)
v8_session_state_json_.Set(ToCoreString(v8_session_->stateJSON())); v8_session_state_cbor_.Set(v8_session_->state());
for (wtf_size_t i = 0; i < notification_queue_.size(); ++i) { for (wtf_size_t i = 0; i < notification_queue_.size(); ++i) {
auto serialized = notification_queue_[i]->Serialize(); auto serialized = notification_queue_[i]->Serialize();
host_ptr_->DispatchProtocolNotification(std::move(serialized), host_ptr_->DispatchProtocolNotification(std::move(serialized),
......
...@@ -96,7 +96,7 @@ class CORE_EXPORT DevToolsSession ...@@ -96,7 +96,7 @@ class CORE_EXPORT DevToolsSession
class Notification; class Notification;
Vector<std::unique_ptr<Notification>> notification_queue_; Vector<std::unique_ptr<Notification>> notification_queue_;
InspectorAgentState v8_session_state_; InspectorAgentState v8_session_state_;
InspectorAgentState::String v8_session_state_json_; InspectorAgentState::Bytes v8_session_state_cbor_;
DISALLOW_COPY_AND_ASSIGN(DevToolsSession); DISALLOW_COPY_AND_ASSIGN(DevToolsSession);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment