Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / task_manager / child_process_resource_provider.h
blob6063e532a64fdb95ef0b920c57e3702ee4da50b5
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.
5 #ifndef CHROME_BROWSER_TASK_MANAGER_CHILD_PROCESS_RESOURCE_PROVIDER_H_
6 #define CHROME_BROWSER_TASK_MANAGER_CHILD_PROCESS_RESOURCE_PROVIDER_H_
8 #include <map>
9 #include <vector>
11 #include "base/basictypes.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"
16 class TaskManager;
18 namespace content {
19 struct ChildProcessData;
22 namespace task_manager {
24 class ChildProcessResource;
26 class ChildProcessResourceProvider
27 : public ResourceProvider,
28 public content::BrowserChildProcessObserver {
29 public:
30 explicit ChildProcessResourceProvider(TaskManager* task_manager);
32 Resource* GetResource(int origin_pid, int child_id, int route_id) override;
33 void StartUpdating() override;
34 void StopUpdating() override;
36 // content::BrowserChildProcessObserver methods:
37 void BrowserChildProcessHostConnected(
38 const content::ChildProcessData& data) override;
39 void BrowserChildProcessHostDisconnected(
40 const content::ChildProcessData& data) override;
42 private:
43 ~ChildProcessResourceProvider() override;
45 // Retrieves information about the running ChildProcessHosts (performed in the
46 // IO thread).
47 virtual void RetrieveChildProcessData();
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);
54 void AddToTaskManager(const content::ChildProcessData& child_process_data);
56 TaskManager* task_manager_;
58 // Whether we are currently reporting to the task manager. Used to ignore
59 // notifications sent after StopUpdating().
60 bool updating_;
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_;
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_;
73 // A scoped container for notification registries.
74 content::NotificationRegistrar registrar_;
76 DISALLOW_COPY_AND_ASSIGN(ChildProcessResourceProvider);
79 } // namespace task_manager
81 #endif // CHROME_BROWSER_TASK_MANAGER_CHILD_PROCESS_RESOURCE_PROVIDER_H_