| Index: content/browser/devtools/devtools_agent_host_impl.cc
|
| diff --git a/content/browser/devtools/devtools_agent_host_impl.cc b/content/browser/devtools/devtools_agent_host_impl.cc
|
| index 4d935519c07e0fa2ee919e11ee9ec83bf5e751c8..28318e043b921197a4a015d29883f6dfdbc4fd92 100644
|
| --- a/content/browser/devtools/devtools_agent_host_impl.cc
|
| +++ b/content/browser/devtools/devtools_agent_host_impl.cc
|
| @@ -76,8 +76,7 @@ scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForWorker(
|
| }
|
|
|
| DevToolsAgentHostImpl::DevToolsAgentHostImpl()
|
| - : id_(base::GenerateGUID()),
|
| - client_(NULL) {
|
| + : id_(base::GenerateGUID()), session_id_(0), client_(NULL) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| g_instances.Get()[id_] = this;
|
| }
|
| @@ -106,6 +105,7 @@ scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::Create(
|
|
|
| void DevToolsAgentHostImpl::AttachClient(DevToolsAgentHostClient* client) {
|
| scoped_refptr<DevToolsAgentHostImpl> protect(this);
|
| + ++session_id_;
|
| if (client_) {
|
| client_->AgentHostClosed(this, true);
|
| InnerDetach();
|
| @@ -153,6 +153,16 @@ void DevToolsAgentHostImpl::DisconnectWebContents() {
|
| void DevToolsAgentHostImpl::ConnectWebContents(WebContents* wc) {
|
| }
|
|
|
| +void DevToolsAgentHostImpl::SendProtocolResponse(int session_id,
|
| + const std::string& message) {
|
| + SendMessageToClient(session_id, message);
|
| +}
|
| +
|
| +void DevToolsAgentHostImpl::SendProtocolNotification(
|
| + const std::string& message) {
|
| + SendMessageToClient(session_id(), message);
|
| +}
|
| +
|
| void DevToolsAgentHostImpl::HostClosed() {
|
| if (!client_)
|
| return;
|
| @@ -164,9 +174,13 @@ void DevToolsAgentHostImpl::HostClosed() {
|
| client->AgentHostClosed(this, false);
|
| }
|
|
|
| -void DevToolsAgentHostImpl::SendMessageToClient(const std::string& message) {
|
| +void DevToolsAgentHostImpl::SendMessageToClient(int session_id,
|
| + const std::string& message) {
|
| if (!client_)
|
| return;
|
| + // Filter any messages from previous sessions.
|
| + if (session_id != session_id_)
|
| + return;
|
| client_->DispatchProtocolMessage(this, message);
|
| }
|
|
|
| @@ -249,7 +263,7 @@ void DevToolsMessageChunkProcessor::ProcessChunkedMessageFromAgent(
|
|
|
| if (chunk.is_first && chunk.is_last) {
|
| CHECK(message_buffer_size_ == 0);
|
| - callback_.Run(chunk.data);
|
| + callback_.Run(chunk.session_id, chunk.data);
|
| return;
|
| }
|
|
|
| @@ -265,7 +279,7 @@ void DevToolsMessageChunkProcessor::ProcessChunkedMessageFromAgent(
|
|
|
| if (chunk.is_last) {
|
| CHECK(message_buffer_.size() == message_buffer_size_);
|
| - callback_.Run(message_buffer_);
|
| + callback_.Run(chunk.session_id, message_buffer_);
|
| message_buffer_ = std::string();
|
| message_buffer_size_ = 0;
|
| }
|
|
|