task_manager.mojom 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. // Copyright 2021 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. module crosapi.mojom;
  5. import "mojo/public/mojom/base/process_id.mojom";
  6. import "mojo/public/mojom/base/string16.mojom";
  7. import "mojo/public/mojom/base/time.mojom";
  8. import "mojo/public/mojom/base/unguessable_token.mojom";
  9. import "ui/gfx/image/mojom/image.mojom";
  10. [Stable, Extensible]
  11. enum TaskType {
  12. [Default] kUnknown = 0,
  13. /* Singleton processes that don't belong to a particular tab. */
  14. kBrowser, /* The main browser process. */
  15. kGpu, /* A graphics process. */
  16. kZygote, /* A Linux zygote process. */
  17. kUtility, /* A browser utility process. */
  18. /* Per-Tab processes. */
  19. kRenderer, /* A normal WebContents renderer process. */
  20. kExtension, /* An extension or app process. */
  21. /* Plugin processes.*/
  22. kGuest, /* A browser plugin guest process. */
  23. kPlugin, /* A plugin process. */
  24. kNacl, /* A NativeClient loader or broker process. */
  25. kSandboxHelper, /* A sandbox helper process. */
  26. kDedicatedWorker, /* A dedicated worker running on the renderer process. */
  27. kSharedWorker, /* A shared worker running on the renderer process. */
  28. kServiceWorker, /* A service worker running on the renderer process. */
  29. };
  30. // A struct mirroring blink::MemoryCache::TypeStatistic.
  31. [Stable]
  32. struct WebCacheResourceTypeStat {
  33. uint64 count;
  34. uint64 size;
  35. uint64 decoded_size;
  36. };
  37. // A struct mirroring blink::MemoryCache::Statistics.
  38. [Stable]
  39. struct WebCacheResourceTypeStats {
  40. WebCacheResourceTypeStat images;
  41. WebCacheResourceTypeStat css_style_sheets;
  42. WebCacheResourceTypeStat scripts;
  43. WebCacheResourceTypeStat xsl_style_sheets;
  44. WebCacheResourceTypeStat fonts;
  45. WebCacheResourceTypeStat other;
  46. };
  47. // A struct represent a task from lacros.
  48. [Stable]
  49. struct Task {
  50. // Uuid that uniquely identifies the task.
  51. string task_uuid;
  52. // Type of lacros task.
  53. TaskType type;
  54. // Title of task.
  55. mojo_base.mojom.String16 title;
  56. // Process id of task.
  57. mojo_base.mojom.ProcessId process_id;
  58. // Icon of task.
  59. gfx.mojom.ImageSkia? icon;
  60. // Profile name of task.
  61. mojo_base.mojom.String16 profile_name;
  62. // Sqlite used memory in bytes.
  63. int64 used_sqlite_memory;
  64. // Allocated v8 memory in bytes.
  65. int64 v8_memory_allocated;
  66. // Used v8 memory in bytes.
  67. int64 v8_memory_used;
  68. // Webkit resource cache statistics.
  69. WebCacheResourceTypeStats? web_cache_stats;
  70. // Keep-alive counter if task is in an event page.
  71. int64 keep_alive_count;
  72. // The instantaneous rate, in bytes per second, of network usage
  73. // (sent and received), as measured over the last refresh cycle.
  74. int64 network_usage_rate;
  75. // The cumulative number of bytes of network use (sent and received)
  76. // over the tasks lifetime.
  77. int64 cumulative_network_usage;
  78. };
  79. // A struct representing a lacros task group, which is a group of tasks
  80. // whiche share the same process, and the resources associated with it.
  81. [Stable]
  82. struct TaskGroup {
  83. // Process id of the task group.
  84. mojo_base.mojom.ProcessId process_id;
  85. // CPU usage over the most recent refresh cycle. The value is in the range
  86. // zero to base::SysInfo::NumberOfProcessors() * 100%.
  87. double platform_independent_cpu_usage;
  88. // Current memory footprint in bytes.
  89. int64 memory_footprint_bytes;
  90. // Current swapped memory in bytes.
  91. int64 swapped_mem_bytes;
  92. // GPU memory usage in bytes.
  93. int64 gpu_memory_bytes;
  94. // True if this process' GPU resource count is inflated because it is counting
  95. // other processes' resources.
  96. bool gpu_memory_has_duplicates;
  97. // Network usage (in bytes per second) during the current refresh cycle
  98. // for the process.
  99. int64 per_process_network_usage_rate;
  100. // A continuously updating sum of all bytes that have been downloaded and
  101. // uploaded by all tasks in this process.
  102. int64 cumulative_per_process_network_usage;
  103. // Whether the process in a backgrounded process.
  104. bool is_backgrounded;
  105. // NaCl GDB debug stub port.
  106. int64 nacl_debug_stub_port;
  107. // Number of file descriptors currently open by the process.
  108. int64 open_fd_count;
  109. // Number of average idle CPU wakeups per second since the last refresh cycle.
  110. int64 idle_wakeups_per_second;
  111. };
  112. // Interface for task manager provider. Implemented by lacros-chrome. Used by
  113. // ash-chrome to get lacros task data remotely.
  114. // Next version: 3
  115. // Next method id: 5
  116. [Stable, Uuid="c5073375-8e4b-43c3-85ca-8813adeb0324"]
  117. interface TaskManagerProvider {
  118. // Deprecated. Use SetRefreshFlags instead.
  119. DeprecatedSetRefreshArgs@0(mojo_base.mojom.TimeDelta refresh_interval,
  120. int64 refresh_flags);
  121. // Gets browser's task data needed for task manager.
  122. // Returns task data and task group data.
  123. // Note: SetRefreshFlags must be called before to set the desired refresh
  124. // interval and refresh flags.
  125. GetTaskManagerTasks@1()
  126. => (array<Task> task_results, array<TaskGroup> task_group_results);
  127. // Notifies Lacros that task manager is closed in ash.
  128. OnTaskManagerClosed@2();
  129. // Sets the desired refresh flags, which must be set before calling
  130. // GetTaskManagerTasks.
  131. // |refresh_flags| specify the enabled resources types, which is a bit flags
  132. // from RefreshType enum defined in:
  133. // chrome/browser/task_manager/task_manager_observer.h
  134. [MinVersion=1]
  135. SetRefreshFlags@3(int64 refresh_flags);
  136. // Activates a lacros task.
  137. // |task_uuid|: task_uuid of the lacros Task to be activated.
  138. [MinVersion=2]
  139. ActivateTask@4(string task_uuid);
  140. };
  141. // Interface for task manager. Implemented by ash-chrome.
  142. // Next version: 2
  143. // Next method id: 2
  144. [Stable, Uuid="c5073375-8e4b-43c3-85ca-8813adeb0324"]
  145. interface TaskManager {
  146. // A crosapi client can register itself as a task manager provider. This
  147. // provides ash a mechanism to get task manager data from lacros.
  148. // The provider is uniquely identified by |token|.
  149. RegisterTaskManagerProvider@0(
  150. pending_remote<TaskManagerProvider> provider,
  151. mojo_base.mojom.UnguessableToken token);
  152. // Shows the Task Manager window, or re-activates an existing one.
  153. [MinVersion=1]
  154. ShowTaskManager@1();
  155. };