Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 return agent_host->page_handler_->CreateThrottleForNavigation( | 371 return agent_host->page_handler_->CreateThrottleForNavigation( |
| 372 navigation_handle); | 372 navigation_handle); |
| 373 } | 373 } |
| 374 return nullptr; | 374 return nullptr; |
| 375 } | 375 } |
| 376 | 376 |
| 377 // static | 377 // static |
| 378 bool RenderFrameDevToolsAgentHost::IsNetworkHandlerEnabled( | 378 bool RenderFrameDevToolsAgentHost::IsNetworkHandlerEnabled( |
| 379 FrameTreeNode* frame_tree_node) { | 379 FrameTreeNode* frame_tree_node) { |
| 380 RenderFrameDevToolsAgentHost* agent_host = FindAgentHost(frame_tree_node); | 380 RenderFrameDevToolsAgentHost* agent_host = FindAgentHost(frame_tree_node); |
| 381 if (!agent_host) | 381 return !!agent_host && agent_host->network_handler_ && |
|
caseq
2016/12/06 18:42:13
nit: nuke !!
dgozman
2016/12/07 00:22:13
Done.
| |
| 382 return false; | 382 agent_host->network_handler_->enabled(); |
| 383 return agent_host->network_handler_->enabled(); | |
| 384 } | 383 } |
| 385 | 384 |
| 386 // static | 385 // static |
| 387 void RenderFrameDevToolsAgentHost::WebContentsCreated( | 386 void RenderFrameDevToolsAgentHost::WebContentsCreated( |
| 388 WebContents* web_contents) { | 387 WebContents* web_contents) { |
| 389 if (ShouldForceCreation()) { | 388 if (ShouldForceCreation()) { |
| 390 // Force agent host. | 389 // Force agent host. |
| 391 DevToolsAgentHost::GetOrCreateFor(web_contents); | 390 DevToolsAgentHost::GetOrCreateFor(web_contents); |
| 392 } | 391 } |
| 393 } | 392 } |
| 394 | 393 |
| 395 RenderFrameDevToolsAgentHost::RenderFrameDevToolsAgentHost( | 394 RenderFrameDevToolsAgentHost::RenderFrameDevToolsAgentHost( |
| 396 RenderFrameHostImpl* host) | 395 RenderFrameHostImpl* host) |
| 397 : DevToolsAgentHostImpl(base::GenerateGUID()), | 396 : DevToolsAgentHostImpl(base::GenerateGUID()), |
| 398 dom_handler_(new devtools::dom::DOMHandler()), | 397 dom_handler_(new devtools::dom::DOMHandler()), |
| 399 input_handler_(new devtools::input::InputHandler()), | 398 input_handler_(new devtools::input::InputHandler()), |
| 400 inspector_handler_(new devtools::inspector::InspectorHandler()), | |
| 401 network_handler_(new devtools::network::NetworkHandler()), | |
| 402 page_handler_(nullptr), | 399 page_handler_(nullptr), |
| 403 schema_handler_(new devtools::schema::SchemaHandler()), | |
| 404 security_handler_(nullptr), | 400 security_handler_(nullptr), |
| 405 service_worker_handler_( | 401 service_worker_handler_( |
| 406 new devtools::service_worker::ServiceWorkerHandler()), | 402 new devtools::service_worker::ServiceWorkerHandler()), |
| 407 storage_handler_(new devtools::storage::StorageHandler()), | 403 storage_handler_(new devtools::storage::StorageHandler()), |
| 408 target_handler_(new devtools::target::TargetHandler()), | 404 target_handler_(new devtools::target::TargetHandler()), |
| 409 emulation_handler_(nullptr), | 405 emulation_handler_(nullptr), |
| 410 frame_trace_recorder_(nullptr), | 406 frame_trace_recorder_(nullptr), |
| 411 protocol_handler_(new DevToolsProtocolHandler(this)), | 407 protocol_handler_(new DevToolsProtocolHandler(this)), |
| 412 handlers_frame_host_(nullptr), | 408 handlers_frame_host_(nullptr), |
| 413 current_frame_crashed_(false), | 409 current_frame_crashed_(false), |
| 414 pending_handle_(nullptr), | 410 pending_handle_(nullptr), |
| 415 frame_tree_node_(host->frame_tree_node()) { | 411 frame_tree_node_(host->frame_tree_node()) { |
| 416 DevToolsProtocolDispatcher* dispatcher = protocol_handler_->dispatcher(); | 412 DevToolsProtocolDispatcher* dispatcher = protocol_handler_->dispatcher(); |
| 417 dispatcher->SetDOMHandler(dom_handler_.get()); | 413 dispatcher->SetDOMHandler(dom_handler_.get()); |
| 418 dispatcher->SetInputHandler(input_handler_.get()); | 414 dispatcher->SetInputHandler(input_handler_.get()); |
| 419 dispatcher->SetInspectorHandler(inspector_handler_.get()); | |
| 420 dispatcher->SetNetworkHandler(network_handler_.get()); | |
| 421 dispatcher->SetSchemaHandler(schema_handler_.get()); | |
| 422 dispatcher->SetServiceWorkerHandler(service_worker_handler_.get()); | 415 dispatcher->SetServiceWorkerHandler(service_worker_handler_.get()); |
| 423 dispatcher->SetStorageHandler(storage_handler_.get()); | 416 dispatcher->SetStorageHandler(storage_handler_.get()); |
| 424 dispatcher->SetTargetHandler(target_handler_.get()); | 417 dispatcher->SetTargetHandler(target_handler_.get()); |
| 425 | 418 |
| 426 if (!host->GetParent()) { | 419 if (!host->GetParent()) { |
| 427 security_handler_.reset(new devtools::security::SecurityHandler()); | 420 security_handler_.reset(new devtools::security::SecurityHandler()); |
| 428 page_handler_.reset(new devtools::page::PageHandler()); | 421 page_handler_.reset(new devtools::page::PageHandler()); |
| 429 emulation_handler_.reset( | 422 emulation_handler_.reset( |
| 430 new devtools::emulation::EmulationHandler()); | 423 new devtools::emulation::EmulationHandler()); |
| 431 dispatcher->SetSecurityHandler(security_handler_.get()); | 424 dispatcher->SetSecurityHandler(security_handler_.get()); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 490 return contents ? contents->GetBrowserContext() : nullptr; | 483 return contents ? contents->GetBrowserContext() : nullptr; |
| 491 } | 484 } |
| 492 | 485 |
| 493 WebContents* RenderFrameDevToolsAgentHost::GetWebContents() { | 486 WebContents* RenderFrameDevToolsAgentHost::GetWebContents() { |
| 494 return web_contents(); | 487 return web_contents(); |
| 495 } | 488 } |
| 496 | 489 |
| 497 void RenderFrameDevToolsAgentHost::Attach() { | 490 void RenderFrameDevToolsAgentHost::Attach() { |
| 498 session()->dispatcher()->setFallThroughForNotFound(true); | 491 session()->dispatcher()->setFallThroughForNotFound(true); |
| 499 | 492 |
| 493 inspector_handler_.reset(new protocol::InspectorHandler()); | |
| 494 inspector_handler_->Wire(session()->dispatcher()); | |
|
caseq
2016/12/06 18:42:13
Symmetrically to detaching automatically in destru
dgozman
2016/12/07 00:22:13
Good point. I'll follow up with a refactoring afte
| |
| 495 inspector_handler_->SetRenderFrameHost(handlers_frame_host_); | |
| 496 | |
| 500 io_handler_.reset(new protocol::IOHandler(GetIOContext())); | 497 io_handler_.reset(new protocol::IOHandler(GetIOContext())); |
| 501 io_handler_->Wire(session()->dispatcher()); | 498 io_handler_->Wire(session()->dispatcher()); |
| 502 | 499 |
| 500 network_handler_.reset(new protocol::NetworkHandler()); | |
| 501 network_handler_->Wire(session()->dispatcher()); | |
| 502 network_handler_->SetRenderFrameHost(handlers_frame_host_); | |
| 503 | |
| 504 schema_handler_.reset(new protocol::SchemaHandler()); | |
| 505 schema_handler_->Wire(session()->dispatcher()); | |
| 506 | |
| 503 tracing_handler_.reset(new protocol::TracingHandler( | 507 tracing_handler_.reset(new protocol::TracingHandler( |
| 504 protocol::TracingHandler::Renderer, | 508 protocol::TracingHandler::Renderer, |
| 505 frame_tree_node_->frame_tree_node_id(), | 509 frame_tree_node_->frame_tree_node_id(), |
| 506 GetIOContext())); | 510 GetIOContext())); |
| 507 tracing_handler_->Wire(session()->dispatcher()); | 511 tracing_handler_->Wire(session()->dispatcher()); |
| 508 | 512 |
| 509 if (current_) | 513 if (current_) |
| 510 current_->Attach(); | 514 current_->Attach(); |
| 511 if (pending_) | 515 if (pending_) |
| 512 pending_->Attach(); | 516 pending_->Attach(); |
| 513 OnClientAttached(); | 517 OnClientAttached(); |
| 514 } | 518 } |
| 515 | 519 |
| 516 void RenderFrameDevToolsAgentHost::Detach() { | 520 void RenderFrameDevToolsAgentHost::Detach() { |
| 521 inspector_handler_->Disable(); | |
| 522 inspector_handler_.reset(); | |
| 517 io_handler_->Disable(); | 523 io_handler_->Disable(); |
| 518 io_handler_.reset(); | 524 io_handler_.reset(); |
| 525 network_handler_->Disable(); | |
| 526 network_handler_.reset(); | |
| 527 schema_handler_->Disable(); | |
| 528 schema_handler_.reset(); | |
| 519 tracing_handler_->Disable(); | 529 tracing_handler_->Disable(); |
| 520 tracing_handler_.reset(); | 530 tracing_handler_.reset(); |
| 521 | 531 |
| 522 if (current_) | 532 if (current_) |
| 523 current_->Detach(); | 533 current_->Detach(); |
| 524 if (pending_) | 534 if (pending_) |
| 525 pending_->Detach(); | 535 pending_->Detach(); |
| 526 OnClientDetached(); | 536 OnClientDetached(); |
| 527 } | 537 } |
| 528 | 538 |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 790 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: | 800 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: |
| 791 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: | 801 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: |
| 792 #if defined(OS_CHROMEOS) | 802 #if defined(OS_CHROMEOS) |
| 793 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM: | 803 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM: |
| 794 #endif | 804 #endif |
| 795 case base::TERMINATION_STATUS_PROCESS_CRASHED: | 805 case base::TERMINATION_STATUS_PROCESS_CRASHED: |
| 796 #if defined(OS_ANDROID) | 806 #if defined(OS_ANDROID) |
| 797 case base::TERMINATION_STATUS_OOM_PROTECTED: | 807 case base::TERMINATION_STATUS_OOM_PROTECTED: |
| 798 #endif | 808 #endif |
| 799 case base::TERMINATION_STATUS_LAUNCH_FAILED: | 809 case base::TERMINATION_STATUS_LAUNCH_FAILED: |
| 800 inspector_handler_->TargetCrashed(); | 810 if (inspector_handler_) |
| 811 inspector_handler_->TargetCrashed(); | |
| 801 current_frame_crashed_ = true; | 812 current_frame_crashed_ = true; |
| 802 break; | 813 break; |
| 803 default: | 814 default: |
| 804 inspector_handler_->TargetDetached("Render process gone."); | 815 if (inspector_handler_) |
| 816 inspector_handler_->TargetDetached("Render process gone."); | |
| 805 break; | 817 break; |
| 806 } | 818 } |
| 807 DCHECK(CheckConsistency()); | 819 DCHECK(CheckConsistency()); |
| 808 } | 820 } |
| 809 | 821 |
| 810 bool RenderFrameDevToolsAgentHost::OnMessageReceived( | 822 bool RenderFrameDevToolsAgentHost::OnMessageReceived( |
| 811 const IPC::Message& message) { | 823 const IPC::Message& message) { |
| 812 if (!current_) | 824 if (!current_) |
| 813 return false; | 825 return false; |
| 814 if (message.type() == ViewHostMsg_SwapCompositorFrame::ID) | 826 if (message.type() == ViewHostMsg_SwapCompositorFrame::ID) |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 911 } | 923 } |
| 912 | 924 |
| 913 void RenderFrameDevToolsAgentHost::UpdateProtocolHandlers( | 925 void RenderFrameDevToolsAgentHost::UpdateProtocolHandlers( |
| 914 RenderFrameHostImpl* host) { | 926 RenderFrameHostImpl* host) { |
| 915 handlers_frame_host_ = host; | 927 handlers_frame_host_ = host; |
| 916 dom_handler_->SetRenderFrameHost(host); | 928 dom_handler_->SetRenderFrameHost(host); |
| 917 if (emulation_handler_) | 929 if (emulation_handler_) |
| 918 emulation_handler_->SetRenderFrameHost(host); | 930 emulation_handler_->SetRenderFrameHost(host); |
| 919 input_handler_->SetRenderWidgetHost( | 931 input_handler_->SetRenderWidgetHost( |
| 920 host ? host->GetRenderWidgetHost() : nullptr); | 932 host ? host->GetRenderWidgetHost() : nullptr); |
| 921 inspector_handler_->SetRenderFrameHost(host); | 933 if (inspector_handler_) |
| 922 network_handler_->SetRenderFrameHost(host); | 934 inspector_handler_->SetRenderFrameHost(host); |
| 935 if (network_handler_) | |
| 936 network_handler_->SetRenderFrameHost(host); | |
| 923 if (page_handler_) | 937 if (page_handler_) |
| 924 page_handler_->SetRenderFrameHost(host); | 938 page_handler_->SetRenderFrameHost(host); |
| 925 service_worker_handler_->SetRenderFrameHost(host); | 939 service_worker_handler_->SetRenderFrameHost(host); |
| 926 if (security_handler_) | 940 if (security_handler_) |
| 927 security_handler_->SetRenderFrameHost(host); | 941 security_handler_->SetRenderFrameHost(host); |
| 928 if (storage_handler_) | 942 if (storage_handler_) |
| 929 storage_handler_->SetRenderFrameHost(host); | 943 storage_handler_->SetRenderFrameHost(host); |
| 930 target_handler_->SetRenderFrameHost(host); | 944 target_handler_->SetRenderFrameHost(host); |
| 931 } | 945 } |
| 932 | 946 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1140 RenderFrameHost* host) { | 1154 RenderFrameHost* host) { |
| 1141 return (current_ && current_->host() == host) || | 1155 return (current_ && current_->host() == host) || |
| 1142 (pending_ && pending_->host() == host); | 1156 (pending_ && pending_->host() == host); |
| 1143 } | 1157 } |
| 1144 | 1158 |
| 1145 bool RenderFrameDevToolsAgentHost::IsChildFrame() { | 1159 bool RenderFrameDevToolsAgentHost::IsChildFrame() { |
| 1146 return current_ && current_->host()->GetParent(); | 1160 return current_ && current_->host()->GetParent(); |
| 1147 } | 1161 } |
| 1148 | 1162 |
| 1149 } // namespace content | 1163 } // namespace content |
| OLD | NEW |