| Index: content/browser/devtools/render_frame_devtools_agent_host.cc
|
| diff --git a/content/browser/devtools/render_frame_devtools_agent_host.cc b/content/browser/devtools/render_frame_devtools_agent_host.cc
|
| index ef1161ecc86426a0cf778303d82e07e98ed9717f..5852ce4dcadc0af7634f9fb2cb6ba9e0127bbcb6 100644
|
| --- a/content/browser/devtools/render_frame_devtools_agent_host.cc
|
| +++ b/content/browser/devtools/render_frame_devtools_agent_host.cc
|
| @@ -182,34 +182,37 @@ void RenderFrameDevToolsAgentHost::FrameHostHolder::Attach(
|
|
|
| void RenderFrameDevToolsAgentHost::FrameHostHolder::Reattach(
|
| FrameHostHolder* old) {
|
| - int session_id = agent_->session()->session_id();
|
| - SessionInfo& info = session_infos_[session_id];
|
| - info.chunk_processor.reset(new DevToolsMessageChunkProcessor(base::Bind(
|
| - &RenderFrameDevToolsAgentHost::FrameHostHolder::SendChunkedMessage,
|
| - base::Unretained(this))));
|
| - SessionInfo* old_info = nullptr;
|
| - if (old) {
|
| - auto it = old->session_infos_.find(session_id);
|
| - old_info = it != old->session_infos_.end() ? &(it->second) : nullptr;
|
| - }
|
| - if (old_info)
|
| - info.chunk_processor->set_state_cookie(
|
| - old_info->chunk_processor->state_cookie());
|
| - host_->Send(new DevToolsAgentMsg_Reattach(
|
| - host_->GetRoutingID(), agent_->GetId(), session_id,
|
| - info.chunk_processor->state_cookie()));
|
| - if (old_info) {
|
| - if (IsBrowserSideNavigationEnabled()) {
|
| - for (const auto& pair :
|
| - old_info->sent_messages_whose_reply_came_while_suspended) {
|
| + for (auto& session_it : agent_->sessions()) {
|
| + int session_id = session_it.first;
|
| + SessionInfo& info = session_infos_[session_id];
|
| + info.chunk_processor.reset(new DevToolsMessageChunkProcessor(base::Bind(
|
| + &RenderFrameDevToolsAgentHost::FrameHostHolder::SendChunkedMessage,
|
| + base::Unretained(this))));
|
| + SessionInfo* old_info = nullptr;
|
| + if (old) {
|
| + auto it = old->session_infos_.find(session_id);
|
| + old_info = it != old->session_infos_.end() ? &(it->second) : nullptr;
|
| + }
|
| + if (old_info) {
|
| + info.chunk_processor->set_state_cookie(
|
| + old_info->chunk_processor->state_cookie());
|
| + }
|
| + host_->Send(new DevToolsAgentMsg_Reattach(
|
| + host_->GetRoutingID(), agent_->GetId(), session_id,
|
| + info.chunk_processor->state_cookie()));
|
| + if (old_info) {
|
| + if (IsBrowserSideNavigationEnabled()) {
|
| + for (const auto& pair :
|
| + old_info->sent_messages_whose_reply_came_while_suspended) {
|
| + DispatchProtocolMessage(session_id, pair.first, pair.second.method,
|
| + pair.second.message);
|
| + }
|
| + }
|
| + for (const auto& pair : old_info->sent_messages) {
|
| DispatchProtocolMessage(session_id, pair.first, pair.second.method,
|
| pair.second.message);
|
| }
|
| }
|
| - for (const auto& pair : old_info->sent_messages) {
|
| - DispatchProtocolMessage(session_id, pair.first, pair.second.method,
|
| - pair.second.message);
|
| - }
|
| }
|
| GrantPolicy();
|
| }
|
| @@ -294,9 +297,9 @@ void RenderFrameDevToolsAgentHost::FrameHostHolder::SendChunkedMessage(
|
| info.sent_messages_whose_reply_came_while_suspended[id] = sent_message;
|
| info.pending_messages.push_back(message);
|
| } else {
|
| - // Filter any messages from previous sessions.
|
| - if (agent_->session() && agent_->session()->session_id() == session_id)
|
| - agent_->session()->SendMessageToClient(message);
|
| + auto session_it = agent_->sessions().find(session_id);
|
| + if (session_it != agent_->sessions().end())
|
| + session_it->second->SendMessageToClient(message);
|
| // |this| may be deleted at this point.
|
| }
|
| }
|
| @@ -309,9 +312,10 @@ void RenderFrameDevToolsAgentHost::FrameHostHolder::Resume() {
|
| suspended_ = false;
|
| for (auto& it : session_infos_) {
|
| SessionInfo& info = it.second;
|
| - if (agent_->session() && agent_->session()->session_id() == it.first) {
|
| + auto session_it = agent_->sessions().find(it.first);
|
| + if (session_it != agent_->sessions().end()) {
|
| for (const std::string& message : info.pending_messages)
|
| - agent_->session()->SendMessageToClient(message);
|
| + session_it->second->SendMessageToClient(message);
|
| }
|
| std::vector<std::string> empty;
|
| info.pending_messages.swap(empty);
|
| @@ -595,7 +599,8 @@ void RenderFrameDevToolsAgentHost::AttachSession(DevToolsSession* session) {
|
| current_->Attach(session);
|
| if (pending_)
|
| pending_->Attach(session);
|
| - OnClientAttached();
|
| + if (sessions().size() == 1)
|
| + OnClientsAttached();
|
| }
|
|
|
| void RenderFrameDevToolsAgentHost::DetachSession(int session_id) {
|
| @@ -603,7 +608,8 @@ void RenderFrameDevToolsAgentHost::DetachSession(int session_id) {
|
| current_->Detach(session_id);
|
| if (pending_)
|
| pending_->Detach(session_id);
|
| - OnClientDetached();
|
| + if (sessions().empty())
|
| + OnClientsDetached();
|
| }
|
|
|
| bool RenderFrameDevToolsAgentHost::DispatchProtocolMessage(
|
| @@ -644,7 +650,7 @@ void RenderFrameDevToolsAgentHost::InspectElement(
|
| pending_->InspectElement(session->session_id(), x, y);
|
| }
|
|
|
| -void RenderFrameDevToolsAgentHost::OnClientAttached() {
|
| +void RenderFrameDevToolsAgentHost::OnClientsAttached() {
|
| if (!web_contents())
|
| return;
|
|
|
| @@ -652,7 +658,7 @@ void RenderFrameDevToolsAgentHost::OnClientAttached() {
|
| CreatePowerSaveBlocker();
|
| }
|
|
|
| -void RenderFrameDevToolsAgentHost::OnClientDetached() {
|
| +void RenderFrameDevToolsAgentHost::OnClientsDetached() {
|
| #if defined(OS_ANDROID)
|
| power_save_blocker_.reset();
|
| #endif
|
| @@ -847,8 +853,8 @@ void RenderFrameDevToolsAgentHost::DestroyOnRenderFrameGone() {
|
| scoped_refptr<RenderFrameDevToolsAgentHost> protect(this);
|
| UpdateProtocolHandlers(nullptr);
|
| if (IsAttached())
|
| - OnClientDetached();
|
| - ForceDetach(false);
|
| + OnClientsDetached();
|
| + ForceDetachAllClients(false);
|
| pending_.reset();
|
| current_.reset();
|
| frame_tree_node_ = nullptr;
|
| @@ -1007,8 +1013,8 @@ void RenderFrameDevToolsAgentHost::UpdateProtocolHandlers(
|
| }
|
| #endif
|
| handlers_frame_host_ = host;
|
| - if (session())
|
| - session()->SetRenderFrameHost(host);
|
| + for (auto& it : sessions())
|
| + it.second->SetRenderFrameHost(host);
|
| }
|
|
|
| void RenderFrameDevToolsAgentHost::DisconnectWebContents() {
|
|
|