OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_RESOURCE_PROVIDERS_H_ | 5 #ifndef CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_RESOURCE_PROVIDERS_H_ |
6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_RESOURCE_PROVIDERS_H_ | 6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_RESOURCE_PROVIDERS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 DISALLOW_COPY_AND_ASSIGN(TaskManagerTabContentsResource); | 93 DISALLOW_COPY_AND_ASSIGN(TaskManagerTabContentsResource); |
94 }; | 94 }; |
95 | 95 |
96 class TaskManagerTabContentsResourceProvider | 96 class TaskManagerTabContentsResourceProvider |
97 : public TaskManager::ResourceProvider, | 97 : public TaskManager::ResourceProvider, |
98 public NotificationObserver { | 98 public NotificationObserver { |
99 public: | 99 public: |
100 explicit TaskManagerTabContentsResourceProvider(TaskManager* task_manager); | 100 explicit TaskManagerTabContentsResourceProvider(TaskManager* task_manager); |
101 | 101 |
102 virtual TaskManager::Resource* GetResource(int origin_pid, | 102 virtual TaskManager::Resource* GetResource(int origin_child_id, |
103 int render_process_host_id, | 103 int render_process_host_id, |
104 int routing_id); | 104 int routing_id); |
105 virtual void StartUpdating(); | 105 virtual void StartUpdating(); |
106 virtual void StopUpdating(); | 106 virtual void StopUpdating(); |
107 | 107 |
108 // NotificationObserver method: | 108 // NotificationObserver method: |
109 virtual void Observe(NotificationType type, | 109 virtual void Observe(NotificationType type, |
110 const NotificationSource& source, | 110 const NotificationSource& source, |
111 const NotificationDetails& details); | 111 const NotificationDetails& details); |
112 | 112 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 DISALLOW_COPY_AND_ASSIGN(TaskManagerBackgroundContentsResource); | 161 DISALLOW_COPY_AND_ASSIGN(TaskManagerBackgroundContentsResource); |
162 }; | 162 }; |
163 | 163 |
164 class TaskManagerBackgroundContentsResourceProvider | 164 class TaskManagerBackgroundContentsResourceProvider |
165 : public TaskManager::ResourceProvider, | 165 : public TaskManager::ResourceProvider, |
166 public NotificationObserver { | 166 public NotificationObserver { |
167 public: | 167 public: |
168 explicit TaskManagerBackgroundContentsResourceProvider( | 168 explicit TaskManagerBackgroundContentsResourceProvider( |
169 TaskManager* task_manager); | 169 TaskManager* task_manager); |
170 | 170 |
171 virtual TaskManager::Resource* GetResource(int origin_pid, | 171 virtual TaskManager::Resource* GetResource(int origin_child_id, |
172 int render_process_host_id, | 172 int render_process_host_id, |
173 int routing_id); | 173 int routing_id); |
174 virtual void StartUpdating(); | 174 virtual void StartUpdating(); |
175 virtual void StopUpdating(); | 175 virtual void StopUpdating(); |
176 | 176 |
177 // NotificationObserver method: | 177 // NotificationObserver method: |
178 virtual void Observe(NotificationType type, | 178 virtual void Observe(NotificationType type, |
179 const NotificationSource& source, | 179 const NotificationSource& source, |
180 const NotificationDetails& details); | 180 const NotificationDetails& details); |
181 | 181 |
(...skipping 29 matching lines...) Expand all Loading... |
211 virtual ~TaskManagerChildProcessResource(); | 211 virtual ~TaskManagerChildProcessResource(); |
212 | 212 |
213 // TaskManagerResource methods: | 213 // TaskManagerResource methods: |
214 virtual std::wstring GetTitle() const; | 214 virtual std::wstring GetTitle() const; |
215 virtual SkBitmap GetIcon() const; | 215 virtual SkBitmap GetIcon() const; |
216 virtual base::ProcessHandle GetProcess() const; | 216 virtual base::ProcessHandle GetProcess() const; |
217 virtual Type GetType() const; | 217 virtual Type GetType() const; |
218 virtual bool SupportNetworkUsage() const; | 218 virtual bool SupportNetworkUsage() const; |
219 virtual void SetSupportNetworkUsage(); | 219 virtual void SetSupportNetworkUsage(); |
220 | 220 |
221 // Returns the pid of the child process. | 221 // Return the child process' unique child ID for use by GetResource() |
222 int process_id() const { return pid_; } | 222 int id() { return child_process_.id(); } |
223 | 223 |
224 private: | 224 private: |
225 ChildProcessInfo child_process_; | 225 ChildProcessInfo child_process_; |
226 int pid_; | |
227 mutable std::wstring title_; | 226 mutable std::wstring title_; |
228 bool network_usage_support_; | 227 bool network_usage_support_; |
229 | 228 |
230 // The icon painted for the child processs. | 229 // The icon painted for the child processs. |
231 // TODO(jcampan): we should have plugin specific icons for well-known | 230 // TODO(jcampan): we should have plugin specific icons for well-known |
232 // plugins. | 231 // plugins. |
233 static SkBitmap* default_icon_; | 232 static SkBitmap* default_icon_; |
234 | 233 |
235 DISALLOW_COPY_AND_ASSIGN(TaskManagerChildProcessResource); | 234 DISALLOW_COPY_AND_ASSIGN(TaskManagerChildProcessResource); |
236 }; | 235 }; |
237 | 236 |
238 class TaskManagerChildProcessResourceProvider | 237 class TaskManagerChildProcessResourceProvider |
239 : public TaskManager::ResourceProvider, | 238 : public TaskManager::ResourceProvider, |
240 public NotificationObserver { | 239 public NotificationObserver { |
241 public: | 240 public: |
242 explicit TaskManagerChildProcessResourceProvider(TaskManager* task_manager); | 241 explicit TaskManagerChildProcessResourceProvider(TaskManager* task_manager); |
243 | 242 |
244 virtual TaskManager::Resource* GetResource(int origin_pid, | 243 virtual TaskManager::Resource* GetResource(int origin_child_id, |
245 int render_process_host_id, | 244 int render_process_host_id, |
246 int routing_id); | 245 int routing_id); |
247 virtual void StartUpdating(); | 246 virtual void StartUpdating(); |
248 virtual void StopUpdating(); | 247 virtual void StopUpdating(); |
249 | 248 |
250 // NotificationObserver method: | 249 // NotificationObserver method: |
251 virtual void Observe(NotificationType type, | 250 virtual void Observe(NotificationType type, |
252 const NotificationSource& source, | 251 const NotificationSource& source, |
253 const NotificationDetails& details); | 252 const NotificationDetails& details); |
254 | 253 |
(...skipping 19 matching lines...) Expand all Loading... |
274 void AddToTaskManager(const ChildProcessInfo& child_process_info); | 273 void AddToTaskManager(const ChildProcessInfo& child_process_info); |
275 | 274 |
276 TaskManager* task_manager_; | 275 TaskManager* task_manager_; |
277 | 276 |
278 // Maps the actual resources (the ChildProcessInfo) to the Task Manager | 277 // Maps the actual resources (the ChildProcessInfo) to the Task Manager |
279 // resources. | 278 // resources. |
280 std::map<ChildProcessInfo, TaskManagerChildProcessResource*> resources_; | 279 std::map<ChildProcessInfo, TaskManagerChildProcessResource*> resources_; |
281 | 280 |
282 // Maps the pids to the resources (used for quick access to the resource on | 281 // Maps the pids to the resources (used for quick access to the resource on |
283 // byte read notifications). | 282 // byte read notifications). |
284 std::map<int, TaskManagerChildProcessResource*> pid_to_resources_; | 283 std::map<int, TaskManagerChildProcessResource*> child_id_to_resources_; |
285 | 284 |
286 // A scoped container for notification registries. | 285 // A scoped container for notification registries. |
287 NotificationRegistrar registrar_; | 286 NotificationRegistrar registrar_; |
288 | 287 |
289 DISALLOW_COPY_AND_ASSIGN(TaskManagerChildProcessResourceProvider); | 288 DISALLOW_COPY_AND_ASSIGN(TaskManagerChildProcessResourceProvider); |
290 }; | 289 }; |
291 | 290 |
292 class TaskManagerExtensionProcessResource : public TaskManager::Resource { | 291 class TaskManagerExtensionProcessResource : public TaskManager::Resource { |
293 public: | 292 public: |
294 explicit TaskManagerExtensionProcessResource(ExtensionHost* extension_host); | 293 explicit TaskManagerExtensionProcessResource(ExtensionHost* extension_host); |
295 virtual ~TaskManagerExtensionProcessResource(); | 294 virtual ~TaskManagerExtensionProcessResource(); |
296 | 295 |
297 // TaskManagerResource methods: | 296 // TaskManagerResource methods: |
298 virtual std::wstring GetTitle() const; | 297 virtual std::wstring GetTitle() const; |
299 virtual SkBitmap GetIcon() const; | 298 virtual SkBitmap GetIcon() const; |
300 virtual base::ProcessHandle GetProcess() const; | 299 virtual base::ProcessHandle GetProcess() const; |
301 virtual Type GetType() const; | 300 virtual Type GetType() const; |
302 virtual bool SupportNetworkUsage() const; | 301 virtual bool SupportNetworkUsage() const; |
303 virtual void SetSupportNetworkUsage(); | 302 virtual void SetSupportNetworkUsage(); |
304 virtual const Extension* GetExtension() const; | 303 virtual const Extension* GetExtension() const; |
305 | 304 |
306 // Returns the pid of the extension process. | |
307 int process_id() const { return pid_; } | |
308 | |
309 // Returns true if the associated extension has a background page. | 305 // Returns true if the associated extension has a background page. |
310 virtual bool IsBackground() const; | 306 virtual bool IsBackground() const; |
311 | 307 |
| 308 int id() { return id_; } |
312 private: | 309 private: |
313 // The icon painted for the extension process. | 310 // The icon painted for the extension process. |
314 static SkBitmap* default_icon_; | 311 static SkBitmap* default_icon_; |
315 | 312 |
316 ExtensionHost* extension_host_; | 313 ExtensionHost* extension_host_; |
317 | 314 |
318 // Cached data about the extension. | 315 // Cached data about the extension. |
319 base::ProcessHandle process_handle_; | 316 base::ProcessHandle process_handle_; |
320 int pid_; | |
321 std::wstring title_; | 317 std::wstring title_; |
| 318 int id_; |
322 | 319 |
323 DISALLOW_COPY_AND_ASSIGN(TaskManagerExtensionProcessResource); | 320 DISALLOW_COPY_AND_ASSIGN(TaskManagerExtensionProcessResource); |
324 }; | 321 }; |
325 | 322 |
326 class TaskManagerExtensionProcessResourceProvider | 323 class TaskManagerExtensionProcessResourceProvider |
327 : public TaskManager::ResourceProvider, | 324 : public TaskManager::ResourceProvider, |
328 public NotificationObserver { | 325 public NotificationObserver { |
329 public: | 326 public: |
330 explicit TaskManagerExtensionProcessResourceProvider( | 327 explicit TaskManagerExtensionProcessResourceProvider( |
331 TaskManager* task_manager); | 328 TaskManager* task_manager); |
332 | 329 |
333 virtual TaskManager::Resource* GetResource(int origin_pid, | 330 virtual TaskManager::Resource* GetResource(int origin_child_id, |
334 int render_process_host_id, | 331 int render_process_host_id, |
335 int routing_id); | 332 int routing_id); |
336 virtual void StartUpdating(); | 333 virtual void StartUpdating(); |
337 virtual void StopUpdating(); | 334 virtual void StopUpdating(); |
338 | 335 |
339 // NotificationObserver method: | 336 // NotificationObserver method: |
340 virtual void Observe(NotificationType type, | 337 virtual void Observe(NotificationType type, |
341 const NotificationSource& source, | 338 const NotificationSource& source, |
342 const NotificationDetails& details); | 339 const NotificationDetails& details); |
343 | 340 |
344 private: | 341 private: |
345 virtual ~TaskManagerExtensionProcessResourceProvider(); | 342 virtual ~TaskManagerExtensionProcessResourceProvider(); |
346 | 343 |
347 void AddToTaskManager(ExtensionHost* extension_host); | 344 void AddToTaskManager(ExtensionHost* extension_host); |
348 void RemoveFromTaskManager(ExtensionHost* extension_host); | 345 void RemoveFromTaskManager(ExtensionHost* extension_host); |
349 | 346 |
350 TaskManager* task_manager_; | 347 TaskManager* task_manager_; |
351 | 348 |
352 // Maps the actual resources (ExtensionHost*) to the Task Manager resources. | 349 // Maps the actual resources (ExtensionHost*) to the Task Manager resources. |
353 std::map<ExtensionHost*, TaskManagerExtensionProcessResource*> resources_; | 350 std::map<ExtensionHost*, TaskManagerExtensionProcessResource*> resources_; |
354 | 351 |
355 // Maps the pids to the resources (used for quick access to the resource on | 352 // Maps the pids to the resources (used for quick access to the resource on |
356 // byte read notifications). | 353 // byte read notifications). |
357 std::map<int, TaskManagerExtensionProcessResource*> pid_to_resources_; | 354 std::map<int, TaskManagerExtensionProcessResource*> child_id_to_resources_; |
358 | 355 |
359 // A scoped container for notification registries. | 356 // A scoped container for notification registries. |
360 NotificationRegistrar registrar_; | 357 NotificationRegistrar registrar_; |
361 | 358 |
362 bool updating_; | 359 bool updating_; |
363 | 360 |
364 DISALLOW_COPY_AND_ASSIGN(TaskManagerExtensionProcessResourceProvider); | 361 DISALLOW_COPY_AND_ASSIGN(TaskManagerExtensionProcessResourceProvider); |
365 }; | 362 }; |
366 | 363 |
367 class TaskManagerNotificationResource : public TaskManager::Resource { | 364 class TaskManagerNotificationResource : public TaskManager::Resource { |
(...skipping 24 matching lines...) Expand all Loading... |
392 DISALLOW_COPY_AND_ASSIGN(TaskManagerNotificationResource); | 389 DISALLOW_COPY_AND_ASSIGN(TaskManagerNotificationResource); |
393 }; | 390 }; |
394 | 391 |
395 class TaskManagerNotificationResourceProvider | 392 class TaskManagerNotificationResourceProvider |
396 : public TaskManager::ResourceProvider, | 393 : public TaskManager::ResourceProvider, |
397 public NotificationObserver { | 394 public NotificationObserver { |
398 public: | 395 public: |
399 explicit TaskManagerNotificationResourceProvider(TaskManager* task_manager); | 396 explicit TaskManagerNotificationResourceProvider(TaskManager* task_manager); |
400 | 397 |
401 // TaskManager::ResourceProvider interface | 398 // TaskManager::ResourceProvider interface |
402 virtual TaskManager::Resource* GetResource(int origin_pid, | 399 virtual TaskManager::Resource* GetResource(int origin_child_id, |
403 int render_process_host_id, | 400 int render_process_host_id, |
404 int routing_id); | 401 int routing_id); |
405 virtual void StartUpdating(); | 402 virtual void StartUpdating(); |
406 virtual void StopUpdating(); | 403 virtual void StopUpdating(); |
407 | 404 |
408 // NotificationObserver interface | 405 // NotificationObserver interface |
409 virtual void Observe(NotificationType type, | 406 virtual void Observe(NotificationType type, |
410 const NotificationSource& source, | 407 const NotificationSource& source, |
411 const NotificationDetails& details); | 408 const NotificationDetails& details); |
412 | 409 |
(...skipping 26 matching lines...) Expand all Loading... |
439 virtual SkBitmap GetIcon() const; | 436 virtual SkBitmap GetIcon() const; |
440 virtual base::ProcessHandle GetProcess() const; | 437 virtual base::ProcessHandle GetProcess() const; |
441 virtual Type GetType() const; | 438 virtual Type GetType() const; |
442 | 439 |
443 virtual bool SupportNetworkUsage() const; | 440 virtual bool SupportNetworkUsage() const; |
444 virtual void SetSupportNetworkUsage(); | 441 virtual void SetSupportNetworkUsage(); |
445 | 442 |
446 virtual bool ReportsSqliteMemoryUsed() const; | 443 virtual bool ReportsSqliteMemoryUsed() const; |
447 virtual size_t SqliteMemoryUsedBytes() const; | 444 virtual size_t SqliteMemoryUsedBytes() const; |
448 | 445 |
449 // Returns the pid of the browser process. | |
450 int process_id() const { return pid_; } | |
451 | |
452 private: | 446 private: |
453 base::ProcessHandle process_; | 447 base::ProcessHandle process_; |
454 int pid_; | |
455 mutable std::wstring title_; | 448 mutable std::wstring title_; |
456 | 449 |
457 static SkBitmap* default_icon_; | 450 static SkBitmap* default_icon_; |
458 | 451 |
459 DISALLOW_COPY_AND_ASSIGN(TaskManagerBrowserProcessResource); | 452 DISALLOW_COPY_AND_ASSIGN(TaskManagerBrowserProcessResource); |
460 }; | 453 }; |
461 | 454 |
462 class TaskManagerBrowserProcessResourceProvider | 455 class TaskManagerBrowserProcessResourceProvider |
463 : public TaskManager::ResourceProvider { | 456 : public TaskManager::ResourceProvider { |
464 public: | 457 public: |
465 explicit TaskManagerBrowserProcessResourceProvider( | 458 explicit TaskManagerBrowserProcessResourceProvider( |
466 TaskManager* task_manager); | 459 TaskManager* task_manager); |
467 | 460 |
468 virtual TaskManager::Resource* GetResource(int origin_pid, | 461 virtual TaskManager::Resource* GetResource(int origin_child_id, |
469 int render_process_host_id, | 462 int render_process_host_id, |
470 int routing_id); | 463 int routing_id); |
471 virtual void StartUpdating(); | 464 virtual void StartUpdating(); |
472 virtual void StopUpdating(); | 465 virtual void StopUpdating(); |
473 | 466 |
474 // Whether we are currently reporting to the task manager. Used to ignore | 467 // Whether we are currently reporting to the task manager. Used to ignore |
475 // notifications sent after StopUpdating(). | 468 // notifications sent after StopUpdating(). |
476 bool updating_; | 469 bool updating_; |
477 | 470 |
478 private: | 471 private: |
479 virtual ~TaskManagerBrowserProcessResourceProvider(); | 472 virtual ~TaskManagerBrowserProcessResourceProvider(); |
480 | 473 |
481 void AddToTaskManager(ChildProcessInfo child_process_info); | 474 void AddToTaskManager(ChildProcessInfo child_process_info); |
482 | 475 |
483 TaskManager* task_manager_; | 476 TaskManager* task_manager_; |
484 TaskManagerBrowserProcessResource resource_; | 477 TaskManagerBrowserProcessResource resource_; |
485 | 478 |
486 DISALLOW_COPY_AND_ASSIGN(TaskManagerBrowserProcessResourceProvider); | 479 DISALLOW_COPY_AND_ASSIGN(TaskManagerBrowserProcessResourceProvider); |
487 }; | 480 }; |
488 | 481 |
489 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_RESOURCE_PROVIDERS_H_ | 482 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_RESOURCE_PROVIDERS_H_ |
OLD | NEW |