summaryrefslogtreecommitdiffstats
path: root/content/renderer/devtools
diff options
context:
space:
mode:
authorkozyatinskiy <kozyatinskiy@chromium.org>2015-11-20 21:40:48 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-21 05:41:26 +0000
commit1084bdca601104f8eb99fa4ff11cc1397d8dd1af (patch)
treefa47b8d11142337184697360518eea01b36cc3c1 /content/renderer/devtools
parent7033604f1c3822f4a73190cf9fef458c7cd66b9b (diff)
downloadchromium_src-1084bdca601104f8eb99fa4ff11cc1397d8dd1af.zip
chromium_src-1084bdca601104f8eb99fa4ff11cc1397d8dd1af.tar.gz
chromium_src-1084bdca601104f8eb99fa4ff11cc1397d8dd1af.tar.bz2
[DevTools] filter any messages from previous session in DevToolsAgentHostImpl
Frontend can receive response for protocol message that was sent by previous session or notification that was produced during previous session. E.g. frontend send protocol message and then reattach and then get response. session_id for protocol message is added in this CL. DevToolsAgentHostImpl store current session_id, RenderFrameDevToolsAgentHost and WorkerDevToolsAgentHost add to each protocol message session id and SendResponseMessageToClient method check it after processing. WebDevToolsAgentImpl get session_id from Attach or Reattach IPC message, clear session_id on Dettach message and use it for notifications. BUG=503875, 503824 TEST=run blink/tools/run_layout_tests.py inspector/sources/debugger-breakpoints/set-conditional-breakpoint.html --repeat-each 2 R=pfeldman@chromium.org, dgozman@chromium.org TBR=jam@chromium.org, tsepez@chromium.org Review URL: https://codereview.chromium.org/1437283003 Cr-Commit-Position: refs/heads/master@{#361008}
Diffstat (limited to 'content/renderer/devtools')
-rw-r--r--content/renderer/devtools/devtools_agent.cc39
-rw-r--r--content/renderer/devtools/devtools_agent.h20
-rw-r--r--content/renderer/devtools/devtools_agent_filter.cc3
-rw-r--r--content/renderer/devtools/devtools_agent_filter.h2
4 files changed, 36 insertions, 28 deletions
diff --git a/content/renderer/devtools/devtools_agent.cc b/content/renderer/devtools/devtools_agent.cc
index 3b2f47e..55b4c6b 100644
--- a/content/renderer/devtools/devtools_agent.cc
+++ b/content/renderer/devtools/devtools_agent.cc
@@ -101,12 +101,12 @@ void DevToolsAgent::WidgetWillClose() {
ContinueProgram();
}
-void DevToolsAgent::sendProtocolMessage(
- int call_id,
- const blink::WebString& message,
- const blink::WebString& state_cookie) {
- SendChunkedProtocolMessage(
- this, routing_id(), call_id, message.utf8(), state_cookie.utf8());
+void DevToolsAgent::sendProtocolMessage(int session_id,
+ int call_id,
+ const blink::WebString& message,
+ const blink::WebString& state_cookie) {
+ SendChunkedProtocolMessage(this, routing_id(), session_id, call_id,
+ message.utf8(), state_cookie.utf8());
}
blink::WebDevToolsAgentClient::WebKitClientMessageLoop*
@@ -157,18 +157,19 @@ DevToolsAgent* DevToolsAgent::FromRoutingId(int routing_id) {
}
// static
-void DevToolsAgent::SendChunkedProtocolMessage(
- IPC::Sender* sender,
- int routing_id,
- int call_id,
- const std::string& message,
- const std::string& post_state) {
+void DevToolsAgent::SendChunkedProtocolMessage(IPC::Sender* sender,
+ int routing_id,
+ int session_id,
+ int call_id,
+ const std::string& message,
+ const std::string& post_state) {
DevToolsMessageChunk chunk;
chunk.message_size = message.size();
chunk.is_first = true;
if (message.length() < kMaxMessageChunkSize) {
chunk.data = message;
+ chunk.session_id = session_id;
chunk.call_id = call_id;
chunk.post_state = post_state;
chunk.is_last = true;
@@ -179,6 +180,7 @@ void DevToolsAgent::SendChunkedProtocolMessage(
for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) {
chunk.is_last = pos + kMaxMessageChunkSize >= message.length();
+ chunk.session_id = chunk.is_last ? session_id : 0;
chunk.call_id = chunk.is_last ? call_id : 0;
chunk.post_state = chunk.is_last ? post_state : std::string();
chunk.data = message.substr(pos, kMaxMessageChunkSize);
@@ -189,19 +191,20 @@ void DevToolsAgent::SendChunkedProtocolMessage(
}
}
-void DevToolsAgent::OnAttach(const std::string& host_id) {
+void DevToolsAgent::OnAttach(const std::string& host_id, int session_id) {
WebDevToolsAgent* web_agent = GetWebAgent();
if (web_agent) {
- web_agent->attach(WebString::fromUTF8(host_id));
+ web_agent->attach(WebString::fromUTF8(host_id), session_id);
is_attached_ = true;
}
}
void DevToolsAgent::OnReattach(const std::string& host_id,
+ int session_id,
const std::string& agent_state) {
WebDevToolsAgent* web_agent = GetWebAgent();
if (web_agent) {
- web_agent->reattach(WebString::fromUTF8(host_id),
+ web_agent->reattach(WebString::fromUTF8(host_id), session_id,
WebString::fromUTF8(agent_state));
is_attached_ = true;
}
@@ -215,11 +218,13 @@ void DevToolsAgent::OnDetach() {
}
}
-void DevToolsAgent::OnDispatchOnInspectorBackend(const std::string& message) {
+void DevToolsAgent::OnDispatchOnInspectorBackend(int session_id,
+ const std::string& message) {
TRACE_EVENT0("devtools", "DevToolsAgent::OnDispatchOnInspectorBackend");
WebDevToolsAgent* web_agent = GetWebAgent();
if (web_agent)
- web_agent->dispatchOnInspectorBackend(WebString::fromUTF8(message));
+ web_agent->dispatchOnInspectorBackend(session_id,
+ WebString::fromUTF8(message));
}
void DevToolsAgent::OnInspectElement(int x, int y) {
diff --git a/content/renderer/devtools/devtools_agent.h b/content/renderer/devtools/devtools_agent.h
index cbdccd5..f4163d7 100644
--- a/content/renderer/devtools/devtools_agent.h
+++ b/content/renderer/devtools/devtools_agent.h
@@ -33,12 +33,12 @@ class CONTENT_EXPORT DevToolsAgent
// Returns agent instance for its routing id.
static DevToolsAgent* FromRoutingId(int routing_id);
- static void SendChunkedProtocolMessage(
- IPC::Sender* sender,
- int routing_id,
- int call_id,
- const std::string& message,
- const std::string& post_state);
+ static void SendChunkedProtocolMessage(IPC::Sender* sender,
+ int routing_id,
+ int session_id,
+ int call_id,
+ const std::string& message,
+ const std::string& post_state);
blink::WebDevToolsAgent* GetWebAgent();
@@ -55,7 +55,8 @@ class CONTENT_EXPORT DevToolsAgent
void WidgetWillClose() override;
// WebDevToolsAgentClient implementation.
- void sendProtocolMessage(int call_id,
+ void sendProtocolMessage(int session_id,
+ int call_id,
const blink::WebString& response,
const blink::WebString& state) override;
blink::WebDevToolsAgentClient::WebKitClientMessageLoop*
@@ -66,11 +67,12 @@ class CONTENT_EXPORT DevToolsAgent
void enableTracing(const blink::WebString& category_filter) override;
void disableTracing() override;
- void OnAttach(const std::string& host_id);
+ void OnAttach(const std::string& host_id, int session_id);
void OnReattach(const std::string& host_id,
+ int session_id,
const std::string& agent_state);
void OnDetach();
- void OnDispatchOnInspectorBackend(const std::string& message);
+ void OnDispatchOnInspectorBackend(int session_id, const std::string& message);
void OnInspectElement(int x, int y);
void ContinueProgram();
void OnSetupDevToolsClient(const std::string& compatibility_script);
diff --git a/content/renderer/devtools/devtools_agent_filter.cc b/content/renderer/devtools/devtools_agent_filter.cc
index e1b3af0..94b9e0d4 100644
--- a/content/renderer/devtools/devtools_agent_filter.cc
+++ b/content/renderer/devtools/devtools_agent_filter.cc
@@ -60,6 +60,7 @@ bool DevToolsAgentFilter::OnMessageReceived(const IPC::Message& message) {
DevToolsAgentFilter::~DevToolsAgentFilter() {}
void DevToolsAgentFilter::OnDispatchOnInspectorBackend(
+ int session_id,
const std::string& message) {
if (embedded_worker_routes_.find(current_routing_id_) !=
embedded_worker_routes_.end()) {
@@ -69,7 +70,7 @@ void DevToolsAgentFilter::OnDispatchOnInspectorBackend(
if (WebDevToolsAgent::shouldInterruptForMessage(
WebString::fromUTF8(message))) {
WebDevToolsAgent::interruptAndDispatch(
- new MessageImpl(message, current_routing_id_));
+ session_id, new MessageImpl(message, current_routing_id_));
}
}
diff --git a/content/renderer/devtools/devtools_agent_filter.h b/content/renderer/devtools/devtools_agent_filter.h
index c8ba687..9113ae2 100644
--- a/content/renderer/devtools/devtools_agent_filter.h
+++ b/content/renderer/devtools/devtools_agent_filter.h
@@ -43,7 +43,7 @@ class DevToolsAgentFilter : public IPC::MessageFilter {
~DevToolsAgentFilter() override;
private:
- void OnDispatchOnInspectorBackend(const std::string& message);
+ void OnDispatchOnInspectorBackend(int session_id, const std::string& message);
// Called on IO thread
void AddEmbeddedWorkerRoute(int32 routing_id);