Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / task_management / providers / web_contents / web_contents_task_provider.h
blobaeff7cc9d411e2d22ed3e924e8b698da7fa12056
1 // Copyright 2015 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_MANAGEMENT_PROVIDERS_WEB_CONTENTS_WEB_CONTENTS_TASK_PROVIDER_H_
6 #define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_WEB_CONTENTS_WEB_CONTENTS_TASK_PROVIDER_H_
8 #include <map>
10 #include "chrome/browser/task_management/providers/task_provider.h"
12 namespace content {
13 class WebContents;
14 } // namespace content
17 namespace task_management {
19 class WebContentsEntry;
20 class WebContentsTag;
22 // Defines a provider to provide the renderer tasks that are associated with
23 // various |WebContents| from various services.
24 // There should be no or only one instance of this class at any time.
25 class WebContentsTaskProvider : public TaskProvider {
26 public:
27 WebContentsTaskProvider();
28 ~WebContentsTaskProvider() override;
30 // This will be called every time we're notified that a new |WebContentsTag|
31 // has been created.
32 void OnWebContentsTagCreated(const WebContentsTag* tag);
34 // Manually remove |tag|'s corresponding Task.
35 void OnWebContentsTagRemoved(const WebContentsTag* tag);
37 // task_management::TaskProvider:
38 Task* GetTaskOfUrlRequest(int origin_pid,
39 int child_id,
40 int route_id) override;
42 // Checks if the given |web_contents| is tracked by the provider.
43 bool HasWebContents(content::WebContents* web_contents) const;
45 private:
46 friend class WebContentsEntry;
48 // task_management::TaskProvider:
49 void StartUpdating() override;
50 void StopUpdating() override;
52 // Called when the given |web_contents| are destroyed so that we can delete
53 // its associated entry.
54 void DeleteEntry(content::WebContents* web_contents);
56 // A map to associate a |WebContents| with its corresponding entry that we
57 // create for it to be able to track it.
58 typedef std::map<content::WebContents*, WebContentsEntry*> EntryMap;
59 EntryMap entries_map_;
61 // True if this provider is listening to WebContentsTags and updating its
62 // observers, false otherwise.
63 bool is_updating_;
65 DISALLOW_COPY_AND_ASSIGN(WebContentsTaskProvider);
68 } // namespace task_management
70 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_WEB_CONTENTS_WEB_CONTENTS_TASK_PROVIDER_H_