| 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 "chrome/browser/task_manager/task_manager_resource_providers.h" | 5 #include "chrome/browser/task_manager/task_manager_resource_providers.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 return i->second; | 617 return i->second; |
| 618 } | 618 } |
| 619 } | 619 } |
| 620 | 620 |
| 621 // Can happen if the panel went away while a network request was being | 621 // Can happen if the panel went away while a network request was being |
| 622 // performed. | 622 // performed. |
| 623 return NULL; | 623 return NULL; |
| 624 } | 624 } |
| 625 | 625 |
| 626 void TaskManagerPanelResourceProvider::StartUpdating() { | 626 void TaskManagerPanelResourceProvider::StartUpdating() { |
| 627 if (!PanelManager::UseBrowserlessPanels()) | |
| 628 return; | |
| 629 | |
| 630 DCHECK(!updating_); | 627 DCHECK(!updating_); |
| 631 updating_ = true; | 628 updating_ = true; |
| 632 | 629 |
| 633 // Add all the Panels. | 630 // Add all the Panels. |
| 634 std::vector<Panel*> panels = PanelManager::GetInstance()->panels(); | 631 std::vector<Panel*> panels = PanelManager::GetInstance()->panels(); |
| 635 for (size_t i = 0; i < panels.size(); ++i) | 632 for (size_t i = 0; i < panels.size(); ++i) |
| 636 Add(panels[i]); | 633 Add(panels[i]); |
| 637 | 634 |
| 638 // Then we register for notifications to get new and remove closed panels. | 635 // Then we register for notifications to get new and remove closed panels. |
| 639 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, | 636 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, |
| 640 content::NotificationService::AllSources()); | 637 content::NotificationService::AllSources()); |
| 641 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, | 638 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, |
| 642 content::NotificationService::AllSources()); | 639 content::NotificationService::AllSources()); |
| 643 } | 640 } |
| 644 | 641 |
| 645 void TaskManagerPanelResourceProvider::StopUpdating() { | 642 void TaskManagerPanelResourceProvider::StopUpdating() { |
| 646 if (!PanelManager::UseBrowserlessPanels()) | |
| 647 return; | |
| 648 | |
| 649 DCHECK(updating_); | 643 DCHECK(updating_); |
| 650 updating_ = false; | 644 updating_ = false; |
| 651 | 645 |
| 652 // Unregister for notifications about new/removed panels. | 646 // Unregister for notifications about new/removed panels. |
| 653 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, | 647 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, |
| 654 content::NotificationService::AllSources()); | 648 content::NotificationService::AllSources()); |
| 655 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, | 649 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, |
| 656 content::NotificationService::AllSources()); | 650 content::NotificationService::AllSources()); |
| 657 | 651 |
| 658 // Delete all the resources. | 652 // Delete all the resources. |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1692 | 1686 |
| 1693 return &resource_; | 1687 return &resource_; |
| 1694 } | 1688 } |
| 1695 | 1689 |
| 1696 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { | 1690 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { |
| 1697 task_manager_->AddResource(&resource_); | 1691 task_manager_->AddResource(&resource_); |
| 1698 } | 1692 } |
| 1699 | 1693 |
| 1700 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { | 1694 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { |
| 1701 } | 1695 } |
| OLD | NEW |