Chromium Code Reviews| Index: chrome/browser/task_management/providers/web_contents/web_contents_task_provider.cc |
| diff --git a/chrome/browser/task_management/providers/web_contents/web_contents_task_provider.cc b/chrome/browser/task_management/providers/web_contents/web_contents_task_provider.cc |
| index 7cd7c0d624ced81be3d0ff6f67599c1e073b736c..d4f7cda71a7f1d90beb8b4786b718f596cc47fad 100644 |
| --- a/chrome/browser/task_management/providers/web_contents/web_contents_task_provider.cc |
| +++ b/chrome/browser/task_management/providers/web_contents/web_contents_task_provider.cc |
| @@ -35,6 +35,10 @@ class WebContentsEntry : public content::WebContentsObserver { |
| // entry's WebContents. |
| void CreateAllTasks(); |
| + // Clears all the tasks in this entry. The provider's observer will be |
| + // notified if |notify_observer| is true. |
| + void ClearAllTasks(bool notify_observer); |
|
gavinp
2015/06/22 18:38:04
Nit: I think the method definition should move to
afakhry
2015/06/22 21:56:18
Thanks for catching that! I forgot to do it.
Done!
|
| + |
| // Returns the |RendererTask| that corresponds to the given |
| // |render_frame_host| or |nullptr| if the given frame is not tracked by this |
| // entry. |
| @@ -61,10 +65,6 @@ class WebContentsEntry : public content::WebContentsObserver { |
| // notifies the provider's observer of the tasks removal. |
| void ClearTaskForFrame(RenderFrameHost* render_frame_host); |
| - // Clears all the tasks in this entry. The provider's observer will be |
| - // notified if |notify_observer| is true. |
| - void ClearAllTasks(bool notify_observer); |
| - |
| // The provider that owns this entry. |
| WebContentsTaskProvider* provider_; |
| @@ -262,7 +262,8 @@ WebContentsTaskProvider::~WebContentsTaskProvider() { |
| STLDeleteValues(&entries_map_); |
| } |
| -void WebContentsTaskProvider::OnWebContentsTagCreated(WebContentsTag* tag) { |
| +void WebContentsTaskProvider::OnWebContentsTagCreated( |
| + const WebContentsTag* tag) { |
| DCHECK(tag); |
| content::WebContents* web_contents = tag->web_contents(); |
| DCHECK(web_contents); |
| @@ -282,6 +283,22 @@ void WebContentsTaskProvider::OnWebContentsTagCreated(WebContentsTag* tag) { |
| entry->CreateAllTasks(); |
| } |
| +void WebContentsTaskProvider::OnWebContentsTagRemoved( |
| + const WebContentsTag* tag) { |
| + DCHECK(tag); |
| + content::WebContents* web_contents = tag->web_contents(); |
| + DCHECK(web_contents); |
| + |
| + auto itr = entries_map_.find(web_contents); |
| + DCHECK(itr != entries_map_.end()); |
| + WebContentsEntry* entry = itr->second; |
| + |
| + // Must manually clear the tasks and notify the observer. |
| + entry->ClearAllTasks(true); |
| + entries_map_.erase(itr); |
| + delete entry; |
| +} |
| + |
| Task* WebContentsTaskProvider::GetTaskOfUrlRequest(int origin_pid, |
| int child_id, |
| int route_id) { |