Commit 839394e1 authored by Pavel Feldman's avatar Pavel Feldman

DevTools: update the renderer agent state upon notifications.

Change-Id: I368cce61bc3acedadefef6a7cc81ca22ec0327f8
TBR: dcheng for mojo touch
Reviewed-on: https://chromium-review.googlesource.com/1055625
Commit-Queue: Pavel Feldman <pfeldman@chromium.org>
Reviewed-by: default avatarEric Seckler <eseckler@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558030}
parent 7eaa5cca
......@@ -207,7 +207,11 @@ void DevToolsSession::DispatchProtocolResponse(
// |this| may be deleted at this point.
}
void DevToolsSession::DispatchProtocolNotification(const std::string& message) {
void DevToolsSession::DispatchProtocolNotification(
const std::string& message,
const base::Optional<std::string>& state) {
if (state.has_value())
state_cookie_ = state.value();
client_->DispatchProtocolMessage(agent_host_, message);
// |this| may be deleted at this point.
}
......
......@@ -80,7 +80,9 @@ class DevToolsSession : public protocol::FrontendChannel,
const std::string& message,
int call_id,
const base::Optional<std::string>& state) override;
void DispatchProtocolNotification(const std::string& message) override;
void DispatchProtocolNotification(
const std::string& message,
const base::Optional<std::string>& state) override;
mojo::AssociatedBinding<blink::mojom::DevToolsSessionHost> binding_;
blink::mojom::DevToolsSessionAssociatedPtr session_ptr_;
......
......@@ -955,10 +955,12 @@ class CrossOriginNavigationVirtualTimeTest
.SetBudget(100)
.Build());
} else {
// For every navigation, WebScopedVirtualTimePauser is going to add
// 10ms of time.
EXPECT_THAT(log_, ElementsAre("url: http://a.com/ @ 0.000000",
"url: http://b.com/ @ 1010.000000",
"url: http://c.com/ @ 2010.000000",
"url: http://d.com/ @ 3010.000000"));
"url: http://c.com/ @ 2020.000000",
"url: http://d.com/ @ 3030.000000"));
FinishAsynchronousTest();
}
}
......
......@@ -99,9 +99,10 @@ interface DevToolsSessionHost {
// |state| is a state for future reattach (see DevToolsAgent),
// may be missing if the state did not change since last time.
DispatchProtocolResponse(mojo_base.mojom.BigString message,
int32 call_id,
string? state);
int32 call_id,
string? state);
// Dispatches protocol notification to a remote debugging client.
DispatchProtocolNotification(mojo_base.mojom.BigString message);
DispatchProtocolNotification(mojo_base.mojom.BigString message,
string? state);
};
......@@ -233,7 +233,9 @@ class WebDevToolsAgentImpl::Session : public GarbageCollectedFinalized<Session>,
int call_id,
const String& response,
const String& state) override;
void SendProtocolNotification(int session_id, const String& message) override;
void SendProtocolNotification(int session_id,
const String& message,
const String& state) override;
void DispatchProtocolCommandInternal(int call_id,
const String& method,
......@@ -366,8 +368,9 @@ void WebDevToolsAgentImpl::Session::SendProtocolResponse(int session_id,
void WebDevToolsAgentImpl::Session::SendProtocolNotification(
int session_id,
const String& message) {
host_ptr_->DispatchProtocolNotification(message);
const String& message,
const String& state) {
host_ptr_->DispatchProtocolNotification(message, state);
}
void WebDevToolsAgentImpl::Session::DispatchProtocolCommand(
......
......@@ -124,13 +124,18 @@ void InspectorSession::SendProtocolResponse(int call_id,
if (disposed_)
return;
flushProtocolNotifications();
client_->SendProtocolResponse(session_id_, call_id, message,
GetStateToSend());
}
String InspectorSession::GetStateToSend() {
state_->setString(kV8StateKey, ToCoreString(v8_session_->stateJSON()));
String state_to_send = state_->serialize();
if (state_to_send == last_sent_state_)
state_to_send = String();
else
last_sent_state_ = state_to_send;
client_->SendProtocolResponse(session_id_, call_id, message, state_to_send);
return state_to_send;
}
class InspectorSession::Notification {
......@@ -192,9 +197,14 @@ void InspectorSession::flushProtocolNotifications() {
return;
for (size_t i = 0; i < agents_.size(); i++)
agents_[i]->FlushPendingProtocolNotifications();
if (!notification_queue_.size())
return;
String state_to_send = GetStateToSend();
for (size_t i = 0; i < notification_queue_.size(); ++i) {
client_->SendProtocolNotification(session_id_,
notification_queue_[i]->Serialize());
client_->SendProtocolNotification(
session_id_, notification_queue_[i]->Serialize(), state_to_send);
// Only send state once in this series of serialized updates.
state_to_send = String();
}
notification_queue_.clear();
}
......
......@@ -32,7 +32,8 @@ class CORE_EXPORT InspectorSession
const String& response,
const String& state) = 0;
virtual void SendProtocolNotification(int session_id,
const String& message) = 0;
const String& message,
const String& state) = 0;
virtual ~Client() = default;
};
......@@ -75,6 +76,8 @@ class CORE_EXPORT InspectorSession
void SendProtocolResponse(int call_id, const String& message);
String GetStateToSend();
Client* client_;
std::unique_ptr<v8_inspector::V8InspectorSession> v8_session_;
int session_id_;
......
......@@ -136,9 +136,9 @@ void WorkerInspectorController::SendProtocolResponse(int session_id,
response);
}
void WorkerInspectorController::SendProtocolNotification(
int session_id,
const String& message) {
void WorkerInspectorController::SendProtocolNotification(int session_id,
const String& message,
const String& state) {
thread_->GetWorkerReportingProxy().PostMessageToPageInspector(session_id,
message);
}
......
......@@ -71,7 +71,9 @@ class WorkerInspectorController final
int call_id,
const String& response,
const String& state) override;
void SendProtocolNotification(int session_id, const String& message) override;
void SendProtocolNotification(int session_id,
const String& message,
const String& state) override;
// WebThread::TaskObserver implementation.
void WillProcessTask() override;
......
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