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

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

Issue 2927063003: Revert of [DevTools] Show icon in top toolbar when Node target is available (patchset #3 id:40001 o… (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))
227 return false;
226 attached_hosts_[host->GetId()] = host; 228 attached_hosts_[host->GetId()] = host;
227 if (!host->AttachClient(this)) {
228 attached_hosts_.erase(host->GetId());
229 return false;
230 }
231 frontend_->AttachedToTarget(CreateInfo(host), waiting_for_debugger); 229 frontend_->AttachedToTarget(CreateInfo(host), waiting_for_debugger);
232 return true; 230 return true;
233 } 231 }
234 232
235 void TargetHandler::DetachFromTargetInternal(DevToolsAgentHost* host) { 233 void TargetHandler::DetachFromTargetInternal(DevToolsAgentHost* host) {
236 auto it = attached_hosts_.find(host->GetId()); 234 auto it = attached_hosts_.find(host->GetId());
237 if (it == attached_hosts_.end()) 235 if (it == attached_hosts_.end())
238 return; 236 return;
239 host->DetachClient(this); 237 host->DetachClient(this);
240 frontend_->DetachedFromTarget(host->GetId()); 238 frontend_->DetachedFromTarget(host->GetId());
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 attached_hosts_.erase(host->GetId()); 408 attached_hosts_.erase(host->GetId());
411 } 409 }
412 410
413 // -------------- DevToolsAgentHostObserver ----------------- 411 // -------------- DevToolsAgentHostObserver -----------------
414 412
415 bool TargetHandler::ShouldForceDevToolsAgentHostCreation() { 413 bool TargetHandler::ShouldForceDevToolsAgentHostCreation() {
416 return true; 414 return true;
417 } 415 }
418 416
419 void TargetHandler::DevToolsAgentHostCreated(DevToolsAgentHost* agent_host) { 417 void TargetHandler::DevToolsAgentHostCreated(DevToolsAgentHost* agent_host) {
420 if (agent_host->GetType() == "node" && agent_host->IsAttached())
421 return;
422 // If we start discovering late, all existing agent hosts will be reported, 418 // If we start discovering late, all existing agent hosts will be reported,
423 // but we could have already attached to some. 419 // but we could have already attached to some.
424 TargetCreatedInternal(agent_host); 420 TargetCreatedInternal(agent_host);
425 } 421 }
426 422
427 void TargetHandler::DevToolsAgentHostDestroyed(DevToolsAgentHost* agent_host) { 423 void TargetHandler::DevToolsAgentHostDestroyed(DevToolsAgentHost* agent_host) {
428 DCHECK(attached_hosts_.find(agent_host->GetId()) == attached_hosts_.end()); 424 DCHECK(attached_hosts_.find(agent_host->GetId()) == attached_hosts_.end());
429 TargetDestroyedInternal(agent_host); 425 TargetDestroyedInternal(agent_host);
430 } 426 }
431 427
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
448 // -------- ServiceWorkerDevToolsManager::Observer ---------- 428 // -------- ServiceWorkerDevToolsManager::Observer ----------
449 429
450 void TargetHandler::WorkerCreated( 430 void TargetHandler::WorkerCreated(
451 ServiceWorkerDevToolsAgentHost* host) { 431 ServiceWorkerDevToolsAgentHost* host) {
452 BrowserContext* browser_context = nullptr; 432 BrowserContext* browser_context = nullptr;
453 if (render_frame_host_) 433 if (render_frame_host_)
454 browser_context = render_frame_host_->GetProcess()->GetBrowserContext(); 434 browser_context = render_frame_host_->GetProcess()->GetBrowserContext();
455 auto hosts = GetMatchingServiceWorkers(browser_context, frame_urls_); 435 auto hosts = GetMatchingServiceWorkers(browser_context, frame_urls_);
456 if (hosts.find(host->GetId()) != hosts.end() && !host->IsAttached() && 436 if (hosts.find(host->GetId()) != hosts.end() && !host->IsAttached() &&
457 !host->IsPausedForDebugOnStart() && wait_for_debugger_on_start_) { 437 !host->IsPausedForDebugOnStart() && wait_for_debugger_on_start_) {
(...skipping 23 matching lines...) Expand all
481 UpdateServiceWorkers(); 461 UpdateServiceWorkers();
482 } 462 }
483 463
484 void TargetHandler::WorkerDestroyed( 464 void TargetHandler::WorkerDestroyed(
485 ServiceWorkerDevToolsAgentHost* host) { 465 ServiceWorkerDevToolsAgentHost* host) {
486 UpdateServiceWorkers(); 466 UpdateServiceWorkers();
487 } 467 }
488 468
489 } // namespace protocol 469 } // namespace protocol
490 } // namespace content 470 } // 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