Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / task_manager / child_process_resource_provider.h
blob6998d6df2e7d48d7bb699a64f3c8226776ac400a
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 virtual Resource* GetResource(int origin_pid,
33 int child_id,
34 int route_id) OVERRIDE;
35 virtual void StartUpdating() OVERRIDE;
36 virtual void StopUpdating() OVERRIDE;
38 // content::BrowserChildProcessObserver methods:
39 virtual void BrowserChildProcessHostConnected(
40 const content::ChildProcessData& data) OVERRIDE;
41 virtual void BrowserChildProcessHostDisconnected(
42 const content::ChildProcessData& data) OVERRIDE;
44 private:
45 virtual ~ChildProcessResourceProvider();
47 // Retrieves information about the running ChildProcessHosts (performed in the
48 // IO thread).
49 virtual void RetrieveChildProcessData();
51 // Notifies the UI thread that the ChildProcessHosts information have been
52 // retrieved.
53 virtual void ChildProcessDataRetreived(
54 const std::vector<content::ChildProcessData>& child_processes);
56 void AddToTaskManager(const content::ChildProcessData& child_process_data);
58 TaskManager* task_manager_;
60 // Whether we are currently reporting to the task manager. Used to ignore
61 // notifications sent after StopUpdating().
62 bool updating_;
64 // Maps the actual resources (the ChildProcessData) to the Task Manager
65 // resources.
66 typedef std::map<base::ProcessHandle, ChildProcessResource*>
67 ChildProcessMap;
68 ChildProcessMap resources_;
70 // Maps the pids to the resources (used for quick access to the resource on
71 // byte read notifications).
72 typedef std::map<int, ChildProcessResource*> PidResourceMap;
73 PidResourceMap pid_to_resources_;
75 // A scoped container for notification registries.
76 content::NotificationRegistrar registrar_;
78 DISALLOW_COPY_AND_ASSIGN(ChildProcessResourceProvider);
81 } // namespace task_manager
83 #endif // CHROME_BROWSER_TASK_MANAGER_CHILD_PROCESS_RESOURCE_PROVIDER_H_