Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/task_manager/providers/web_contents/web_contents_task_p rovider.h" | 5 #include "chrome/browser/task_manager/providers/web_contents/web_contents_task_p rovider.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "chrome/browser/task_manager/providers/web_contents/subframe_task.h" | 9 #include "chrome/browser/task_manager/providers/web_contents/subframe_task.h" |
| 10 #include "chrome/browser/task_manager/providers/web_contents/web_contents_tags_m anager.h" | 10 #include "chrome/browser/task_manager/providers/web_contents/web_contents_tags_m anager.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 // Clears the task that corresponds to the given |render_frame_host| and | 67 // Clears the task that corresponds to the given |render_frame_host| and |
| 68 // notifies the provider's observer of the tasks removal. | 68 // notifies the provider's observer of the tasks removal. |
| 69 void ClearTaskForFrame(RenderFrameHost* render_frame_host); | 69 void ClearTaskForFrame(RenderFrameHost* render_frame_host); |
| 70 | 70 |
| 71 // The provider that owns this entry. | 71 // The provider that owns this entry. |
| 72 WebContentsTaskProvider* provider_; | 72 WebContentsTaskProvider* provider_; |
| 73 | 73 |
| 74 // The RenderFrameHosts associated with this entry's WebContents that we're | 74 // The RenderFrameHosts associated with this entry's WebContents that we're |
| 75 // tracking mapped by their SiteInstances. | 75 // tracking mapped by their SiteInstances. |
| 76 using FramesList = std::vector<RenderFrameHost*>; | 76 using FramesList = std::vector<RenderFrameHost*>; |
| 77 using SiteInstanceToFramesMap = std::map<SiteInstance*, FramesList>; | 77 std::map<SiteInstance*, FramesList> frames_by_site_instance_; |
| 78 SiteInstanceToFramesMap frames_by_site_instance_; | |
| 79 | 78 |
| 80 // The RendererTasks that we create for the task manager, mapped by their | 79 // The RendererTasks that we create for the task manager, mapped by their |
| 81 // RenderFrameHosts. | 80 // RenderFrameHosts. This owns the RenderTasks. |
| 82 using FramesToTasksMap = std::map<RenderFrameHost*, RendererTask*>; | 81 std::map<RenderFrameHost*, RendererTask*> tasks_by_frames_; |
| 83 FramesToTasksMap tasks_by_frames_; | |
| 84 | 82 |
| 85 // States whether we did record a main frame for this entry. | 83 // States whether we did record a main frame for this entry. |
| 86 SiteInstance* main_frame_site_instance_; | 84 SiteInstance* main_frame_site_instance_; |
| 87 | 85 |
| 88 DISALLOW_COPY_AND_ASSIGN(WebContentsEntry); | 86 DISALLOW_COPY_AND_ASSIGN(WebContentsEntry); |
| 89 }; | 87 }; |
| 90 | 88 |
| 91 //////////////////////////////////////////////////////////////////////////////// | 89 //////////////////////////////////////////////////////////////////////////////// |
| 92 | 90 |
| 93 WebContentsEntry::WebContentsEntry(content::WebContents* web_contents, | 91 WebContentsEntry::WebContentsEntry(content::WebContents* web_contents, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 return; | 164 return; |
| 167 | 165 |
| 168 DCHECK_EQ(render_widget_host->GetProcess(), | 166 DCHECK_EQ(render_widget_host->GetProcess(), |
| 169 web_contents()->GetMainFrame()->GetProcess()); | 167 web_contents()->GetMainFrame()->GetProcess()); |
| 170 | 168 |
| 171 provider_->NotifyObserverTaskUnresponsive(task); | 169 provider_->NotifyObserverTaskUnresponsive(task); |
| 172 } | 170 } |
| 173 | 171 |
| 174 void WebContentsEntry::DidFinishNavigation( | 172 void WebContentsEntry::DidFinishNavigation( |
| 175 content::NavigationHandle* navigation_handle) { | 173 content::NavigationHandle* navigation_handle) { |
| 176 RendererTask* task = GetTaskForFrame(web_contents()->GetMainFrame()); | 174 RendererTask* main_frame_task = |
| 177 if (!task) | 175 GetTaskForFrame(web_contents()->GetMainFrame()); |
| 176 if (!main_frame_task) | |
| 178 return; | 177 return; |
| 179 | 178 |
| 180 // Listening to WebContentsObserver::TitleWasSet() only is not enough in | 179 main_frame_task->UpdateRapporSampleName(); |
|
ncarter (slow)
2016/10/26 17:45:27
Maybe do this only if navigation_handle->IsInMainF
Avi (use Gerrit)
2016/10/26 20:37:28
Maybe? I'm not sure if that would change the rappo
ncarter (slow)
2016/10/26 20:55:48
Ah, ignore this comment; I was mistaken about what
| |
| 181 // some cases when the the webpage doesn't have a title. That's why we update | |
| 182 // the title here as well. | |
| 183 task->UpdateTitle(); | |
| 184 | 180 |
| 185 // Call RendererTask::UpdateFavicon() to set the current favicon to the | 181 for (const auto& frame_pair : tasks_by_frames_) { |
|
ncarter (slow)
2016/10/26 17:45:27
In the a(b, b) case, or the non-oopif case, this w
Avi (use Gerrit)
2016/10/26 20:37:28
Done.
| |
| 186 // default favicon. If the page has a non-default favicon, | 182 // Listening to WebContentsObserver::TitleWasSet() only is not enough in |
| 187 // RendererTask::OnFaviconUpdated() will update the current favicon once | 183 // some cases when the the web page doesn't have a title. That's why we |
| 188 // FaviconDriver figures out the correct favicon for the page. | 184 // update the title here as well. |
| 189 task->UpdateFavicon(); | 185 frame_pair.second->UpdateTitle(); |
| 190 task->UpdateRapporSampleName(); | 186 |
| 187 // Call RendererTask::UpdateFavicon() to set the current favicon to the | |
| 188 // default favicon. If the page has a non-default favicon, | |
| 189 // RendererTask::OnFaviconUpdated() will update the current favicon once | |
| 190 // FaviconDriver figures out the correct favicon for the page. | |
| 191 frame_pair.second->UpdateFavicon(); | |
| 192 } | |
| 191 } | 193 } |
| 192 | 194 |
| 193 void WebContentsEntry::TitleWasSet(content::NavigationEntry* entry, | 195 void WebContentsEntry::TitleWasSet(content::NavigationEntry* entry, |
| 194 bool explicit_set) { | 196 bool explicit_set) { |
| 195 RendererTask* task = GetTaskForFrame(web_contents()->GetMainFrame()); | 197 for (const auto& frame_pair : tasks_by_frames_) { |
|
ncarter (slow)
2016/10/26 17:45:27
Same here. Might be worth extracting a function to
Avi (use Gerrit)
2016/10/26 20:37:28
Done.
| |
| 196 if (!task) | 198 frame_pair.second->UpdateTitle(); |
| 197 return; | 199 frame_pair.second->UpdateFavicon(); |
| 198 | 200 } |
| 199 task->UpdateTitle(); | |
| 200 task->UpdateFavicon(); | |
| 201 } | 201 } |
| 202 | 202 |
| 203 void WebContentsEntry::CreateTaskForFrame(RenderFrameHost* render_frame_host) { | 203 void WebContentsEntry::CreateTaskForFrame(RenderFrameHost* render_frame_host) { |
| 204 DCHECK(!tasks_by_frames_.count(render_frame_host)); | 204 DCHECK(!tasks_by_frames_.count(render_frame_host)); |
| 205 | 205 |
| 206 content::SiteInstance* site_instance = render_frame_host->GetSiteInstance(); | 206 content::SiteInstance* site_instance = render_frame_host->GetSiteInstance(); |
| 207 if (!site_instance->GetProcess()->HasConnection()) | 207 if (!site_instance->GetProcess()->HasConnection()) |
| 208 return; | 208 return; |
| 209 | 209 |
| 210 bool site_instance_exists = | 210 bool site_instance_exists = |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 } | 376 } |
| 377 | 377 |
| 378 void WebContentsTaskProvider::DeleteEntry(content::WebContents* web_contents) { | 378 void WebContentsTaskProvider::DeleteEntry(content::WebContents* web_contents) { |
| 379 // This erase() will delete the WebContentsEntry, which is actually our | 379 // This erase() will delete the WebContentsEntry, which is actually our |
| 380 // caller, but it's expecting us to delete it. | 380 // caller, but it's expecting us to delete it. |
| 381 bool success = entries_map_.erase(web_contents) != 0; | 381 bool success = entries_map_.erase(web_contents) != 0; |
| 382 DCHECK(success); | 382 DCHECK(success); |
| 383 } | 383 } |
| 384 | 384 |
| 385 } // namespace task_manager | 385 } // namespace task_manager |
| OLD | NEW |