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_
10 #include "chrome/browser/task_management/providers/task_provider.h"
14 } // namespace content
17 namespace task_management
{
19 class WebContentsEntry
;
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
{
27 WebContentsTaskProvider();
28 ~WebContentsTaskProvider() override
;
30 // This will be called every time we're notified that a new |WebContentsTag|
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
,
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;
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.
65 DISALLOW_COPY_AND_ASSIGN(WebContentsTaskProvider
);
68 } // namespace task_management
70 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_WEB_CONTENTS_WEB_CONTENTS_TASK_PROVIDER_H_