| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_TASK_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_TASK_MANAGER_H_ |
| 6 #define CHROME_BROWSER_TASK_MANAGER_H_ | 6 #define CHROME_BROWSER_TASK_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/lock.h" | 14 #include "base/lock.h" |
| 15 #include "base/process_util.h" | 15 #include "base/process_util.h" |
| 16 #include "base/ref_counted.h" | 16 #include "base/ref_counted.h" |
| 17 #include "base/singleton.h" | 17 #include "base/singleton.h" |
| 18 #include "base/timer.h" | 18 #include "base/timer.h" |
| 19 #include "chrome/browser/renderer_host/web_cache_manager.h" | 19 #include "chrome/browser/renderer_host/web_cache_manager.h" |
| 20 #include "chrome/browser/tab_contents/tab_contents.h" | 20 #include "chrome/browser/tab_contents/tab_contents.h" |
| 21 #include "net/url_request/url_request_job_tracker.h" | 21 #include "net/url_request/url_request_job_tracker.h" |
| 22 #include "testing/gtest/include/gtest/gtest_prod.h" | 22 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 23 | 23 |
| 24 class MessageLoop; | 24 class MessageLoop; |
| 25 class SkBitmap; | 25 class SkBitmap; |
| 26 class TaskManager; | 26 class TaskManager; |
| 27 class TaskManagerView; | |
| 28 class TaskManagerModel; | 27 class TaskManagerModel; |
| 29 | 28 |
| 30 struct BytesReadParam; | 29 struct BytesReadParam; |
| 31 | 30 |
| 32 namespace base { | 31 namespace base { |
| 33 class ProcessMetrics; | 32 class ProcessMetrics; |
| 34 } | 33 } |
| 35 | 34 |
| 36 // This class is a singleton. | 35 // This class is a singleton. |
| 37 class TaskManager { | 36 class TaskManager { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // the resource does not belong to this provider. | 81 // the resource does not belong to this provider. |
| 83 virtual TaskManager::Resource* GetResource(int process_id, | 82 virtual TaskManager::Resource* GetResource(int process_id, |
| 84 int render_process_host_id, | 83 int render_process_host_id, |
| 85 int routing_id) = 0; | 84 int routing_id) = 0; |
| 86 virtual void StartUpdating() = 0; | 85 virtual void StartUpdating() = 0; |
| 87 virtual void StopUpdating() = 0; | 86 virtual void StopUpdating() = 0; |
| 88 }; | 87 }; |
| 89 | 88 |
| 90 static void RegisterPrefs(PrefService* prefs); | 89 static void RegisterPrefs(PrefService* prefs); |
| 91 | 90 |
| 92 // Call this method to show the Task Manager. | 91 // Returns true if the process at the specified index is the browser process. |
| 93 // Only one instance of Task Manager is created, so if the Task Manager has | 92 bool IsBrowserProcess(int index) const; |
| 94 // already be opened, it is reopened. If it is currently opened, then it is | |
| 95 // moved to the front. | |
| 96 static void Open(); | |
| 97 | 93 |
| 98 // Close the task manager if it's currently opened. | 94 // Terminates the process at the specified index. |
| 99 static void Close(); | 95 void KillProcess(int index); |
| 100 | 96 |
| 101 // Returns true if the current selection includes the browser process. | 97 // Activates the browser tab associated with the process in the specified |
| 102 bool BrowserProcessIsSelected(); | 98 // index. |
| 103 | 99 void ActivateProcess(int index); |
| 104 // Terminates the selected tab(s) in the list. | |
| 105 void KillSelectedProcesses(); | |
| 106 | |
| 107 // Activates the browser tab associated with the focused row in the task | |
| 108 // manager table. This happens when the user double clicks or hits return. | |
| 109 void ActivateFocusedTab(); | |
| 110 | 100 |
| 111 void AddResourceProvider(ResourceProvider* provider); | 101 void AddResourceProvider(ResourceProvider* provider); |
| 112 void RemoveResourceProvider(ResourceProvider* provider); | 102 void RemoveResourceProvider(ResourceProvider* provider); |
| 113 | 103 |
| 114 // These methods are invoked by the resource providers to add/remove resources | 104 // These methods are invoked by the resource providers to add/remove resources |
| 115 // to the Task Manager. Note that the resources are owned by the | 105 // to the Task Manager. Note that the resources are owned by the |
| 116 // ResourceProviders and are not valid after StopUpdating() has been called | 106 // ResourceProviders and are not valid after StopUpdating() has been called |
| 117 // on the ResourceProviders. | 107 // on the ResourceProviders. |
| 118 void AddResource(Resource* resource); | 108 void AddResource(Resource* resource); |
| 119 void RemoveResource(Resource* resource); | 109 void RemoveResource(Resource* resource); |
| 120 | 110 |
| 121 void OnWindowClosed(); | 111 void OnWindowClosed(); |
| 122 | 112 |
| 113 // Returns the singleton instance (and initializes it if necessary). |
| 114 static TaskManager* GetInstance(); |
| 115 |
| 116 TaskManagerModel* model() const { return model_.get(); } |
| 117 |
| 123 private: | 118 private: |
| 124 FRIEND_TEST(TaskManagerTest, Basic); | 119 FRIEND_TEST(TaskManagerTest, Basic); |
| 125 FRIEND_TEST(TaskManagerTest, Resources); | 120 FRIEND_TEST(TaskManagerTest, Resources); |
| 126 | 121 |
| 127 // Obtain an instance via GetInstance(). | 122 // Obtain an instance via GetInstance(). |
| 128 TaskManager(); | 123 TaskManager(); |
| 129 friend struct DefaultSingletonTraits<TaskManager>; | 124 friend struct DefaultSingletonTraits<TaskManager>; |
| 130 | 125 |
| 131 ~TaskManager(); | 126 ~TaskManager(); |
| 132 | 127 |
| 133 void CreateView(); | |
| 134 | |
| 135 // Returns the singleton instance (and initializes it if necessary). | |
| 136 static TaskManager* GetInstance(); | |
| 137 | |
| 138 // The model used for gathering and processing task data. It is ref counted | 128 // The model used for gathering and processing task data. It is ref counted |
| 139 // because it is passed as a parameter to MessageLoop::InvokeLater(). | 129 // because it is passed as a parameter to MessageLoop::InvokeLater(). |
| 140 scoped_refptr<TaskManagerModel> model_; | 130 scoped_refptr<TaskManagerModel> model_; |
| 141 | 131 |
| 142 // A container containing the buttons and table. | |
| 143 TaskManagerView* view_; | |
| 144 | |
| 145 DISALLOW_COPY_AND_ASSIGN(TaskManager); | 132 DISALLOW_COPY_AND_ASSIGN(TaskManager); |
| 146 }; | 133 }; |
| 147 | 134 |
| 148 class TaskManagerModelObserver { | 135 class TaskManagerModelObserver { |
| 149 public: | 136 public: |
| 150 virtual ~TaskManagerModelObserver() {} | 137 virtual ~TaskManagerModelObserver() {} |
| 151 | 138 |
| 152 // Invoked when the model has been completely changed. | 139 // Invoked when the model has been completely changed. |
| 153 virtual void OnModelChanged() = 0; | 140 virtual void OnModelChanged() = 0; |
| 154 | 141 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 328 |
| 342 // Whether we are currently in the process of updating. | 329 // Whether we are currently in the process of updating. |
| 343 UpdateState update_state_; | 330 UpdateState update_state_; |
| 344 | 331 |
| 345 // See design doc at http://go/at-teleporter for more information. | 332 // See design doc at http://go/at-teleporter for more information. |
| 346 static int goats_teleported_; | 333 static int goats_teleported_; |
| 347 | 334 |
| 348 DISALLOW_COPY_AND_ASSIGN(TaskManagerModel); | 335 DISALLOW_COPY_AND_ASSIGN(TaskManagerModel); |
| 349 }; | 336 }; |
| 350 | 337 |
| 351 class TaskManagerView { | |
| 352 public: | |
| 353 virtual ~TaskManagerView() {} | |
| 354 | |
| 355 virtual void GetSelection(std::vector<int>* selection) = 0; | |
| 356 virtual void GetFocused(std::vector<int>* focused) = 0; | |
| 357 | |
| 358 virtual void OpenWindow() = 0; | |
| 359 virtual void ActivateWindow() = 0; | |
| 360 virtual void CloseWindow() = 0; | |
| 361 }; | |
| 362 | |
| 363 #endif // CHROME_BROWSER_TASK_MANAGER_H_ | 338 #endif // CHROME_BROWSER_TASK_MANAGER_H_ |
| OLD | NEW |