Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / task_manager / worker_resource_provider.h
blob25df691a8fec3427c26e462f5abf218f2acb054d
1 // Copyright (c) 2011 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_WORKER_RESOURCE_PROVIDER_H_
6 #define CHROME_BROWSER_TASK_MANAGER_WORKER_RESOURCE_PROVIDER_H_
8 #include <map>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/memory/singleton.h"
13 #include "chrome/browser/task_manager/resource_provider.h"
14 #include "content/public/browser/browser_child_process_observer.h"
15 #include "content/public/browser/worker_service_observer.h"
17 class TaskManager;
19 namespace task_manager {
21 class SharedWorkerResource;
23 class WorkerResourceProvider : public ResourceProvider,
24 public content::BrowserChildProcessObserver,
25 private content::WorkerServiceObserver {
26 public:
27 explicit WorkerResourceProvider(TaskManager* task_manager);
29 private:
30 class WorkerResourceListHolder;
31 typedef std::vector<SharedWorkerResource*> WorkerResourceList;
32 typedef scoped_ptr<SharedWorkerResource> WorkerResourceHolder;
33 typedef std::map<int, WorkerResourceList> ProcessIdToWorkerResources;
35 virtual ~WorkerResourceProvider();
37 // ResourceProvider implementation.
38 virtual Resource* GetResource(int origin_pid,
39 int child_id,
40 int route_id) OVERRIDE;
41 virtual void StartUpdating() OVERRIDE;
42 virtual void StopUpdating() OVERRIDE;
44 // content::BrowserChildProcessObserver implementation.
45 virtual void BrowserChildProcessHostConnected(
46 const content::ChildProcessData& data) OVERRIDE;
47 virtual void BrowserChildProcessHostDisconnected(
48 const content::ChildProcessData& data) OVERRIDE;
50 // content::WorkerServiceObserver implementation.
51 virtual void WorkerCreated(const GURL& url,
52 const base::string16& name,
53 int process_id,
54 int route_id) OVERRIDE;
55 virtual void WorkerDestroyed(int process_id, int route_id) OVERRIDE;
57 void NotifyWorkerCreated(WorkerResourceHolder* resource_holder);
58 void NotifyWorkerDestroyed(int process_id, int routing_id);
60 void StartObservingWorkers();
61 void StopObservingWorkers();
63 void AddWorkerResourceList(WorkerResourceListHolder* resource_list_holder);
64 void AddResource(SharedWorkerResource* resource);
65 void DeleteAllResources();
67 bool updating_;
68 TaskManager* task_manager_;
69 WorkerResourceList resources_;
70 // Map from worker process id to the list of its workers. This list contains
71 // entries for worker processes which has not launched yet but for which we
72 // have already received WorkerCreated event. We don't add such workers to
73 // the task manager until the process is launched.
74 ProcessIdToWorkerResources launching_workers_;
76 DISALLOW_COPY_AND_ASSIGN(WorkerResourceProvider);
79 } // namespace task_manager
81 #endif // CHROME_BROWSER_TASK_MANAGER_WORKER_RESOURCE_PROVIDER_H_