| 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/macros.h" | |
| 12 #include "chrome/browser/task_manager/resource_provider.h" | |
| 13 #include "content/public/browser/browser_child_process_observer.h" | |
| 14 #include "content/public/browser/notification_registrar.h" | |
| 15 | |
| 16 class TaskManager; | |
| 17 | |
| 18 namespace content { | |
| 19 struct ChildProcessData; | |
| 20 } | |
| 21 | |
| 22 namespace task_manager { | |
| 23 | |
| 24 class ChildProcessResource; | |
| 25 | |
| 26 class ChildProcessResourceProvider | |
| 27 : public ResourceProvider, | |
| 28 public content::BrowserChildProcessObserver { | |
| 29 public: | |
| 30 explicit ChildProcessResourceProvider(TaskManager* task_manager); | |
| 31 | |
| 32 Resource* GetResource(int origin_pid, int child_id, int route_id) override; | |
| 33 void StartUpdating() override; | |
| 34 void StopUpdating() override; | |
| 35 | |
| 36 // content::BrowserChildProcessObserver methods: | |
| 37 void BrowserChildProcessHostConnected( | |
| 38 const content::ChildProcessData& data) override; | |
| 39 void BrowserChildProcessHostDisconnected( | |
| 40 const content::ChildProcessData& data) override; | |
| 41 | |
| 42 private: | |
| 43 ~ChildProcessResourceProvider() override; | |
| 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 |