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 71ab308e0ed65363211e8dc04d3f70df65ff921e..fb191fbdb9c9cf19611c8dfa732c5b9b45b94c61 100644 |
--- a/content/browser/devtools/render_frame_devtools_agent_host.cc |
+++ b/content/browser/devtools/render_frame_devtools_agent_host.cc |
@@ -86,9 +86,7 @@ |
void Attach(); |
void Reattach(FrameHostHolder* old); |
void Detach(); |
- void DispatchProtocolMessage(int session_id, |
- int call_id, |
- const std::string& message); |
+ void DispatchProtocolMessage(int call_id, const std::string& message); |
void InspectElement(int x, int y); |
void ProcessChunkedMessageFromAgent(const DevToolsMessageChunk& chunk); |
void Suspend(); |
@@ -97,17 +95,15 @@ |
private: |
void GrantPolicy(); |
void RevokePolicy(); |
- void SendMessageToClient(int session_id, const std::string& message); |
+ void SendMessageToClient(const std::string& message); |
RenderFrameDevToolsAgentHost* agent_; |
RenderFrameHostImpl* host_; |
bool attached_; |
bool suspended_; |
DevToolsMessageChunkProcessor chunk_processor_; |
- // <session_id, message> |
- std::vector<std::pair<int, std::string>> pending_messages_; |
- // <call_id> -> <session_id, message> |
- std::map<int, std::pair<int, std::string>> sent_messages_; |
+ std::vector<std::string> pending_messages_; |
+ std::map<int, std::string> sent_messages_; |
}; |
RenderFrameDevToolsAgentHost::FrameHostHolder::FrameHostHolder( |
@@ -130,7 +126,7 @@ |
void RenderFrameDevToolsAgentHost::FrameHostHolder::Attach() { |
host_->Send(new DevToolsAgentMsg_Attach( |
- host_->GetRoutingID(), agent_->GetId(), agent_->session_id())); |
+ host_->GetRoutingID(), agent_->GetId())); |
GrantPolicy(); |
attached_ = true; |
} |
@@ -140,13 +136,10 @@ |
if (old) |
chunk_processor_.set_state_cookie(old->chunk_processor_.state_cookie()); |
host_->Send(new DevToolsAgentMsg_Reattach( |
- host_->GetRoutingID(), agent_->GetId(), agent_->session_id(), |
- chunk_processor_.state_cookie())); |
+ host_->GetRoutingID(), agent_->GetId(), chunk_processor_.state_cookie())); |
if (old) { |
- for (const auto& pair : old->sent_messages_) { |
- DispatchProtocolMessage(pair.second.first, pair.first, |
- pair.second.second); |
- } |
+ for (const auto& pair : old->sent_messages_) |
+ DispatchProtocolMessage(pair.first, pair.second); |
} |
GrantPolicy(); |
attached_ = true; |
@@ -186,18 +179,16 @@ |
} |
} |
void RenderFrameDevToolsAgentHost::FrameHostHolder::DispatchProtocolMessage( |
- int session_id, |
- int call_id, |
- const std::string& message) { |
+ int call_id, const std::string& message) { |
host_->Send(new DevToolsAgentMsg_DispatchOnInspectorBackend( |
- host_->GetRoutingID(), session_id, message)); |
- sent_messages_[call_id] = std::make_pair(session_id, message); |
+ host_->GetRoutingID(), message)); |
+ sent_messages_[call_id] = message; |
} |
void RenderFrameDevToolsAgentHost::FrameHostHolder::InspectElement( |
int x, int y) { |
host_->Send(new DevToolsAgentMsg_InspectElement( |
- host_->GetRoutingID(), agent_->GetId(), agent_->session_id(), x, y)); |
+ host_->GetRoutingID(), agent_->GetId(), x, y)); |
} |
void |
@@ -207,13 +198,12 @@ |
} |
void RenderFrameDevToolsAgentHost::FrameHostHolder::SendMessageToClient( |
- int session_id, |
const std::string& message) { |
sent_messages_.erase(chunk_processor_.last_call_id()); |
if (suspended_) |
- pending_messages_.push_back(std::make_pair(session_id, message)); |
+ pending_messages_.push_back(message); |
else |
- agent_->SendMessageToClient(session_id, message); |
+ agent_->SendMessageToClient(message); |
} |
void RenderFrameDevToolsAgentHost::FrameHostHolder::Suspend() { |
@@ -222,9 +212,9 @@ |
void RenderFrameDevToolsAgentHost::FrameHostHolder::Resume() { |
suspended_ = false; |
- for (const auto& pair : pending_messages_) |
- agent_->SendMessageToClient(pair.first, pair.second); |
- std::vector<std::pair<int, std::string>> empty; |
+ for (const std::string& message : pending_messages_) |
+ agent_->SendMessageToClient(message); |
+ std::vector<std::string> empty; |
pending_messages_.swap(empty); |
} |
@@ -335,7 +325,10 @@ |
GetIOContext())), |
emulation_handler_(nullptr), |
frame_trace_recorder_(nullptr), |
- protocol_handler_(new DevToolsProtocolHandler(this)), |
+ protocol_handler_(new DevToolsProtocolHandler( |
+ this, |
+ base::Bind(&RenderFrameDevToolsAgentHost::SendMessageToClient, |
+ base::Unretained(this)))), |
current_frame_crashed_(false) { |
DevToolsProtocolDispatcher* dispatcher = protocol_handler_->dispatcher(); |
dispatcher->SetDOMHandler(dom_handler_.get()); |
@@ -430,13 +423,13 @@ |
bool RenderFrameDevToolsAgentHost::DispatchProtocolMessage( |
const std::string& message) { |
int call_id = 0; |
- if (protocol_handler_->HandleOptionalMessage(session_id(), message, &call_id)) |
+ if (protocol_handler_->HandleOptionalMessage(message, &call_id)) |
return true; |
if (current_) |
- current_->DispatchProtocolMessage(session_id(), call_id, message); |
+ current_->DispatchProtocolMessage(call_id, message); |
if (pending_) |
- pending_->DispatchProtocolMessage(session_id(), call_id, message); |
+ pending_->DispatchProtocolMessage(call_id, message); |
return true; |
} |