Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(650)

Side by Side Diff: content/browser/devtools/render_frame_devtools_agent_host.cc

Issue 2499343002: [DevTools] Introduce DevToolsSession. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/devtools/render_frame_devtools_agent_host.h" 5 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
6 6
7 #include <tuple> 7 #include <tuple>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/guid.h" 10 #include "base/guid.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "content/browser/bad_message.h" 14 #include "content/browser/bad_message.h"
15 #include "content/browser/child_process_security_policy_impl.h" 15 #include "content/browser/child_process_security_policy_impl.h"
16 #include "content/browser/devtools/devtools_frame_trace_recorder.h" 16 #include "content/browser/devtools/devtools_frame_trace_recorder.h"
17 #include "content/browser/devtools/devtools_manager.h" 17 #include "content/browser/devtools/devtools_manager.h"
18 #include "content/browser/devtools/devtools_protocol_handler.h" 18 #include "content/browser/devtools/devtools_protocol_handler.h"
19 #include "content/browser/devtools/devtools_session.h"
19 #include "content/browser/devtools/page_navigation_throttle.h" 20 #include "content/browser/devtools/page_navigation_throttle.h"
20 #include "content/browser/devtools/protocol/dom_handler.h" 21 #include "content/browser/devtools/protocol/dom_handler.h"
21 #include "content/browser/devtools/protocol/emulation_handler.h" 22 #include "content/browser/devtools/protocol/emulation_handler.h"
22 #include "content/browser/devtools/protocol/input_handler.h" 23 #include "content/browser/devtools/protocol/input_handler.h"
23 #include "content/browser/devtools/protocol/inspector_handler.h" 24 #include "content/browser/devtools/protocol/inspector_handler.h"
24 #include "content/browser/devtools/protocol/io_handler.h" 25 #include "content/browser/devtools/protocol/io_handler.h"
25 #include "content/browser/devtools/protocol/network_handler.h" 26 #include "content/browser/devtools/protocol/network_handler.h"
26 #include "content/browser/devtools/protocol/page_handler.h" 27 #include "content/browser/devtools/protocol/page_handler.h"
27 #include "content/browser/devtools/protocol/schema_handler.h" 28 #include "content/browser/devtools/protocol/schema_handler.h"
28 #include "content/browser/devtools/protocol/security_handler.h" 29 #include "content/browser/devtools/protocol/security_handler.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 DCHECK(host_); 143 DCHECK(host_);
143 } 144 }
144 145
145 RenderFrameDevToolsAgentHost::FrameHostHolder::~FrameHostHolder() { 146 RenderFrameDevToolsAgentHost::FrameHostHolder::~FrameHostHolder() {
146 if (attached_) 147 if (attached_)
147 RevokePolicy(); 148 RevokePolicy();
148 } 149 }
149 150
150 void RenderFrameDevToolsAgentHost::FrameHostHolder::Attach() { 151 void RenderFrameDevToolsAgentHost::FrameHostHolder::Attach() {
151 host_->Send(new DevToolsAgentMsg_Attach( 152 host_->Send(new DevToolsAgentMsg_Attach(
152 host_->GetRoutingID(), agent_->GetId(), agent_->session_id())); 153 host_->GetRoutingID(), agent_->GetId(), agent_->session()->session_id()));
153 GrantPolicy(); 154 GrantPolicy();
154 attached_ = true; 155 attached_ = true;
155 } 156 }
156 157
157 void RenderFrameDevToolsAgentHost::FrameHostHolder::Reattach( 158 void RenderFrameDevToolsAgentHost::FrameHostHolder::Reattach(
158 FrameHostHolder* old) { 159 FrameHostHolder* old) {
159 if (old) 160 if (old)
160 chunk_processor_.set_state_cookie(old->chunk_processor_.state_cookie()); 161 chunk_processor_.set_state_cookie(old->chunk_processor_.state_cookie());
161 host_->Send(new DevToolsAgentMsg_Reattach( 162 host_->Send(new DevToolsAgentMsg_Reattach(
162 host_->GetRoutingID(), agent_->GetId(), agent_->session_id(), 163 host_->GetRoutingID(), agent_->GetId(), agent_->session()->session_id(),
163 chunk_processor_.state_cookie())); 164 chunk_processor_.state_cookie()));
164 if (old) { 165 if (old) {
165 for (const auto& pair : old->sent_messages_) { 166 for (const auto& pair : old->sent_messages_) {
166 DispatchProtocolMessage(pair.second.session_id, pair.first, 167 DispatchProtocolMessage(pair.second.session_id, pair.first,
167 pair.second.method, pair.second.message); 168 pair.second.method, pair.second.message);
168 } 169 }
169 } 170 }
170 GrantPolicy(); 171 GrantPolicy();
171 attached_ = true; 172 attached_ = true;
172 } 173 }
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 current_->Detach(); 512 current_->Detach();
512 if (pending_) 513 if (pending_)
513 pending_->Detach(); 514 pending_->Detach();
514 OnClientDetached(); 515 OnClientDetached();
515 } 516 }
516 517
517 bool RenderFrameDevToolsAgentHost::DispatchProtocolMessage( 518 bool RenderFrameDevToolsAgentHost::DispatchProtocolMessage(
518 const std::string& message) { 519 const std::string& message) {
519 int call_id = 0; 520 int call_id = 0;
520 std::string method; 521 std::string method;
521 if (protocol_handler_->HandleOptionalMessage(session_id(), message, &call_id, 522 if (protocol_handler_->HandleOptionalMessage(session()->session_id(), message,
522 &method)) 523 &call_id, &method))
523 return true; 524 return true;
524 525
525 if (!navigating_handles_.empty()) { 526 if (!navigating_handles_.empty()) {
526 DCHECK(IsBrowserSideNavigationEnabled()); 527 DCHECK(IsBrowserSideNavigationEnabled());
527 in_navigation_protocol_message_buffer_[call_id] = 528 in_navigation_protocol_message_buffer_[call_id] =
528 { session_id(), method, message }; 529 { session()->session_id(), method, message };
529 return true; 530 return true;
530 } 531 }
531 532
532 if (current_) 533 if (current_) {
533 current_->DispatchProtocolMessage(session_id(), call_id, method, message); 534 current_->DispatchProtocolMessage(
534 if (pending_) 535 session()->session_id(), call_id, method, message);
535 pending_->DispatchProtocolMessage(session_id(), call_id, method, message); 536 }
537 if (pending_) {
538 pending_->DispatchProtocolMessage(
539 session()->session_id(), call_id, method, message);
540 }
536 return true; 541 return true;
537 } 542 }
538 543
539 void RenderFrameDevToolsAgentHost::InspectElement(int x, int y) { 544 void RenderFrameDevToolsAgentHost::InspectElement(int x, int y) {
540 if (current_) 545 if (current_)
541 current_->InspectElement(session_id(), x, y); 546 current_->InspectElement(session()->session_id(), x, y);
542 if (pending_) 547 if (pending_)
543 pending_->InspectElement(session_id(), x, y); 548 pending_->InspectElement(session()->session_id(), x, y);
544 } 549 }
545 550
546 void RenderFrameDevToolsAgentHost::OnClientAttached() { 551 void RenderFrameDevToolsAgentHost::OnClientAttached() {
547 if (!web_contents()) 552 if (!web_contents())
548 return; 553 return;
549 554
550 frame_trace_recorder_.reset(new DevToolsFrameTraceRecorder()); 555 frame_trace_recorder_.reset(new DevToolsFrameTraceRecorder());
551 CreatePowerSaveBlocker(); 556 CreatePowerSaveBlocker();
552 } 557 }
553 558
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 RenderFrameHost* host) { 1121 RenderFrameHost* host) {
1117 return (current_ && current_->host() == host) || 1122 return (current_ && current_->host() == host) ||
1118 (pending_ && pending_->host() == host); 1123 (pending_ && pending_->host() == host);
1119 } 1124 }
1120 1125
1121 bool RenderFrameDevToolsAgentHost::IsChildFrame() { 1126 bool RenderFrameDevToolsAgentHost::IsChildFrame() {
1122 return current_ && current_->host()->GetParent(); 1127 return current_ && current_->host()->GetParent();
1123 } 1128 }
1124 1129
1125 } // namespace content 1130 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/forwarding_agent_host.cc ('k') | content/browser/devtools/worker_devtools_agent_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698