OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_H_ |
| 6 #define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/process/process_handle.h" |
| 10 #include "base/strings/string16.h" |
| 11 #include "base/time/time.h" |
| 12 #include "third_party/WebKit/public/web/WebCache.h" |
| 13 #include "ui/gfx/image/image_skia.h" |
| 14 |
| 15 namespace task_management { |
| 16 |
| 17 // Defines a task that corresponds to a tab, an app, an extension, ... etc. It |
| 18 // represents one row in the task manager table. Multiple tasks can share the |
| 19 // same process, in which case they're grouped together in the task manager |
| 20 // table. See |task_management::TaskGroup| which represents a process possibly |
| 21 // shared by multiple tasks. |
| 22 class Task { |
| 23 public: |
| 24 enum Type { |
| 25 UNKNOWN = 0, |
| 26 BROWSER, /* The main browser process. */ |
| 27 RENDERER, /* A normal WebContents renderer process. */ |
| 28 EXTENSION, /* An extension or app process. */ |
| 29 NOTIFICATION, /* A notification process. */ |
| 30 GUEST, /* A browser plugin guest process. */ |
| 31 PLUGIN, /* A plugin process. */ |
| 32 WORKER, /* A web worker process. */ |
| 33 NACL, /* A NativeClient loader or broker process. */ |
| 34 UTILITY, /* A browser utility process. */ |
| 35 ZYGOTE, /* A Linux zygote process. */ |
| 36 SANDBOX_HELPER, /* A sandbox helper process. */ |
| 37 GPU, /* A graphics process. */ |
| 38 }; |
| 39 |
| 40 // Create a task with the given |title| and the given Fav |icon|. This task |
| 41 // runs on a process whose handle is |handle|. |
| 42 Task(const base::string16& title, |
| 43 const gfx::ImageSkia& icon, |
| 44 base::ProcessHandle handle); |
| 45 virtual ~Task(); |
| 46 |
| 47 // Will be called to let the task refresh itself between refresh cycles. |
| 48 // |update_interval| is the time since the last task manager refresh. |
| 49 virtual void Refresh(const base::TimeDelta& update_interval); |
| 50 |
| 51 // Will receive this notification through the task manager from |
| 52 // |ChromeNetworkDelegate::OnRawBytesRead()|. The task will add to the |
| 53 // |current_byte_count_| in this refresh cycle. |
| 54 void OnNetworkBytesRead(int64 bytes_read); |
| 55 |
| 56 // Returns the task type. |
| 57 virtual Type GetType() const = 0; |
| 58 |
| 59 // This is the unique ID of the BrowserChildProcessHost/RenderProcessHost. It |
| 60 // is not the PID nor the handle of the process. |
| 61 virtual int GetChildProcessUniqueID() const = 0; |
| 62 |
| 63 // The name of the profile associated with the browser context of the render |
| 64 // view host that this task represents (if this task represents a renderer). |
| 65 virtual base::string16 GetProfileName() const; |
| 66 |
| 67 // If this task represents a renderer process, this would the return the |
| 68 // routing ID of the RenderViewHost, otherwise it will return 0. |
| 69 virtual int GetRoutingID() const; |
| 70 |
| 71 // Returns the Sqlite used memory (in bytes). Not all tasks reports Sqlite |
| 72 // memory, in this case a default invalid value of -1U will be returned. |
| 73 virtual size_t GetSqliteMemoryUsed() const; |
| 74 |
| 75 // Returns the allocated and used V8 memory (in bytes). Not all tasks reports |
| 76 // V8 memory, in this case a default invalid value of -1U will be returned. |
| 77 virtual size_t GetV8MemoryAllocated() const; |
| 78 virtual size_t GetV8MemoryUsed() const; |
| 79 |
| 80 // Checking if the task reports Webkit resource cache statistics and getting |
| 81 // them if it does. |
| 82 virtual bool ReportsWebCacheStats() const; |
| 83 virtual blink::WebCache::ResourceTypeStats GetWebCacheStats() const; |
| 84 |
| 85 int64 task_id() const { return task_id_; } |
| 86 int64 network_usage() const { return network_usage_; } |
| 87 const base::string16& title() const { return title_; } |
| 88 gfx::ImageSkia icon() const { return icon_; } |
| 89 base::ProcessHandle process_handle() const { return process_handle_; } |
| 90 |
| 91 private: |
| 92 // The unique ID of this task. |
| 93 const int64 task_id_; |
| 94 |
| 95 // The task's network usage in the current refresh cycle measured in bytes per |
| 96 // second. |
| 97 int64 network_usage_; |
| 98 |
| 99 // The current network bytes received by this task during the current refresh |
| 100 // cycle. |
| 101 int64 current_byte_count_; |
| 102 |
| 103 // The title of the task. |
| 104 base::string16 title_; |
| 105 |
| 106 // The Fav icon. |
| 107 gfx::ImageSkia icon_; |
| 108 |
| 109 // The handle of the process on which this task is running. |
| 110 const base::ProcessHandle process_handle_; |
| 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(Task); |
| 113 }; |
| 114 |
| 115 } // namespace task_management |
| 116 |
| 117 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_H_ |
OLD | NEW |