Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: chrome/browser/task_manager/child_process_resource_provider.h

Issue 15196003: Create task_manager namespace and wrap classes related to TaskManager with it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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_CHILD_PROCESS_RESOURCE_PROVIDER _H_ 5 #ifndef CHROME_BROWSER_TASK_MANAGER_CHILD_PROCESS_RESOURCE_PROVIDER_H_
6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_CHILD_PROCESS_RESOURCE_PROVIDER _H_ 6 #define CHROME_BROWSER_TASK_MANAGER_CHILD_PROCESS_RESOURCE_PROVIDER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "chrome/browser/task_manager/task_manager.h" 12 #include "chrome/browser/task_manager/task_manager.h"
13 #include "content/public/browser/browser_child_process_observer.h" 13 #include "content/public/browser/browser_child_process_observer.h"
14 #include "content/public/browser/notification_registrar.h" 14 #include "content/public/browser/notification_registrar.h"
15 15
16 class TaskManagerChildProcessResource;
17
18 namespace content { 16 namespace content {
19 struct ChildProcessData; 17 struct ChildProcessData;
20 } 18 }
21 19
22 class TaskManagerChildProcessResourceProvider 20 namespace task_manager {
21
22 class ChildProcessResource;
23
24 class ChildProcessResourceProvider
23 : public TaskManager::ResourceProvider, 25 : public TaskManager::ResourceProvider,
24 public content::BrowserChildProcessObserver { 26 public content::BrowserChildProcessObserver {
25 public: 27 public:
26 explicit TaskManagerChildProcessResourceProvider(TaskManager* task_manager); 28 explicit ChildProcessResourceProvider(TaskManager* task_manager);
27 29
28 virtual TaskManager::Resource* GetResource(int origin_pid, 30 virtual TaskManager::Resource* GetResource(int origin_pid,
29 int render_process_host_id, 31 int render_process_host_id,
30 int routing_id) OVERRIDE; 32 int routing_id) OVERRIDE;
31 virtual void StartUpdating() OVERRIDE; 33 virtual void StartUpdating() OVERRIDE;
32 virtual void StopUpdating() OVERRIDE; 34 virtual void StopUpdating() OVERRIDE;
33 35
34 // content::BrowserChildProcessObserver methods: 36 // content::BrowserChildProcessObserver methods:
35 virtual void BrowserChildProcessHostConnected( 37 virtual void BrowserChildProcessHostConnected(
36 const content::ChildProcessData& data) OVERRIDE; 38 const content::ChildProcessData& data) OVERRIDE;
37 virtual void BrowserChildProcessHostDisconnected( 39 virtual void BrowserChildProcessHostDisconnected(
38 const content::ChildProcessData& data) OVERRIDE; 40 const content::ChildProcessData& data) OVERRIDE;
39 41
40 private: 42 private:
41 virtual ~TaskManagerChildProcessResourceProvider(); 43 virtual ~ChildProcessResourceProvider();
42 44
43 // Retrieves information about the running ChildProcessHosts (performed in the 45 // Retrieves information about the running ChildProcessHosts (performed in the
44 // IO thread). 46 // IO thread).
45 virtual void RetrieveChildProcessData(); 47 virtual void RetrieveChildProcessData();
46 48
47 // Notifies the UI thread that the ChildProcessHosts information have been 49 // Notifies the UI thread that the ChildProcessHosts information have been
48 // retrieved. 50 // retrieved.
49 virtual void ChildProcessDataRetreived( 51 virtual void ChildProcessDataRetreived(
50 const std::vector<content::ChildProcessData>& child_processes); 52 const std::vector<content::ChildProcessData>& child_processes);
51 53
52 void AddToTaskManager(const content::ChildProcessData& child_process_data); 54 void AddToTaskManager(const content::ChildProcessData& child_process_data);
53 55
54 TaskManager* task_manager_; 56 TaskManager* task_manager_;
55 57
56 // Whether we are currently reporting to the task manager. Used to ignore 58 // Whether we are currently reporting to the task manager. Used to ignore
57 // notifications sent after StopUpdating(). 59 // notifications sent after StopUpdating().
58 bool updating_; 60 bool updating_;
59 61
60 // Maps the actual resources (the ChildProcessData) to the Task Manager 62 // Maps the actual resources (the ChildProcessData) to the Task Manager
61 // resources. 63 // resources.
62 typedef std::map<base::ProcessHandle, TaskManagerChildProcessResource*> 64 typedef std::map<base::ProcessHandle, ChildProcessResource*>
63 ChildProcessMap; 65 ChildProcessMap;
64 ChildProcessMap resources_; 66 ChildProcessMap resources_;
65 67
66 // Maps the pids to the resources (used for quick access to the resource on 68 // Maps the pids to the resources (used for quick access to the resource on
67 // byte read notifications). 69 // byte read notifications).
68 typedef std::map<int, TaskManagerChildProcessResource*> PidResourceMap; 70 typedef std::map<int, ChildProcessResource*> PidResourceMap;
69 PidResourceMap pid_to_resources_; 71 PidResourceMap pid_to_resources_;
70 72
71 // A scoped container for notification registries. 73 // A scoped container for notification registries.
72 content::NotificationRegistrar registrar_; 74 content::NotificationRegistrar registrar_;
73 75
74 DISALLOW_COPY_AND_ASSIGN(TaskManagerChildProcessResourceProvider); 76 DISALLOW_COPY_AND_ASSIGN(ChildProcessResourceProvider);
75 }; 77 };
76 78
77 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_CHILD_PROCESS_RESOURCE_PROVI DER_H_ 79 } // namespace task_manager
80
81 #endif // CHROME_BROWSER_TASK_MANAGER_CHILD_PROCESS_RESOURCE_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698