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