| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // Use the <code>chrome.processes</code> API to interact with the browser's | 5 // Use the <code>chrome.processes</code> API to interact with the browser's |
| 6 // processes. | 6 // processes. |
| 7 namespace processes { | 7 [use_movable_types=true]namespace processes { |
| 8 // The types of the browser processes. | 8 // The types of the browser processes. |
| 9 enum ProcessType { | 9 enum ProcessType { |
| 10 browser, | 10 browser, |
| 11 renderer, | 11 renderer, |
| 12 extension, | 12 extension, |
| 13 notification, | 13 notification, |
| 14 plugin, | 14 plugin, |
| 15 worker, | 15 worker, |
| 16 nacl, | 16 nacl, |
| 17 utility, | 17 utility, |
| 18 gpu, | 18 gpu, |
| 19 other | 19 other |
| 20 }; | 20 }; |
| 21 | 21 |
| 22 // An object that represents a Chrome task running on a process. Several tasks | 22 // An object that represents a Chrome task running on a process. Several tasks |
| 23 // can share the same process. | 23 // can share the same process. |
| 24 dictionary TaskInfo { | 24 dictionary TaskInfo { |
| 25 // The title of the task. | 25 // The title of the task. |
| 26 DOMString title; | 26 DOMString title; |
| 27 // Optional tab ID, if this task represents a tab running on a renderer | 27 // Optional tab ID, if this task represents a tab running on a renderer |
| 28 // process. | 28 // process. |
| 29 long? tabId; | 29 long? tabId; |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 // The Cache object contains information about the size and utilization of a | 32 // The Cache object contains information about the size and utilization of a |
| 33 // cache used by the browser. | 33 // cache used by the browser. |
| 34 dictionary Cache { | 34 dictionary Cache { |
| 35 // The size of the cache, in bytes. | 35 // The size of the cache, in bytes. |
| 36 double size; | 36 double size; |
| 37 // The part of the cache that is utilized, in bytes. | 37 // The part of the cache that is utilized, in bytes. |
| 38 double liveSize; | 38 double liveSize; |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 // An object containing information about one of the browser's processes. | 41 // An object containing information about one of the browser's processes. |
| 42 dictionary Process { | 42 dictionary Process { |
| 43 // Unique ID of the process provided by the browser. | 43 // Unique ID of the process provided by the browser. |
| 44 long id; | 44 long id; |
| 45 // The ID of the process, as provided by the OS. | 45 // The ID of the process, as provided by the OS. |
| 46 long osProcessId; | 46 long osProcessId; |
| 47 // The type of process. | 47 // The type of process. |
| 48 ProcessType type; | 48 ProcessType type; |
| 49 // The profile which the process is associated with. | 49 // The profile which the process is associated with. |
| 50 DOMString profile; | 50 DOMString profile; |
| 51 // The debugging port for Native Client processes. Zero for other process | 51 // The debugging port for Native Client processes. Zero for other process |
| 52 // types and for NaCl processes that do not have debugging enabled. | 52 // types and for NaCl processes that do not have debugging enabled. |
| 53 long naclDebugPort; | 53 long naclDebugPort; |
| 54 // Array of TaskInfos representing the tasks running on this process. | 54 // Array of TaskInfos representing the tasks running on this process. |
| 55 TaskInfo[] tasks; | 55 TaskInfo[] tasks; |
| 56 // The most recent measurement of the process CPU usage, between 0 and 100. | 56 // The most recent measurement of the process CPU usage, between 0 and 100. |
| 57 // Only available when receiving the object as part of a callback from | 57 // Only available when receiving the object as part of a callback from |
| 58 // onUpdated or onUpdatedWithMemory. | 58 // onUpdated or onUpdatedWithMemory. |
| 59 double? cpu; | 59 double? cpu; |
| 60 // The most recent measurement of the process network usage, in bytes per | 60 // The most recent measurement of the process network usage, in bytes per |
| 61 // second. Only available when receiving the object as part of a callback | 61 // second. Only available when receiving the object as part of a callback |
| 62 // from onUpdated or onUpdatedWithMemory. | 62 // from onUpdated or onUpdatedWithMemory. |
| 63 double? network; | 63 double? network; |
| 64 // The most recent measurement of the process private memory usage, in | 64 // The most recent measurement of the process private memory usage, in |
| 65 // bytes. Only available when receiving the object as part of a callback | 65 // bytes. Only available when receiving the object as part of a callback |
| 66 // from onUpdatedWithMemory or getProcessInfo with the includeMemory flag. | 66 // from onUpdatedWithMemory or getProcessInfo with the includeMemory flag. |
| 67 double? privateMemory; | 67 double? privateMemory; |
| 68 // The most recent measurement of the process JavaScript allocated memory, | 68 // The most recent measurement of the process JavaScript allocated memory, |
| 69 // in bytes. Only available when receiving the object as part of a callback | 69 // in bytes. Only available when receiving the object as part of a callback |
| 70 // from onUpdated or onUpdatedWithMemory. | 70 // from onUpdated or onUpdatedWithMemory. |
| 71 double? jsMemoryAllocated; | 71 double? jsMemoryAllocated; |
| 72 // The most recent measurement of the process JavaScript memory used, in | 72 // The most recent measurement of the process JavaScript memory used, in |
| 73 // bytes. Only available when receiving the object as part of a callback | 73 // bytes. Only available when receiving the object as part of a callback |
| 74 // from onUpdated or onUpdatedWithMemory. | 74 // from onUpdated or onUpdatedWithMemory. |
| 75 double? jsMemoryUsed; | 75 double? jsMemoryUsed; |
| 76 // The most recent measurement of the process’s SQLite memory usage, in | 76 // The most recent measurement of the process’s SQLite memory usage, in |
| 77 // bytes. Only available when receiving the object as part of a callback | 77 // bytes. Only available when receiving the object as part of a callback |
| 78 // from onUpdated or onUpdatedWithMemory. | 78 // from onUpdated or onUpdatedWithMemory. |
| 79 double? sqliteMemory; | 79 double? sqliteMemory; |
| 80 // The most recent information about the image cache for the process. Only | 80 // The most recent information about the image cache for the process. Only |
| 81 // available when receiving the object as part of a callback from onUpdated | 81 // available when receiving the object as part of a callback from onUpdated |
| 82 // or onUpdatedWithMemory. | 82 // or onUpdatedWithMemory. |
| 83 Cache? imageCache; | 83 Cache? imageCache; |
| 84 // The most recent information about the script cache for the process. Only | 84 // The most recent information about the script cache for the process. Only |
| 85 // available when receiving the object as part of a callback from onUpdated | 85 // available when receiving the object as part of a callback from onUpdated |
| 86 // or onUpdatedWithMemory. | 86 // or onUpdatedWithMemory. |
| 87 Cache? scriptCache; | 87 Cache? scriptCache; |
| 88 // The most recent information about the CSS cache for the process. Only | 88 // The most recent information about the CSS cache for the process. Only |
| 89 // available when receiving the object as part of a callback from onUpdated | 89 // available when receiving the object as part of a callback from onUpdated |
| 90 // or onUpdatedWithMemory. | 90 // or onUpdatedWithMemory. |
| 91 Cache? cssCache; | 91 Cache? cssCache; |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 // A callback to report the status of the termination. | 94 // A callback to report the status of the termination. |
| 95 // |didTerminate|: True if terminating the process was successful, and false | 95 // |didTerminate|: True if terminating the process was successful, and false |
| 96 // otherwise. | 96 // otherwise. |
| 97 callback TerminateCallback = void(boolean didTerminate); | 97 callback TerminateCallback = void(boolean didTerminate); |
| 98 | 98 |
| 99 // A callback to return the ID of the renderer process of a tab. | 99 // A callback to return the ID of the renderer process of a tab. |
| 100 // |processId|: Process ID of the tab's renderer process. | 100 // |processId|: Process ID of the tab's renderer process. |
| 101 callback GetProcessIdForTabCallback = void(long processId); | 101 callback GetProcessIdForTabCallback = void(long processId); |
| 102 | 102 |
| 103 // A callback called when the processes information is collected. | 103 // A callback called when the processes information is collected. |
| 104 // |processes|: A dictionary of $(ref:Process) objects for each requested | 104 // |processes|: A dictionary of $(ref:Process) objects for each requested |
| 105 // process that is a live child process of the current browser process, | 105 // process that is a live child process of the current browser process, |
| 106 // indexed by process ID. Metrics requiring aggregation over time will not be | 106 // indexed by process ID. Metrics requiring aggregation over time will not be |
| 107 // populated in each Process object. | 107 // populated in each Process object. |
| 108 callback GetProcessInfoCallback = void(object processes); | 108 callback GetProcessInfoCallback = void(object processes); |
| 109 | 109 |
| 110 interface Functions { | 110 interface Functions { |
| 111 // Returns the ID of the renderer process for the specified tab. | 111 // Returns the ID of the renderer process for the specified tab. |
| 112 // |tabId|: The ID of the tab for which the renderer process ID is to be | 112 // |tabId|: The ID of the tab for which the renderer process ID is to be |
| 113 // returned. | 113 // returned. |
| 114 static void getProcessIdForTab(long tabId, | 114 static void getProcessIdForTab(long tabId, |
| 115 GetProcessIdForTabCallback callback); | 115 GetProcessIdForTabCallback callback); |
| 116 | 116 |
| 117 // Terminates the specified renderer process. Equivalent to visiting | 117 // Terminates the specified renderer process. Equivalent to visiting |
| 118 // about:crash, but without changing the tab's URL. | 118 // about:crash, but without changing the tab's URL. |
| 119 // |processId|: The ID of the process to be terminated. | 119 // |processId|: The ID of the process to be terminated. |
| 120 static void terminate(long processId, optional TerminateCallback callback); | 120 static void terminate(long processId, optional TerminateCallback callback); |
| 121 | 121 |
| 122 // Retrieves the process information for each process ID specified. | 122 // Retrieves the process information for each process ID specified. |
| 123 // |processIds|: The list of process IDs or single process ID for which | 123 // |processIds|: The list of process IDs or single process ID for which |
| 124 // to return the process information. An empty list indicates all processes | 124 // to return the process information. An empty list indicates all processes |
| 125 // are requested. | 125 // are requested. |
| 126 // |includeMemory|: True if detailed memory usage is required. Note, | 126 // |includeMemory|: True if detailed memory usage is required. Note, |
| 127 // collecting memory usage information incurs extra CPU usage and should | 127 // collecting memory usage information incurs extra CPU usage and should |
| 128 // only be queried for when needed. | 128 // only be queried for when needed. |
| 129 static void getProcessInfo((long or long[]) processIds, | 129 static void getProcessInfo((long or long[]) processIds, |
| 130 boolean includeMemory, | 130 boolean includeMemory, |
| 131 GetProcessInfoCallback callback); | 131 GetProcessInfoCallback callback); |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 interface Events { | 134 interface Events { |
| 135 // Fired each time the Task Manager updates its process statistics, | 135 // Fired each time the Task Manager updates its process statistics, |
| 136 // providing the dictionary of updated Process objects, indexed by process | 136 // providing the dictionary of updated Process objects, indexed by process |
| 137 // ID. | 137 // ID. |
| 138 // |processes|: A dictionary of updated $(ref:Process) objects for each live | 138 // |processes|: A dictionary of updated $(ref:Process) objects for each live |
| 139 // process in the browser, indexed by process ID. Metrics requiring | 139 // process in the browser, indexed by process ID. Metrics requiring |
| 140 // aggregation over time will be populated in each Process object. | 140 // aggregation over time will be populated in each Process object. |
| 141 static void onUpdated(object processes); | 141 static void onUpdated(object processes); |
| 142 | 142 |
| 143 // Fired each time the Task Manager updates its process statistics, | 143 // Fired each time the Task Manager updates its process statistics, |
| 144 // providing the dictionary of updated Process objects, indexed by process | 144 // providing the dictionary of updated Process objects, indexed by process |
| 145 // ID. Identical to onUpdate, with the addition of memory usage details | 145 // ID. Identical to onUpdate, with the addition of memory usage details |
| 146 // included in each Process object. Note, collecting memory usage | 146 // included in each Process object. Note, collecting memory usage |
| 147 // information incurs extra CPU usage and should only be listened for when | 147 // information incurs extra CPU usage and should only be listened for when |
| 148 // needed. | 148 // needed. |
| 149 // |processes|: A dictionary of updated $(ref:Process) objects for each live | 149 // |processes|: A dictionary of updated $(ref:Process) objects for each live |
| 150 // process in the browser, indexed by process ID. Memory usage details will | 150 // process in the browser, indexed by process ID. Memory usage details will |
| 151 // be included in each Process object. | 151 // be included in each Process object. |
| 152 static void onUpdatedWithMemory(object processes); | 152 static void onUpdatedWithMemory(object processes); |
| 153 | 153 |
| 154 // Fired each time a process is created, providing the corrseponding Process | 154 // Fired each time a process is created, providing the corrseponding Process |
| 155 // object. | 155 // object. |
| 156 // |process|: Details of the process that was created. Metrics requiring | 156 // |process|: Details of the process that was created. Metrics requiring |
| 157 // aggregation over time will not be populated in the object. | 157 // aggregation over time will not be populated in the object. |
| 158 static void onCreated(Process process); | 158 static void onCreated(Process process); |
| 159 | 159 |
| 160 // Fired each time a process becomes unresponsive, providing the | 160 // Fired each time a process becomes unresponsive, providing the |
| 161 // corrseponding Process object. | 161 // corrseponding Process object. |
| 162 // |process|: Details of the unresponsive process. Metrics requiring | 162 // |process|: Details of the unresponsive process. Metrics requiring |
| 163 // aggregation over time will not be populated in the object. Only available | 163 // aggregation over time will not be populated in the object. Only available |
| 164 // for renderer processes. | 164 // for renderer processes. |
| 165 static void onUnresponsive(Process process); | 165 static void onUnresponsive(Process process); |
| 166 | 166 |
| 167 // Fired each time a process is terminated, providing the type of exit. | 167 // Fired each time a process is terminated, providing the type of exit. |
| 168 // |processId|: The ID of the process that exited. | 168 // |processId|: The ID of the process that exited. |
| 169 // |exitType|: The type of exit that occurred for the process - normal, | 169 // |exitType|: The type of exit that occurred for the process - normal, |
| 170 // abnormal, killed, crashed. Only available for renderer processes. | 170 // abnormal, killed, crashed. Only available for renderer processes. |
| 171 // |exitCode|: The exit code if the process exited abnormally. Only | 171 // |exitCode|: The exit code if the process exited abnormally. Only |
| 172 // available for renderer processes. | 172 // available for renderer processes. |
| 173 static void onExited(long processId, long exitType, long exitCode); | 173 static void onExited(long processId, long exitType, long exitCode); |
| 174 }; | 174 }; |
| 175 }; | 175 }; |
| OLD | NEW |