OLD | NEW |
| (Empty) |
1 // Copyright 2013 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_MANAGER_TASK_MANAGER_CHILD_PROCESS_RESOURCE_PROVIDER
_H_ | |
6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_CHILD_PROCESS_RESOURCE_PROVIDER
_H_ | |
7 | |
8 #include <map> | |
9 #include <vector> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "chrome/browser/task_manager/task_manager.h" | |
13 #include "content/public/browser/browser_child_process_observer.h" | |
14 #include "content/public/browser/notification_registrar.h" | |
15 | |
16 class TaskManagerChildProcessResource; | |
17 | |
18 namespace content { | |
19 struct ChildProcessData; | |
20 } | |
21 | |
22 class TaskManagerChildProcessResourceProvider | |
23 : public TaskManager::ResourceProvider, | |
24 public content::BrowserChildProcessObserver { | |
25 public: | |
26 explicit TaskManagerChildProcessResourceProvider(TaskManager* task_manager); | |
27 | |
28 virtual TaskManager::Resource* GetResource(int origin_pid, | |
29 int render_process_host_id, | |
30 int routing_id) OVERRIDE; | |
31 virtual void StartUpdating() OVERRIDE; | |
32 virtual void StopUpdating() OVERRIDE; | |
33 | |
34 // content::BrowserChildProcessObserver methods: | |
35 virtual void BrowserChildProcessHostConnected( | |
36 const content::ChildProcessData& data) OVERRIDE; | |
37 virtual void BrowserChildProcessHostDisconnected( | |
38 const content::ChildProcessData& data) OVERRIDE; | |
39 | |
40 private: | |
41 virtual ~TaskManagerChildProcessResourceProvider(); | |
42 | |
43 // Retrieves information about the running ChildProcessHosts (performed in the | |
44 // IO thread). | |
45 virtual void RetrieveChildProcessData(); | |
46 | |
47 // Notifies the UI thread that the ChildProcessHosts information have been | |
48 // retrieved. | |
49 virtual void ChildProcessDataRetreived( | |
50 const std::vector<content::ChildProcessData>& child_processes); | |
51 | |
52 void AddToTaskManager(const content::ChildProcessData& child_process_data); | |
53 | |
54 TaskManager* task_manager_; | |
55 | |
56 // Whether we are currently reporting to the task manager. Used to ignore | |
57 // notifications sent after StopUpdating(). | |
58 bool updating_; | |
59 | |
60 // Maps the actual resources (the ChildProcessData) to the Task Manager | |
61 // resources. | |
62 typedef std::map<base::ProcessHandle, TaskManagerChildProcessResource*> | |
63 ChildProcessMap; | |
64 ChildProcessMap resources_; | |
65 | |
66 // Maps the pids to the resources (used for quick access to the resource on | |
67 // byte read notifications). | |
68 typedef std::map<int, TaskManagerChildProcessResource*> PidResourceMap; | |
69 PidResourceMap pid_to_resources_; | |
70 | |
71 // A scoped container for notification registries. | |
72 content::NotificationRegistrar registrar_; | |
73 | |
74 DISALLOW_COPY_AND_ASSIGN(TaskManagerChildProcessResourceProvider); | |
75 }; | |
76 | |
77 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_CHILD_PROCESS_RESOURCE_PROVI
DER_H_ | |
OLD | NEW |