| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_TASK_MANAGER_INTERFACE_H_ | 5 #ifndef CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_INTERFACE_H_ |
| 6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_INTERFACE_H_ | 6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_INTERFACE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/memory_coordinator_client.h" | 15 #include "base/memory/memory_coordinator_client.h" |
| 16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "base/process/kill.h" | 17 #include "base/process/kill.h" |
| 18 #include "base/process/process_handle.h" | 18 #include "base/process/process_handle.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "base/timer/timer.h" | 20 #include "base/timer/timer.h" |
| 21 #include "chrome/browser/task_manager/providers/task.h" | 21 #include "chrome/browser/task_manager/providers/task.h" |
| 22 #include "chrome/browser/task_manager/sampling/task_manager_io_thread_helper.h" |
| 22 #include "chrome/browser/task_manager/task_manager_observer.h" | 23 #include "chrome/browser/task_manager/task_manager_observer.h" |
| 23 #include "third_party/WebKit/public/platform/WebCache.h" | 24 #include "third_party/WebKit/public/platform/WebCache.h" |
| 24 #include "ui/gfx/image/image_skia.h" | 25 #include "ui/gfx/image/image_skia.h" |
| 25 | 26 |
| 26 class PrefRegistrySimple; | 27 class PrefRegistrySimple; |
| 27 | 28 |
| 28 namespace content { | 29 namespace content { |
| 29 class WebContents; | 30 class WebContents; |
| 30 } // namespace content | 31 } // namespace content |
| 31 | 32 |
| 32 namespace net { | |
| 33 class URLRequest; | |
| 34 } // namespace net | |
| 35 | |
| 36 namespace task_manager { | 33 namespace task_manager { |
| 37 | 34 |
| 38 // Defines the interface for any implementation of the task manager. | 35 // Defines the interface for any implementation of the task manager. |
| 39 // Concrete implementations have no control over the refresh rate nor the | 36 // Concrete implementations have no control over the refresh rate nor the |
| 40 // enabled calculations of the usage of the various resources. | 37 // enabled calculations of the usage of the various resources. |
| 41 class TaskManagerInterface { | 38 class TaskManagerInterface { |
| 42 public: | 39 public: |
| 43 // Registers the task manager related prefs. | 40 // Registers the task manager related prefs. |
| 44 static void RegisterPrefs(PrefRegistrySimple* registry); | 41 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 45 | 42 |
| 46 // Returns true if the user is allowed to end processes. | 43 // Returns true if the user is allowed to end processes. |
| 47 static bool IsEndProcessEnabled(); | 44 static bool IsEndProcessEnabled(); |
| 48 | 45 |
| 49 // Gets the existing instance of the task manager if any, otherwise it will | 46 // Gets the existing instance of the task manager if any, otherwise it will |
| 50 // create it first. Must be called on the UI thread. | 47 // create it first. Must be called on the UI thread. |
| 51 static TaskManagerInterface* GetTaskManager(); | 48 static TaskManagerInterface* GetTaskManager(); |
| 52 | 49 |
| 53 // This notification will be received on the IO thread from | 50 // This notification will be received on the IO thread from |
| 54 // ChromeNetworkDelegate to update the task manager with read network usage. | 51 // ChromeNetworkDelegate to update the task manager with read network usage. |
| 55 static void OnRawBytesRead(const net::URLRequest& request, | 52 static void OnRawBytesTransferred(BytesTransferredKey key, |
| 56 int64_t bytes_read); | 53 int64_t bytes_read, |
| 57 | 54 int64_t bytes_sent); |
| 58 // This notification will be received on the IO thread from | |
| 59 // ChromeNetworkDelegate to update the task manager with sent network usage. | |
| 60 static void OnRawBytesSent(const net::URLRequest& request, | |
| 61 int64_t bytes_sent); | |
| 62 | 55 |
| 63 void AddObserver(TaskManagerObserver* observer); | 56 void AddObserver(TaskManagerObserver* observer); |
| 64 void RemoveObserver(TaskManagerObserver* observer); | 57 void RemoveObserver(TaskManagerObserver* observer); |
| 65 | 58 |
| 66 // Activates the task with |task_id| by bringing its container to the front if | 59 // Activates the task with |task_id| by bringing its container to the front if |
| 67 // possible. | 60 // possible. |
| 68 virtual void ActivateTask(TaskId task_id) = 0; | 61 virtual void ActivateTask(TaskId task_id) = 0; |
| 69 | 62 |
| 70 // Returns if the task is killable. | 63 // Returns if the task is killable. |
| 71 virtual bool IsTaskKillable(TaskId task_id) = 0; | 64 virtual bool IsTaskKillable(TaskId task_id) = 0; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 | 293 |
| 301 // The flags containing the enabled resources types calculations. | 294 // The flags containing the enabled resources types calculations. |
| 302 int64_t enabled_resources_flags_; | 295 int64_t enabled_resources_flags_; |
| 303 | 296 |
| 304 DISALLOW_COPY_AND_ASSIGN(TaskManagerInterface); | 297 DISALLOW_COPY_AND_ASSIGN(TaskManagerInterface); |
| 305 }; | 298 }; |
| 306 | 299 |
| 307 } // namespace task_manager | 300 } // namespace task_manager |
| 308 | 301 |
| 309 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_INTERFACE_H_ | 302 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_INTERFACE_H_ |
| OLD | NEW |