| 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_MANAGEMENT_TASK_MANAGER_INTERFACE_H_ | 5 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_INTERFACE_H_ | 
| 6 #define CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_INTERFACE_H_ | 6 #define CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_INTERFACE_H_ | 
| 7 | 7 | 
|  | 8 #include <stddef.h> | 
| 8 #include <stdint.h> | 9 #include <stdint.h> | 
| 9 | 10 | 
|  | 11 #include "base/macros.h" | 
| 10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" | 
| 11 #include "base/observer_list.h" | 13 #include "base/observer_list.h" | 
| 12 #include "base/process/process_handle.h" | 14 #include "base/process/process_handle.h" | 
| 13 #include "base/time/time.h" | 15 #include "base/time/time.h" | 
| 14 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" | 
| 15 #include "chrome/browser/task_management/providers/task.h" | 17 #include "chrome/browser/task_management/providers/task.h" | 
| 16 #include "chrome/browser/task_management/task_manager_observer.h" | 18 #include "chrome/browser/task_management/task_manager_observer.h" | 
| 17 #include "third_party/WebKit/public/web/WebCache.h" | 19 #include "third_party/WebKit/public/web/WebCache.h" | 
| 18 #include "ui/gfx/image/image_skia.h" | 20 #include "ui/gfx/image/image_skia.h" | 
| 19 | 21 | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
| 44   // possible. | 46   // possible. | 
| 45   virtual void ActivateTask(TaskId task_id) = 0; | 47   virtual void ActivateTask(TaskId task_id) = 0; | 
| 46 | 48 | 
| 47   // returns the CPU usage in percent for the process on which the task with | 49   // returns the CPU usage in percent for the process on which the task with | 
| 48   // |task_id| is running during the current refresh cycle. | 50   // |task_id| is running during the current refresh cycle. | 
| 49   virtual double GetCpuUsage(TaskId task_id) const = 0; | 51   virtual double GetCpuUsage(TaskId task_id) const = 0; | 
| 50 | 52 | 
| 51   // Returns the current physical/private/shared memory usage of the task with | 53   // Returns the current physical/private/shared memory usage of the task with | 
| 52   // |task_id| in bytes. A value of -1 means no valid value is currently | 54   // |task_id| in bytes. A value of -1 means no valid value is currently | 
| 53   // available. | 55   // available. | 
| 54   virtual int64 GetPhysicalMemoryUsage(TaskId task_id) const = 0; | 56   virtual int64_t GetPhysicalMemoryUsage(TaskId task_id) const = 0; | 
| 55   virtual int64 GetPrivateMemoryUsage(TaskId task_id) const = 0; | 57   virtual int64_t GetPrivateMemoryUsage(TaskId task_id) const = 0; | 
| 56   virtual int64 GetSharedMemoryUsage(TaskId task_id) const = 0; | 58   virtual int64_t GetSharedMemoryUsage(TaskId task_id) const = 0; | 
| 57 | 59 | 
| 58   // Returns the GPU memory usage of the task with |task_id| in bytes. A value | 60   // Returns the GPU memory usage of the task with |task_id| in bytes. A value | 
| 59   // of -1 means no valid value is currently available. | 61   // of -1 means no valid value is currently available. | 
| 60   // |has_duplicates| will be set to true if this process' GPU resource count is | 62   // |has_duplicates| will be set to true if this process' GPU resource count is | 
| 61   // inflated because it is counting other processes' resources. | 63   // inflated because it is counting other processes' resources. | 
| 62   virtual int64 GetGpuMemoryUsage(TaskId task_id, | 64   virtual int64_t GetGpuMemoryUsage(TaskId task_id, | 
| 63                                   bool* has_duplicates) const = 0; | 65                                     bool* has_duplicates) const = 0; | 
| 64 | 66 | 
| 65   // Returns the number of average idle CPU wakeups per second since the last | 67   // Returns the number of average idle CPU wakeups per second since the last | 
| 66   // refresh cycle. A value of -1 means no valid value is currently available. | 68   // refresh cycle. A value of -1 means no valid value is currently available. | 
| 67   virtual int GetIdleWakeupsPerSecond(TaskId task_id) const = 0; | 69   virtual int GetIdleWakeupsPerSecond(TaskId task_id) const = 0; | 
| 68 | 70 | 
| 69   // Returns the NaCl GDB debug stub port. A value of | 71   // Returns the NaCl GDB debug stub port. A value of | 
| 70   // |nacl::kGdbDebugStubPortUnknown| means no valid value is currently | 72   // |nacl::kGdbDebugStubPortUnknown| means no valid value is currently | 
| 71   // available. A value of -2 means NaCl is not enabled for this build. | 73   // available. A value of -2 means NaCl is not enabled for this build. | 
| 72   virtual int GetNaClDebugStubPort(TaskId task_id) const = 0; | 74   virtual int GetNaClDebugStubPort(TaskId task_id) const = 0; | 
| 73 | 75 | 
| 74   // On Windows, gets the current and peak number of GDI and USER handles in | 76   // On Windows, gets the current and peak number of GDI and USER handles in | 
| 75   // use. A value of -1 means no valid value is currently available. | 77   // use. A value of -1 means no valid value is currently available. | 
| 76   virtual void GetGDIHandles(TaskId task_id, | 78   virtual void GetGDIHandles(TaskId task_id, | 
| 77                              int64* current, | 79                              int64_t* current, | 
| 78                              int64* peak) const = 0; | 80                              int64_t* peak) const = 0; | 
| 79   virtual void GetUSERHandles(TaskId task_id, | 81   virtual void GetUSERHandles(TaskId task_id, | 
| 80                               int64* current, | 82                               int64_t* current, | 
| 81                               int64* peak) const = 0; | 83                               int64_t* peak) const = 0; | 
| 82 | 84 | 
| 83   // On Linux and ChromeOS, gets the number of file descriptors currently open | 85   // On Linux and ChromeOS, gets the number of file descriptors currently open | 
| 84   // by the process on which the task with |task_id| is running, or -1 if no | 86   // by the process on which the task with |task_id| is running, or -1 if no | 
| 85   // valid value is currently available. | 87   // valid value is currently available. | 
| 86   virtual int GetOpenFdCount(TaskId task_id) const = 0; | 88   virtual int GetOpenFdCount(TaskId task_id) const = 0; | 
| 87 | 89 | 
| 88   // Returns whether the task with |task_id| is running on a backgrounded | 90   // Returns whether the task with |task_id| is running on a backgrounded | 
| 89   // process. | 91   // process. | 
| 90   virtual bool IsTaskOnBackgroundedProcess(TaskId task_id) const = 0; | 92   virtual bool IsTaskOnBackgroundedProcess(TaskId task_id) const = 0; | 
| 91 | 93 | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 109   virtual const base::ProcessHandle& GetProcessHandle(TaskId task_id) const = 0; | 111   virtual const base::ProcessHandle& GetProcessHandle(TaskId task_id) const = 0; | 
| 110   virtual const base::ProcessId& GetProcessId(TaskId task_id) const = 0; | 112   virtual const base::ProcessId& GetProcessId(TaskId task_id) const = 0; | 
| 111 | 113 | 
| 112   // Returns the type of the task with |task_id|. | 114   // Returns the type of the task with |task_id|. | 
| 113   virtual Task::Type GetType(TaskId task_id) const = 0; | 115   virtual Task::Type GetType(TaskId task_id) const = 0; | 
| 114 | 116 | 
| 115   // Returns the network usage (in bytes per second) during the current refresh | 117   // Returns the network usage (in bytes per second) during the current refresh | 
| 116   // cycle for the task with |task_id|. A value of -1 means no valid value is | 118   // cycle for the task with |task_id|. A value of -1 means no valid value is | 
| 117   // currently available or that task has never been notified of any network | 119   // currently available or that task has never been notified of any network | 
| 118   // usage. | 120   // usage. | 
| 119   virtual int64 GetNetworkUsage(TaskId task_id) const = 0; | 121   virtual int64_t GetNetworkUsage(TaskId task_id) const = 0; | 
| 120 | 122 | 
| 121   // Returns the total network usage (in bytes per second) during the current | 123   // Returns the total network usage (in bytes per second) during the current | 
| 122   // refresh cycle for the process on which the task with |task_id| is running. | 124   // refresh cycle for the process on which the task with |task_id| is running. | 
| 123   // This is the sum of all the network usage of the individual tasks (that | 125   // This is the sum of all the network usage of the individual tasks (that | 
| 124   // can be gotten by the above GetNetworkUsage()). A value of -1 means network | 126   // can be gotten by the above GetNetworkUsage()). A value of -1 means network | 
| 125   // usage calculation refresh is currently not available. | 127   // usage calculation refresh is currently not available. | 
| 126   virtual int64 GetProcessTotalNetworkUsage(TaskId task_id) const = 0; | 128   virtual int64_t GetProcessTotalNetworkUsage(TaskId task_id) const = 0; | 
| 127 | 129 | 
| 128   // Returns the Sqlite used memory (in bytes) for the task with |task_id|. | 130   // Returns the Sqlite used memory (in bytes) for the task with |task_id|. | 
| 129   // A value of -1 means no valid value is currently available. | 131   // A value of -1 means no valid value is currently available. | 
| 130   virtual int64 GetSqliteMemoryUsed(TaskId task_id) const = 0; | 132   virtual int64_t GetSqliteMemoryUsed(TaskId task_id) const = 0; | 
| 131 | 133 | 
| 132   // Returns the allocated and used V8 memory (in bytes) for the task with | 134   // Returns the allocated and used V8 memory (in bytes) for the task with | 
| 133   // |task_id|. A return value of false means no valid value is currently | 135   // |task_id|. A return value of false means no valid value is currently | 
| 134   // available. | 136   // available. | 
| 135   virtual bool GetV8Memory(TaskId task_id, | 137   virtual bool GetV8Memory(TaskId task_id, | 
| 136                            int64* allocated, | 138                            int64_t* allocated, | 
| 137                            int64* used) const = 0; | 139                            int64_t* used) const = 0; | 
| 138 | 140 | 
| 139   // Gets the Webkit resource cache stats for the task with |task_id|. | 141   // Gets the Webkit resource cache stats for the task with |task_id|. | 
| 140   // A return value of false means that task does NOT report WebCache stats. | 142   // A return value of false means that task does NOT report WebCache stats. | 
| 141   virtual bool GetWebCacheStats( | 143   virtual bool GetWebCacheStats( | 
| 142       TaskId task_id, | 144       TaskId task_id, | 
| 143       blink::WebCache::ResourceTypeStats* stats) const = 0; | 145       blink::WebCache::ResourceTypeStats* stats) const = 0; | 
| 144 | 146 | 
| 145   // Gets the list of task IDs currently tracked by the task manager. The list | 147   // Gets the list of task IDs currently tracked by the task manager. The list | 
| 146   // will be sorted such that the task representing the browser process is at | 148   // will be sorted such that the task representing the browser process is at | 
| 147   // the top of the list and the rest of the IDs will be sorted by the process | 149   // the top of the list and the rest of the IDs will be sorted by the process | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 171 | 173 | 
| 172   // StartUpdating will be called once an observer is added, and StopUpdating | 174   // StartUpdating will be called once an observer is added, and StopUpdating | 
| 173   // will be called when the last observer is removed. | 175   // will be called when the last observer is removed. | 
| 174   virtual void StartUpdating() = 0; | 176   virtual void StartUpdating() = 0; | 
| 175   virtual void StopUpdating() = 0; | 177   virtual void StopUpdating() = 0; | 
| 176 | 178 | 
| 177   // Returns the current refresh time that this task manager is running at. It | 179   // Returns the current refresh time that this task manager is running at. It | 
| 178   // will return base::TimeDelta::Max() if the task manager is not running. | 180   // will return base::TimeDelta::Max() if the task manager is not running. | 
| 179   base::TimeDelta GetCurrentRefreshTime() const; | 181   base::TimeDelta GetCurrentRefreshTime() const; | 
| 180 | 182 | 
| 181   int64 enabled_resources_flags() const { return enabled_resources_flags_; } | 183   int64_t enabled_resources_flags() const { return enabled_resources_flags_; } | 
| 182 | 184 | 
| 183   void set_timer_for_testing(scoped_ptr<base::Timer> timer) { | 185   void set_timer_for_testing(scoped_ptr<base::Timer> timer) { | 
| 184     refresh_timer_ = timer.Pass(); | 186     refresh_timer_ = timer.Pass(); | 
| 185   } | 187   } | 
| 186 | 188 | 
| 187  private: | 189  private: | 
| 188   friend class TaskManagerObserver; | 190   friend class TaskManagerObserver; | 
| 189 | 191 | 
| 190   // This should be called after each time an observer changes its own desired | 192   // This should be called after each time an observer changes its own desired | 
| 191   // resources refresh flags. | 193   // resources refresh flags. | 
| 192   void RecalculateRefreshFlags(); | 194   void RecalculateRefreshFlags(); | 
| 193 | 195 | 
| 194   // Appends |flags| to the |enabled_resources_flags_|. | 196   // Appends |flags| to the |enabled_resources_flags_|. | 
| 195   void ResourceFlagsAdded(int64 flags); | 197   void ResourceFlagsAdded(int64_t flags); | 
| 196 | 198 | 
| 197   // Sets |enabled_resources_flags_| to |flags|. | 199   // Sets |enabled_resources_flags_| to |flags|. | 
| 198   void SetEnabledResourceFlags(int64 flags); | 200   void SetEnabledResourceFlags(int64_t flags); | 
| 199 | 201 | 
| 200   // Schedules the task manager refresh cycles using the given |refresh_time|. | 202   // Schedules the task manager refresh cycles using the given |refresh_time|. | 
| 201   // It stops any existing refresh schedule. | 203   // It stops any existing refresh schedule. | 
| 202   void ScheduleRefresh(base::TimeDelta refresh_time); | 204   void ScheduleRefresh(base::TimeDelta refresh_time); | 
| 203 | 205 | 
| 204   // The list of observers. | 206   // The list of observers. | 
| 205   base::ObserverList<TaskManagerObserver> observers_; | 207   base::ObserverList<TaskManagerObserver> observers_; | 
| 206 | 208 | 
| 207   // The timer that will be used to schedule the successive refreshes. | 209   // The timer that will be used to schedule the successive refreshes. | 
| 208   scoped_ptr<base::Timer> refresh_timer_; | 210   scoped_ptr<base::Timer> refresh_timer_; | 
| 209 | 211 | 
| 210   // The flags containing the enabled resources types calculations. | 212   // The flags containing the enabled resources types calculations. | 
| 211   int64 enabled_resources_flags_; | 213   int64_t enabled_resources_flags_; | 
| 212 | 214 | 
| 213   DISALLOW_COPY_AND_ASSIGN(TaskManagerInterface); | 215   DISALLOW_COPY_AND_ASSIGN(TaskManagerInterface); | 
| 214 }; | 216 }; | 
| 215 | 217 | 
| 216 }  // namespace task_management | 218 }  // namespace task_management | 
| 217 | 219 | 
| 218 #endif  // CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_INTERFACE_H_ | 220 #endif  // CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_INTERFACE_H_ | 
| OLD | NEW | 
|---|