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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/task_manager_resource_providers.h" 5 #include "chrome/browser/task_manager/task_manager_resource_providers.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/file_version_info.h" 8 #include "base/file_version_info.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
11 #include "base/stl_util-inl.h" 11 #include "base/stl_util-inl.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "chrome/app/chrome_command_ids.h" 16 #include "chrome/app/chrome_command_ids.h"
17 #include "chrome/browser/background/background_contents_service.h" 17 #include "chrome/browser/background/background_contents_service.h"
18 #include "chrome/browser/background/background_contents_service_factory.h" 18 #include "chrome/browser/background/background_contents_service_factory.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/extensions/extension_host.h" 20 #include "chrome/browser/extensions/extension_host.h"
21 #include "chrome/browser/extensions/extension_process_manager.h" 21 #include "chrome/browser/extensions/extension_process_manager.h"
22 #include "chrome/browser/extensions/extension_service.h" 22 #include "chrome/browser/extensions/extension_service.h"
23 #include "chrome/browser/favicon/favicon_tab_helper.h" 23 #include "chrome/browser/favicon/favicon_tab_helper.h"
24 #include "chrome/browser/prerender/prerender_manager.h" 24 #include "chrome/browser/prerender/prerender_manager.h"
25 #include "chrome/browser/profiles/profile_manager.h" 25 #include "chrome/browser/profiles/profile_manager.h"
26 #include "chrome/browser/tab_contents/background_contents.h" 26 #include "chrome/browser/tab_contents/background_contents.h"
27 #include "chrome/browser/tab_contents/tab_util.h" 27 #include "chrome/browser/tab_contents/tab_util.h"
28 #include "chrome/browser/ui/browser_list.h" 28 #include "chrome/browser/ui/browser_list.h"
29 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 29 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
30 #include "chrome/common/chrome_notification_types.h"
30 #include "chrome/common/chrome_switches.h" 31 #include "chrome/common/chrome_switches.h"
31 #include "chrome/common/extensions/extension.h" 32 #include "chrome/common/extensions/extension.h"
32 #include "chrome/common/render_messages.h" 33 #include "chrome/common/render_messages.h"
33 #include "content/browser/browser_child_process_host.h" 34 #include "content/browser/browser_child_process_host.h"
34 #include "content/browser/browser_thread.h" 35 #include "content/browser/browser_thread.h"
35 #include "content/browser/renderer_host/render_message_filter.h" 36 #include "content/browser/renderer_host/render_message_filter.h"
36 #include "content/browser/renderer_host/render_process_host.h" 37 #include "content/browser/renderer_host/render_process_host.h"
37 #include "content/browser/renderer_host/render_view_host.h" 38 #include "content/browser/renderer_host/render_view_host.h"
38 #include "content/browser/tab_contents/tab_contents.h" 39 #include "content/browser/tab_contents/tab_contents.h"
39 #include "content/common/notification_service.h" 40 #include "content/common/notification_service.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 319
319 void TaskManagerTabContentsResourceProvider::StartUpdating() { 320 void TaskManagerTabContentsResourceProvider::StartUpdating() {
320 DCHECK(!updating_); 321 DCHECK(!updating_);
321 updating_ = true; 322 updating_ = true;
322 323
323 // Add all the existing TabContents. 324 // Add all the existing TabContents.
324 for (TabContentsIterator iterator; !iterator.done(); ++iterator) 325 for (TabContentsIterator iterator; !iterator.done(); ++iterator)
325 Add(*iterator); 326 Add(*iterator);
326 327
327 // Then we register for notifications to get new tabs. 328 // Then we register for notifications to get new tabs.
328 registrar_.Add(this, NotificationType::TAB_CONTENTS_CONNECTED, 329 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_CONNECTED,
329 NotificationService::AllSources()); 330 NotificationService::AllSources());
330 registrar_.Add(this, NotificationType::TAB_CONTENTS_SWAPPED, 331 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_SWAPPED,
331 NotificationService::AllSources()); 332 NotificationService::AllSources());
332 registrar_.Add(this, NotificationType::TAB_CONTENTS_DISCONNECTED, 333 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED,
333 NotificationService::AllSources()); 334 NotificationService::AllSources());
334 // TAB_CONTENTS_DISCONNECTED should be enough to know when to remove a 335 // TAB_CONTENTS_DISCONNECTED should be enough to know when to remove a
335 // resource. This is an attempt at mitigating a crasher that seem to 336 // resource. This is an attempt at mitigating a crasher that seem to
336 // indicate a resource is still referencing a deleted TabContents 337 // indicate a resource is still referencing a deleted TabContents
337 // (http://crbug.com/7321). 338 // (http://crbug.com/7321).
338 registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED, 339 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
339 NotificationService::AllSources()); 340 NotificationService::AllSources());
340 } 341 }
341 342
342 void TaskManagerTabContentsResourceProvider::StopUpdating() { 343 void TaskManagerTabContentsResourceProvider::StopUpdating() {
343 DCHECK(updating_); 344 DCHECK(updating_);
344 updating_ = false; 345 updating_ = false;
345 346
346 // Then we unregister for notifications to get new tabs. 347 // Then we unregister for notifications to get new tabs.
347 registrar_.Remove(this, NotificationType::TAB_CONTENTS_CONNECTED, 348 registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_CONNECTED,
348 NotificationService::AllSources()); 349 NotificationService::AllSources());
349 registrar_.Remove(this, NotificationType::TAB_CONTENTS_SWAPPED, 350 registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_SWAPPED,
350 NotificationService::AllSources()); 351 NotificationService::AllSources());
351 registrar_.Remove(this, NotificationType::TAB_CONTENTS_DISCONNECTED, 352 registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED,
352 NotificationService::AllSources()); 353 NotificationService::AllSources());
353 registrar_.Remove(this, NotificationType::TAB_CONTENTS_DESTROYED, 354 registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
354 NotificationService::AllSources()); 355 NotificationService::AllSources());
355 356
356 // Delete all the resources. 357 // Delete all the resources.
357 STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end()); 358 STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end());
358 359
359 resources_.clear(); 360 resources_.clear();
360 } 361 }
361 362
362 void TaskManagerTabContentsResourceProvider::AddToTaskManager( 363 void TaskManagerTabContentsResourceProvider::AddToTaskManager(
363 TabContentsWrapper* tab_contents) { 364 TabContentsWrapper* tab_contents) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 407
407 // Remove the resource from the Task Manager. 408 // Remove the resource from the Task Manager.
408 TaskManagerTabContentsResource* resource = iter->second; 409 TaskManagerTabContentsResource* resource = iter->second;
409 task_manager_->RemoveResource(resource); 410 task_manager_->RemoveResource(resource);
410 // And from the provider. 411 // And from the provider.
411 resources_.erase(iter); 412 resources_.erase(iter);
412 // Finally, delete the resource. 413 // Finally, delete the resource.
413 delete resource; 414 delete resource;
414 } 415 }
415 416
416 void TaskManagerTabContentsResourceProvider::Observe(NotificationType type, 417 void TaskManagerTabContentsResourceProvider::Observe(int type,
417 const NotificationSource& source, 418 const NotificationSource& source,
418 const NotificationDetails& details) { 419 const NotificationDetails& details) {
419 TabContentsWrapper* tab_contents = 420 TabContentsWrapper* tab_contents =
420 TabContentsWrapper::GetCurrentWrapperForContents( 421 TabContentsWrapper::GetCurrentWrapperForContents(
421 Source<TabContents>(source).ptr()); 422 Source<TabContents>(source).ptr());
422 // A background page does not have a TabContentsWrapper. 423 // A background page does not have a TabContentsWrapper.
423 if (!tab_contents) 424 if (!tab_contents)
424 return; 425 return;
425 switch (type.value) { 426 switch (type) {
426 case NotificationType::TAB_CONTENTS_CONNECTED: 427 case content::NOTIFICATION_TAB_CONTENTS_CONNECTED:
427 Add(tab_contents); 428 Add(tab_contents);
428 break; 429 break;
429 case NotificationType::TAB_CONTENTS_SWAPPED: 430 case content::NOTIFICATION_TAB_CONTENTS_SWAPPED:
430 Remove(tab_contents); 431 Remove(tab_contents);
431 Add(tab_contents); 432 Add(tab_contents);
432 break; 433 break;
433 case NotificationType::TAB_CONTENTS_DESTROYED: 434 case content::NOTIFICATION_TAB_CONTENTS_DESTROYED:
434 // If this DCHECK is triggered, it could explain http://crbug.com/7321 . 435 // If this DCHECK is triggered, it could explain http://crbug.com/7321 .
435 DCHECK(resources_.find(tab_contents) == 436 DCHECK(resources_.find(tab_contents) ==
436 resources_.end()) << "TAB_CONTENTS_DESTROYED with no associated " 437 resources_.end()) << "TAB_CONTENTS_DESTROYED with no associated "
437 "TAB_CONTENTS_DISCONNECTED"; 438 "TAB_CONTENTS_DISCONNECTED";
438 // Fall through. 439 // Fall through.
439 case NotificationType::TAB_CONTENTS_DISCONNECTED: 440 case content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED:
440 Remove(tab_contents); 441 Remove(tab_contents);
441 break; 442 break;
442 default: 443 default:
443 NOTREACHED() << "Unexpected notification."; 444 NOTREACHED() << "Unexpected notification.";
444 return; 445 return;
445 } 446 }
446 } 447 }
447 448
448 //////////////////////////////////////////////////////////////////////////////// 449 ////////////////////////////////////////////////////////////////////////////////
449 // TaskManagerBackgroundContentsResource class 450 // TaskManagerBackgroundContentsResource class
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 const Extension* extension = extensions_service->GetExtensionById( 559 const Extension* extension = extensions_service->GetExtensionById(
559 UTF16ToUTF8(application_id), false); 560 UTF16ToUTF8(application_id), false);
560 if (extension) 561 if (extension)
561 application_name = UTF8ToUTF16(extension->name()); 562 application_name = UTF8ToUTF16(extension->name());
562 } 563 }
563 Add(*iterator, application_name); 564 Add(*iterator, application_name);
564 } 565 }
565 } 566 }
566 567
567 // Then we register for notifications to get new BackgroundContents. 568 // Then we register for notifications to get new BackgroundContents.
568 registrar_.Add(this, NotificationType::BACKGROUND_CONTENTS_OPENED, 569 registrar_.Add(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_OPENED,
569 NotificationService::AllSources()); 570 NotificationService::AllSources());
570 registrar_.Add(this, NotificationType::BACKGROUND_CONTENTS_NAVIGATED, 571 registrar_.Add(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED,
571 NotificationService::AllSources()); 572 NotificationService::AllSources());
572 registrar_.Add(this, NotificationType::BACKGROUND_CONTENTS_DELETED, 573 registrar_.Add(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED,
573 NotificationService::AllSources()); 574 NotificationService::AllSources());
574 } 575 }
575 576
576 void TaskManagerBackgroundContentsResourceProvider::StopUpdating() { 577 void TaskManagerBackgroundContentsResourceProvider::StopUpdating() {
577 DCHECK(updating_); 578 DCHECK(updating_);
578 updating_ = false; 579 updating_ = false;
579 580
580 // Unregister for notifications 581 // Unregister for notifications
581 registrar_.Remove(this, NotificationType::BACKGROUND_CONTENTS_OPENED, 582 registrar_.Remove(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_OPENED,
582 NotificationService::AllSources()); 583 NotificationService::AllSources());
583 registrar_.Remove(this, NotificationType::BACKGROUND_CONTENTS_NAVIGATED, 584 registrar_.Remove(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED,
584 NotificationService::AllSources()); 585 NotificationService::AllSources());
585 registrar_.Remove(this, NotificationType::BACKGROUND_CONTENTS_DELETED, 586 registrar_.Remove(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED,
586 NotificationService::AllSources()); 587 NotificationService::AllSources());
587 588
588 // Delete all the resources. 589 // Delete all the resources.
589 STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end()); 590 STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end());
590 591
591 resources_.clear(); 592 resources_.clear();
592 } 593 }
593 594
594 void TaskManagerBackgroundContentsResourceProvider::AddToTaskManager( 595 void TaskManagerBackgroundContentsResourceProvider::AddToTaskManager(
595 BackgroundContents* background_contents, 596 BackgroundContents* background_contents,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 // Remove the resource from the Task Manager. 628 // Remove the resource from the Task Manager.
628 TaskManagerBackgroundContentsResource* resource = iter->second; 629 TaskManagerBackgroundContentsResource* resource = iter->second;
629 task_manager_->RemoveResource(resource); 630 task_manager_->RemoveResource(resource);
630 // And from the provider. 631 // And from the provider.
631 resources_.erase(iter); 632 resources_.erase(iter);
632 // Finally, delete the resource. 633 // Finally, delete the resource.
633 delete resource; 634 delete resource;
634 } 635 }
635 636
636 void TaskManagerBackgroundContentsResourceProvider::Observe( 637 void TaskManagerBackgroundContentsResourceProvider::Observe(
637 NotificationType type, 638 int type,
638 const NotificationSource& source, 639 const NotificationSource& source,
639 const NotificationDetails& details) { 640 const NotificationDetails& details) {
640 switch (type.value) { 641 switch (type) {
641 case NotificationType::BACKGROUND_CONTENTS_OPENED: { 642 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_OPENED: {
642 // Get the name from the parent application. If no parent application is 643 // Get the name from the parent application. If no parent application is
643 // found, just pass an empty string - BackgroundContentsResource::GetTitle 644 // found, just pass an empty string - BackgroundContentsResource::GetTitle
644 // will display the URL instead in this case. This should never happen 645 // will display the URL instead in this case. This should never happen
645 // except in rare cases when an extension is being unloaded or chrome is 646 // except in rare cases when an extension is being unloaded or chrome is
646 // exiting while the task manager is displayed. 647 // exiting while the task manager is displayed.
647 string16 application_name; 648 string16 application_name;
648 ExtensionService* service = 649 ExtensionService* service =
649 Source<Profile>(source)->GetExtensionService(); 650 Source<Profile>(source)->GetExtensionService();
650 if (service) { 651 if (service) {
651 std::string application_id = UTF16ToUTF8( 652 std::string application_id = UTF16ToUTF8(
652 Details<BackgroundContentsOpenedDetails>(details)->application_id); 653 Details<BackgroundContentsOpenedDetails>(details)->application_id);
653 const Extension* extension = 654 const Extension* extension =
654 service->GetExtensionById(application_id, false); 655 service->GetExtensionById(application_id, false);
655 // Extension can be NULL when running unit tests. 656 // Extension can be NULL when running unit tests.
656 if (extension) 657 if (extension)
657 application_name = UTF8ToUTF16(extension->name()); 658 application_name = UTF8ToUTF16(extension->name());
658 } 659 }
659 Add(Details<BackgroundContentsOpenedDetails>(details)->contents, 660 Add(Details<BackgroundContentsOpenedDetails>(details)->contents,
660 application_name); 661 application_name);
661 // Opening a new BackgroundContents needs to force the display to refresh 662 // Opening a new BackgroundContents needs to force the display to refresh
662 // (applications may now be considered "background" that weren't before). 663 // (applications may now be considered "background" that weren't before).
663 task_manager_->ModelChanged(); 664 task_manager_->ModelChanged();
664 break; 665 break;
665 } 666 }
666 case NotificationType::BACKGROUND_CONTENTS_NAVIGATED: { 667 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED: {
667 BackgroundContents* contents = Details<BackgroundContents>(details).ptr(); 668 BackgroundContents* contents = Details<BackgroundContents>(details).ptr();
668 // Should never get a NAVIGATED before OPENED. 669 // Should never get a NAVIGATED before OPENED.
669 DCHECK(resources_.find(contents) != resources_.end()); 670 DCHECK(resources_.find(contents) != resources_.end());
670 // Preserve the application name. 671 // Preserve the application name.
671 string16 application_name( 672 string16 application_name(
672 resources_.find(contents)->second->application_name()); 673 resources_.find(contents)->second->application_name());
673 Remove(contents); 674 Remove(contents);
674 Add(contents, application_name); 675 Add(contents, application_name);
675 break; 676 break;
676 } 677 }
677 case NotificationType::BACKGROUND_CONTENTS_DELETED: 678 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED:
678 Remove(Details<BackgroundContents>(details).ptr()); 679 Remove(Details<BackgroundContents>(details).ptr());
679 // Closing a BackgroundContents needs to force the display to refresh 680 // Closing a BackgroundContents needs to force the display to refresh
680 // (applications may now be considered "foreground" that weren't before). 681 // (applications may now be considered "foreground" that weren't before).
681 task_manager_->ModelChanged(); 682 task_manager_->ModelChanged();
682 break; 683 break;
683 default: 684 default:
684 NOTREACHED() << "Unexpected notification."; 685 NOTREACHED() << "Unexpected notification.";
685 return; 686 return;
686 } 687 }
687 } 688 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 return iter->second; 843 return iter->second;
843 else 844 else
844 return NULL; 845 return NULL;
845 } 846 }
846 847
847 void TaskManagerChildProcessResourceProvider::StartUpdating() { 848 void TaskManagerChildProcessResourceProvider::StartUpdating() {
848 DCHECK(!updating_); 849 DCHECK(!updating_);
849 updating_ = true; 850 updating_ = true;
850 851
851 // Register for notifications to get new child processes. 852 // Register for notifications to get new child processes.
852 registrar_.Add(this, NotificationType::CHILD_PROCESS_HOST_CONNECTED, 853 registrar_.Add(this, content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED,
853 NotificationService::AllSources()); 854 NotificationService::AllSources());
854 registrar_.Add(this, NotificationType::CHILD_PROCESS_HOST_DISCONNECTED, 855 registrar_.Add(this, content::NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED,
855 NotificationService::AllSources()); 856 NotificationService::AllSources());
856 857
857 // Get the existing child processes. 858 // Get the existing child processes.
858 BrowserThread::PostTask( 859 BrowserThread::PostTask(
859 BrowserThread::IO, FROM_HERE, 860 BrowserThread::IO, FROM_HERE,
860 NewRunnableMethod( 861 NewRunnableMethod(
861 this, 862 this,
862 &TaskManagerChildProcessResourceProvider::RetrieveChildProcessInfo)); 863 &TaskManagerChildProcessResourceProvider::RetrieveChildProcessInfo));
863 } 864 }
864 865
865 void TaskManagerChildProcessResourceProvider::StopUpdating() { 866 void TaskManagerChildProcessResourceProvider::StopUpdating() {
866 DCHECK(updating_); 867 DCHECK(updating_);
867 updating_ = false; 868 updating_ = false;
868 869
869 // Unregister for notifications to get new plugin processes. 870 // Unregister for notifications to get new plugin processes.
870 registrar_.Remove(this, NotificationType::CHILD_PROCESS_HOST_CONNECTED, 871 registrar_.Remove(this, content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED,
871 NotificationService::AllSources()); 872 NotificationService::AllSources());
872 registrar_.Remove(this, 873 registrar_.Remove(this,
873 NotificationType::CHILD_PROCESS_HOST_DISCONNECTED, 874 content::NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED,
874 NotificationService::AllSources()); 875 NotificationService::AllSources());
875 876
876 // Delete all the resources. 877 // Delete all the resources.
877 STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end()); 878 STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end());
878 879
879 resources_.clear(); 880 resources_.clear();
880 pid_to_resources_.clear(); 881 pid_to_resources_.clear();
881 existing_child_process_info_.clear(); 882 existing_child_process_info_.clear();
882 } 883 }
883 884
884 void TaskManagerChildProcessResourceProvider::Observe( 885 void TaskManagerChildProcessResourceProvider::Observe(
885 NotificationType type, 886 int type,
886 const NotificationSource& source, 887 const NotificationSource& source,
887 const NotificationDetails& details) { 888 const NotificationDetails& details) {
888 switch (type.value) { 889 switch (type) {
889 case NotificationType::CHILD_PROCESS_HOST_CONNECTED: 890 case content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED:
890 Add(*Details<ChildProcessInfo>(details).ptr()); 891 Add(*Details<ChildProcessInfo>(details).ptr());
891 break; 892 break;
892 case NotificationType::CHILD_PROCESS_HOST_DISCONNECTED: 893 case content::NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED:
893 Remove(*Details<ChildProcessInfo>(details).ptr()); 894 Remove(*Details<ChildProcessInfo>(details).ptr());
894 break; 895 break;
895 default: 896 default:
896 NOTREACHED() << "Unexpected notification."; 897 NOTREACHED() << "Unexpected notification.";
897 return; 898 return;
898 } 899 }
899 } 900 }
900 901
901 void TaskManagerChildProcessResourceProvider::Add( 902 void TaskManagerChildProcessResourceProvider::Add(
902 const ChildProcessInfo& child_process_info) { 903 const ChildProcessInfo& child_process_info) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 profiles[i]->GetOffTheRecordProfile()->GetExtensionProcessManager(); 1086 profiles[i]->GetOffTheRecordProfile()->GetExtensionProcessManager();
1086 if (process_manager) { 1087 if (process_manager) {
1087 ExtensionProcessManager::const_iterator jt; 1088 ExtensionProcessManager::const_iterator jt;
1088 for (jt = process_manager->begin(); jt != process_manager->end(); ++jt) 1089 for (jt = process_manager->begin(); jt != process_manager->end(); ++jt)
1089 AddToTaskManager(*jt); 1090 AddToTaskManager(*jt);
1090 } 1091 }
1091 } 1092 }
1092 } 1093 }
1093 1094
1094 // Register for notifications about extension process changes. 1095 // Register for notifications about extension process changes.
1095 registrar_.Add(this, NotificationType::EXTENSION_PROCESS_CREATED, 1096 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_CREATED,
1096 NotificationService::AllSources()); 1097 NotificationService::AllSources());
1097 registrar_.Add(this, NotificationType::EXTENSION_PROCESS_TERMINATED, 1098 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED,
1098 NotificationService::AllSources()); 1099 NotificationService::AllSources());
1099 registrar_.Add(this, NotificationType::EXTENSION_HOST_DESTROYED, 1100 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
1100 NotificationService::AllSources()); 1101 NotificationService::AllSources());
1101 } 1102 }
1102 1103
1103 void TaskManagerExtensionProcessResourceProvider::StopUpdating() { 1104 void TaskManagerExtensionProcessResourceProvider::StopUpdating() {
1104 DCHECK(updating_); 1105 DCHECK(updating_);
1105 updating_ = false; 1106 updating_ = false;
1106 1107
1107 // Unregister for notifications about extension process changes. 1108 // Unregister for notifications about extension process changes.
1108 registrar_.Remove(this, NotificationType::EXTENSION_PROCESS_CREATED, 1109 registrar_.Remove(this, chrome::NOTIFICATION_EXTENSION_PROCESS_CREATED,
1109 NotificationService::AllSources()); 1110 NotificationService::AllSources());
1110 registrar_.Remove(this, NotificationType::EXTENSION_PROCESS_TERMINATED, 1111 registrar_.Remove(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED,
1111 NotificationService::AllSources()); 1112 NotificationService::AllSources());
1112 registrar_.Remove(this, NotificationType::EXTENSION_HOST_DESTROYED, 1113 registrar_.Remove(this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
1113 NotificationService::AllSources()); 1114 NotificationService::AllSources());
1114 1115
1115 // Delete all the resources. 1116 // Delete all the resources.
1116 STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end()); 1117 STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end());
1117 1118
1118 resources_.clear(); 1119 resources_.clear();
1119 pid_to_resources_.clear(); 1120 pid_to_resources_.clear();
1120 } 1121 }
1121 1122
1122 void TaskManagerExtensionProcessResourceProvider::Observe( 1123 void TaskManagerExtensionProcessResourceProvider::Observe(
1123 NotificationType type, 1124 int type,
1124 const NotificationSource& source, 1125 const NotificationSource& source,
1125 const NotificationDetails& details) { 1126 const NotificationDetails& details) {
1126 switch (type.value) { 1127 switch (type) {
1127 case NotificationType::EXTENSION_PROCESS_CREATED: 1128 case chrome::NOTIFICATION_EXTENSION_PROCESS_CREATED:
1128 AddToTaskManager(Details<ExtensionHost>(details).ptr()); 1129 AddToTaskManager(Details<ExtensionHost>(details).ptr());
1129 break; 1130 break;
1130 case NotificationType::EXTENSION_PROCESS_TERMINATED: 1131 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED:
1131 case NotificationType::EXTENSION_HOST_DESTROYED: 1132 case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED:
1132 RemoveFromTaskManager(Details<ExtensionHost>(details).ptr()); 1133 RemoveFromTaskManager(Details<ExtensionHost>(details).ptr());
1133 break; 1134 break;
1134 default: 1135 default:
1135 NOTREACHED() << "Unexpected notification."; 1136 NOTREACHED() << "Unexpected notification.";
1136 return; 1137 return;
1137 } 1138 }
1138 } 1139 }
1139 1140
1140 void TaskManagerExtensionProcessResourceProvider::AddToTaskManager( 1141 void TaskManagerExtensionProcessResourceProvider::AddToTaskManager(
1141 ExtensionHost* extension_host) { 1142 ExtensionHost* extension_host) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 1307
1307 return &resource_; 1308 return &resource_;
1308 } 1309 }
1309 1310
1310 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { 1311 void TaskManagerBrowserProcessResourceProvider::StartUpdating() {
1311 task_manager_->AddResource(&resource_); 1312 task_manager_->AddResource(&resource_);
1312 } 1313 }
1313 1314
1314 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { 1315 void TaskManagerBrowserProcessResourceProvider::StopUpdating() {
1315 } 1316 }
OLDNEW
« no previous file with comments | « chrome/browser/task_manager/task_manager_resource_providers.h ('k') | chrome/browser/themes/theme_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698