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

Side by Side Diff: content/browser/devtools/protocol/target_handler.cc

Issue 2939173002: Reland of [DevTools] Show icon in top toolbar when Node target is available (Closed)
Patch Set: Created 3 years, 6 months 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/protocol/target_handler.h" 5 #include "content/browser/devtools/protocol/target_handler.h"
6 6
7 #include "content/browser/devtools/devtools_manager.h" 7 #include "content/browser/devtools/devtools_manager.h"
8 #include "content/browser/devtools/devtools_session.h" 8 #include "content/browser/devtools/devtools_session.h"
9 #include "content/browser/devtools/service_worker_devtools_agent_host.h" 9 #include "content/browser/devtools/service_worker_devtools_agent_host.h"
10 #include "content/browser/frame_host/frame_tree.h" 10 #include "content/browser/frame_host/frame_tree.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 DevToolsAgentHost* host) { 216 DevToolsAgentHost* host) {
217 auto it = reported_hosts_.find(host->GetId()); 217 auto it = reported_hosts_.find(host->GetId());
218 if (it == reported_hosts_.end()) 218 if (it == reported_hosts_.end())
219 return; 219 return;
220 frontend_->TargetDestroyed(host->GetId()); 220 frontend_->TargetDestroyed(host->GetId());
221 reported_hosts_.erase(it); 221 reported_hosts_.erase(it);
222 } 222 }
223 223
224 bool TargetHandler::AttachToTargetInternal( 224 bool TargetHandler::AttachToTargetInternal(
225 DevToolsAgentHost* host, bool waiting_for_debugger) { 225 DevToolsAgentHost* host, bool waiting_for_debugger) {
226 if (!host->AttachClient(this)) 226 attached_hosts_[host->GetId()] = host;
227 if (!host->AttachClient(this)) {
228 attached_hosts_.erase(host->GetId());
227 return false; 229 return false;
228 attached_hosts_[host->GetId()] = host; 230 }
229 frontend_->AttachedToTarget(CreateInfo(host), waiting_for_debugger); 231 frontend_->AttachedToTarget(CreateInfo(host), waiting_for_debugger);
230 return true; 232 return true;
231 } 233 }
232 234
233 void TargetHandler::DetachFromTargetInternal(DevToolsAgentHost* host) { 235 void TargetHandler::DetachFromTargetInternal(DevToolsAgentHost* host) {
234 auto it = attached_hosts_.find(host->GetId()); 236 auto it = attached_hosts_.find(host->GetId());
235 if (it == attached_hosts_.end()) 237 if (it == attached_hosts_.end())
236 return; 238 return;
237 host->DetachClient(this); 239 host->DetachClient(this);
238 frontend_->DetachedFromTarget(host->GetId()); 240 frontend_->DetachedFromTarget(host->GetId());
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 attached_hosts_.erase(host->GetId()); 410 attached_hosts_.erase(host->GetId());
409 } 411 }
410 412
411 // -------------- DevToolsAgentHostObserver ----------------- 413 // -------------- DevToolsAgentHostObserver -----------------
412 414
413 bool TargetHandler::ShouldForceDevToolsAgentHostCreation() { 415 bool TargetHandler::ShouldForceDevToolsAgentHostCreation() {
414 return true; 416 return true;
415 } 417 }
416 418
417 void TargetHandler::DevToolsAgentHostCreated(DevToolsAgentHost* agent_host) { 419 void TargetHandler::DevToolsAgentHostCreated(DevToolsAgentHost* agent_host) {
420 if (agent_host->GetType() == "node" && agent_host->IsAttached())
421 return;
418 // If we start discovering late, all existing agent hosts will be reported, 422 // If we start discovering late, all existing agent hosts will be reported,
419 // but we could have already attached to some. 423 // but we could have already attached to some.
420 TargetCreatedInternal(agent_host); 424 TargetCreatedInternal(agent_host);
421 } 425 }
422 426
423 void TargetHandler::DevToolsAgentHostDestroyed(DevToolsAgentHost* agent_host) { 427 void TargetHandler::DevToolsAgentHostDestroyed(DevToolsAgentHost* agent_host) {
424 DCHECK(attached_hosts_.find(agent_host->GetId()) == attached_hosts_.end()); 428 DCHECK(attached_hosts_.find(agent_host->GetId()) == attached_hosts_.end());
425 TargetDestroyedInternal(agent_host); 429 TargetDestroyedInternal(agent_host);
426 } 430 }
427 431
432 void TargetHandler::DevToolsAgentHostAttached(DevToolsAgentHost* host) {
433 if (host->GetType() == "node" &&
434 reported_hosts_.find(host->GetId()) != reported_hosts_.end() &&
435 attached_hosts_.find(host->GetId()) == attached_hosts_.end()) {
436 TargetDestroyedInternal(host);
437 }
438 }
439
440 void TargetHandler::DevToolsAgentHostDetached(DevToolsAgentHost* host) {
441 if (host->GetType() == "node" &&
442 reported_hosts_.find(host->GetId()) == reported_hosts_.end() &&
443 attached_hosts_.find(host->GetId()) == attached_hosts_.end()) {
444 TargetCreatedInternal(host);
445 }
446 }
447
428 // -------- ServiceWorkerDevToolsManager::Observer ---------- 448 // -------- ServiceWorkerDevToolsManager::Observer ----------
429 449
430 void TargetHandler::WorkerCreated( 450 void TargetHandler::WorkerCreated(
431 ServiceWorkerDevToolsAgentHost* host) { 451 ServiceWorkerDevToolsAgentHost* host) {
432 BrowserContext* browser_context = nullptr; 452 BrowserContext* browser_context = nullptr;
433 if (render_frame_host_) 453 if (render_frame_host_)
434 browser_context = render_frame_host_->GetProcess()->GetBrowserContext(); 454 browser_context = render_frame_host_->GetProcess()->GetBrowserContext();
435 auto hosts = GetMatchingServiceWorkers(browser_context, frame_urls_); 455 auto hosts = GetMatchingServiceWorkers(browser_context, frame_urls_);
436 if (hosts.find(host->GetId()) != hosts.end() && !host->IsAttached() && 456 if (hosts.find(host->GetId()) != hosts.end() && !host->IsAttached() &&
437 !host->IsPausedForDebugOnStart() && wait_for_debugger_on_start_) { 457 !host->IsPausedForDebugOnStart() && wait_for_debugger_on_start_) {
(...skipping 23 matching lines...) Expand all
461 UpdateServiceWorkers(); 481 UpdateServiceWorkers();
462 } 482 }
463 483
464 void TargetHandler::WorkerDestroyed( 484 void TargetHandler::WorkerDestroyed(
465 ServiceWorkerDevToolsAgentHost* host) { 485 ServiceWorkerDevToolsAgentHost* host) {
466 UpdateServiceWorkers(); 486 UpdateServiceWorkers();
467 } 487 }
468 488
469 } // namespace protocol 489 } // namespace protocol
470 } // namespace content 490 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/protocol/target_handler.h ('k') | third_party/WebKit/Source/devtools/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698