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

Side by Side Diff: chrome/browser/task_manager_resource_providers.cc

Issue 126289: Graceful handling of extension process crashes (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/extension_view.cc ('k') | chrome/common/notification_type.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/task_manager_resource_providers.h" 5 #include "chrome/browser/task_manager_resource_providers.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <atlbase.h> 10 #include <atlbase.h>
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 ProfileManager* profile_manager = g_browser_process->profile_manager(); 533 ProfileManager* profile_manager = g_browser_process->profile_manager();
534 for (ProfileManager::const_iterator it = profile_manager->begin(); 534 for (ProfileManager::const_iterator it = profile_manager->begin();
535 it != profile_manager->end(); ++it) { 535 it != profile_manager->end(); ++it) {
536 ExtensionProcessManager* process_manager = 536 ExtensionProcessManager* process_manager =
537 (*it)->GetExtensionProcessManager(); 537 (*it)->GetExtensionProcessManager();
538 ExtensionProcessManager::const_iterator jt; 538 ExtensionProcessManager::const_iterator jt;
539 for (jt = process_manager->begin(); jt != process_manager->end(); ++jt) 539 for (jt = process_manager->begin(); jt != process_manager->end(); ++jt)
540 AddToTaskManager(*jt); 540 AddToTaskManager(*jt);
541 } 541 }
542 542
543 // Register for notifications to get new extension processes. 543 // Register for notifications about extension process changes.
544 registrar_.Add(this, NotificationType::EXTENSION_HOST_CREATED, 544 registrar_.Add(this, NotificationType::EXTENSION_HOST_CREATED,
545 NotificationService::AllSources()); 545 NotificationService::AllSources());
546 registrar_.Add(this, NotificationType::EXTENSION_HOST_DESTROYED, 546 registrar_.Add(this, NotificationType::EXTENSION_HOST_DESTROYED,
547 NotificationService::AllSources()); 547 NotificationService::AllSources());
548 registrar_.Add(this, NotificationType::EXTENSION_PROCESS_CRASHED,
549 NotificationService::AllSources());
550 registrar_.Add(this, NotificationType::EXTENSION_PROCESS_RESTORED,
551 NotificationService::AllSources());
548 } 552 }
549 553
550 void TaskManagerExtensionProcessResourceProvider::StopUpdating() { 554 void TaskManagerExtensionProcessResourceProvider::StopUpdating() {
551 DCHECK(updating_); 555 DCHECK(updating_);
552 updating_ = false; 556 updating_ = false;
553 557
554 // Unregister for notifications to get new extension processes. 558 // Unregister for notifications about extension process changes.
555 registrar_.Remove(this, NotificationType::EXTENSION_HOST_CREATED, 559 registrar_.Remove(this, NotificationType::EXTENSION_HOST_CREATED,
556 NotificationService::AllSources()); 560 NotificationService::AllSources());
557 registrar_.Remove(this, NotificationType::EXTENSION_HOST_DESTROYED, 561 registrar_.Remove(this, NotificationType::EXTENSION_HOST_DESTROYED,
558 NotificationService::AllSources()); 562 NotificationService::AllSources());
563 registrar_.Remove(this, NotificationType::EXTENSION_PROCESS_CRASHED,
564 NotificationService::AllSources());
565 registrar_.Remove(this, NotificationType::EXTENSION_PROCESS_RESTORED,
566 NotificationService::AllSources());
559 567
560 // Delete all the resources. 568 // Delete all the resources.
561 STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end()); 569 STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end());
562 570
563 resources_.clear(); 571 resources_.clear();
564 pid_to_resources_.clear(); 572 pid_to_resources_.clear();
565 } 573 }
566 574
567 void TaskManagerExtensionProcessResourceProvider::Observe( 575 void TaskManagerExtensionProcessResourceProvider::Observe(
568 NotificationType type, 576 NotificationType type,
569 const NotificationSource& source, 577 const NotificationSource& source,
570 const NotificationDetails& details) { 578 const NotificationDetails& details) {
571 switch (type.value) { 579 switch (type.value) {
572 case NotificationType::EXTENSION_HOST_CREATED: 580 case NotificationType::EXTENSION_HOST_CREATED:
581 case NotificationType::EXTENSION_PROCESS_RESTORED:
573 AddToTaskManager(Details<ExtensionHost>(details).ptr()); 582 AddToTaskManager(Details<ExtensionHost>(details).ptr());
574 break; 583 break;
575 case NotificationType::EXTENSION_HOST_DESTROYED: 584 case NotificationType::EXTENSION_HOST_DESTROYED:
585 case NotificationType::EXTENSION_PROCESS_CRASHED:
576 RemoveFromTaskManager(Details<ExtensionHost>(details).ptr()); 586 RemoveFromTaskManager(Details<ExtensionHost>(details).ptr());
577 break; 587 break;
578 default: 588 default:
579 NOTREACHED() << "Unexpected notification."; 589 NOTREACHED() << "Unexpected notification.";
580 return; 590 return;
581 } 591 }
582 } 592 }
583 593
584 void TaskManagerExtensionProcessResourceProvider::AddToTaskManager( 594 void TaskManagerExtensionProcessResourceProvider::AddToTaskManager(
585 ExtensionHost* extension_host) { 595 ExtensionHost* extension_host) {
596 // Don't add dead extension processes.
597 if (!extension_host->IsViewLive())
598 return;
599
586 TaskManagerExtensionProcessResource* resource = 600 TaskManagerExtensionProcessResource* resource =
587 new TaskManagerExtensionProcessResource(extension_host); 601 new TaskManagerExtensionProcessResource(extension_host);
588 DCHECK(resources_.find(extension_host) == resources_.end()); 602 DCHECK(resources_.find(extension_host) == resources_.end());
589 resources_[extension_host] = resource; 603 resources_[extension_host] = resource;
590 pid_to_resources_[resource->process_id()] = resource; 604 pid_to_resources_[resource->process_id()] = resource;
591 task_manager_->AddResource(resource); 605 task_manager_->AddResource(resource);
592 } 606 }
593 607
594 void TaskManagerExtensionProcessResourceProvider::RemoveFromTaskManager( 608 void TaskManagerExtensionProcessResourceProvider::RemoveFromTaskManager(
595 ExtensionHost* extension_host) { 609 ExtensionHost* extension_host) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 707
694 return &resource_; 708 return &resource_;
695 } 709 }
696 710
697 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { 711 void TaskManagerBrowserProcessResourceProvider::StartUpdating() {
698 task_manager_->AddResource(&resource_); 712 task_manager_->AddResource(&resource_);
699 } 713 }
700 714
701 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { 715 void TaskManagerBrowserProcessResourceProvider::StopUpdating() {
702 } 716 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_view.cc ('k') | chrome/common/notification_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698