OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/process_util.h" | 14 #include "base/process_util.h" |
15 #include "chrome/browser/task_manager/task_manager.h" | 15 #include "chrome/browser/task_manager/task_manager.h" |
| 16 #include "content/public/browser/child_process_data.h" |
16 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
18 #include "content/public/common/process_type.h" | 19 #include "content/public/common/process_type.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" |
20 | 21 |
21 class BackgroundContents; | 22 class BackgroundContents; |
22 class BalloonHost; | 23 class BalloonHost; |
23 class Extension; | 24 class Extension; |
24 class ExtensionHost; | 25 class ExtensionHost; |
25 class RenderViewHost; | 26 class RenderViewHost; |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 int routing_id) OVERRIDE; | 282 int routing_id) OVERRIDE; |
282 virtual void StartUpdating() OVERRIDE; | 283 virtual void StartUpdating() OVERRIDE; |
283 virtual void StopUpdating() OVERRIDE; | 284 virtual void StopUpdating() OVERRIDE; |
284 | 285 |
285 // content::NotificationObserver method: | 286 // content::NotificationObserver method: |
286 virtual void Observe(int type, | 287 virtual void Observe(int type, |
287 const content::NotificationSource& source, | 288 const content::NotificationSource& source, |
288 const content::NotificationDetails& details) OVERRIDE; | 289 const content::NotificationDetails& details) OVERRIDE; |
289 | 290 |
290 private: | 291 private: |
291 struct ChildProcessData { | |
292 content::ProcessType type; | |
293 string16 name; | |
294 base::ProcessHandle handle; | |
295 }; | |
296 | |
297 virtual ~TaskManagerChildProcessResourceProvider(); | 292 virtual ~TaskManagerChildProcessResourceProvider(); |
298 | 293 |
299 // Retrieves information about the running ChildProcessHosts (performed in the | 294 // Retrieves information about the running ChildProcessHosts (performed in the |
300 // IO thread). | 295 // IO thread). |
301 virtual void RetrieveChildProcessInfo(); | 296 virtual void RetrieveChildProcessData(); |
302 | 297 |
303 // Notifies the UI thread that the ChildProcessHosts information have been | 298 // Notifies the UI thread that the ChildProcessHosts information have been |
304 // retrieved. | 299 // retrieved. |
305 virtual void ChildProcessInfoRetreived( | 300 virtual void ChildProcessDataRetreived( |
306 const std::vector<ChildProcessData>& child_processes); | 301 const std::vector<content::ChildProcessData>& child_processes); |
307 | 302 |
308 void Add(const ChildProcessData& child_process_data); | 303 void Add(const content::ChildProcessData& child_process_data); |
309 void Remove(const ChildProcessData& child_process_data); | 304 void Remove(const content::ChildProcessData& child_process_data); |
310 | 305 |
311 void AddToTaskManager(const ChildProcessData& child_process_data); | 306 void AddToTaskManager(const content::ChildProcessData& child_process_data); |
312 | 307 |
313 TaskManager* task_manager_; | 308 TaskManager* task_manager_; |
314 | 309 |
315 // Whether we are currently reporting to the task manager. Used to ignore | 310 // Whether we are currently reporting to the task manager. Used to ignore |
316 // notifications sent after StopUpdating(). | 311 // notifications sent after StopUpdating(). |
317 bool updating_; | 312 bool updating_; |
318 | 313 |
319 // Maps the actual resources (the ChildProcessInfo) to the Task Manager | 314 // Maps the actual resources (the ChildProcessData) to the Task Manager |
320 // resources. | 315 // resources. |
321 typedef std::map<base::ProcessHandle, TaskManagerChildProcessResource*> | 316 typedef std::map<base::ProcessHandle, TaskManagerChildProcessResource*> |
322 ChildProcessMap; | 317 ChildProcessMap; |
323 ChildProcessMap resources_; | 318 ChildProcessMap resources_; |
324 | 319 |
325 // Maps the pids to the resources (used for quick access to the resource on | 320 // Maps the pids to the resources (used for quick access to the resource on |
326 // byte read notifications). | 321 // byte read notifications). |
327 typedef std::map<int, TaskManagerChildProcessResource*> PidResourceMap; | 322 typedef std::map<int, TaskManagerChildProcessResource*> PidResourceMap; |
328 PidResourceMap pid_to_resources_; | 323 PidResourceMap pid_to_resources_; |
329 | 324 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 private: | 526 private: |
532 virtual ~TaskManagerBrowserProcessResourceProvider(); | 527 virtual ~TaskManagerBrowserProcessResourceProvider(); |
533 | 528 |
534 TaskManager* task_manager_; | 529 TaskManager* task_manager_; |
535 TaskManagerBrowserProcessResource resource_; | 530 TaskManagerBrowserProcessResource resource_; |
536 | 531 |
537 DISALLOW_COPY_AND_ASSIGN(TaskManagerBrowserProcessResourceProvider); | 532 DISALLOW_COPY_AND_ASSIGN(TaskManagerBrowserProcessResourceProvider); |
538 }; | 533 }; |
539 | 534 |
540 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_RESOURCE_PROVIDERS_H_ | 535 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_RESOURCE_PROVIDERS_H_ |
OLD | NEW |