Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: chrome/browser/task_management/providers/web_contents/web_contents_task_provider.cc

Issue 1338023002: Refactor TaskManager's favicon retrieval approach (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/task_management/providers/web_contents/renderer_task.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_management/providers/web_contents/web_contents_tas k_provider.h" 5 #include "chrome/browser/task_management/providers/web_contents/web_contents_tas k_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "chrome/browser/task_management/providers/web_contents/subframe_task.h" 9 #include "chrome/browser/task_management/providers/web_contents/subframe_task.h"
10 #include "chrome/browser/task_management/providers/web_contents/web_contents_tag s_manager.h" 10 #include "chrome/browser/task_management/providers/web_contents/web_contents_tag s_manager.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // content::WebContentsObserver: 47 // content::WebContentsObserver:
48 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; 48 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override;
49 void RenderFrameHostChanged(RenderFrameHost* old_host, 49 void RenderFrameHostChanged(RenderFrameHost* old_host,
50 RenderFrameHost* new_host) override; 50 RenderFrameHost* new_host) override;
51 void RenderViewReady() override; 51 void RenderViewReady() override;
52 void WebContentsDestroyed() override; 52 void WebContentsDestroyed() override;
53 void RenderProcessGone(base::TerminationStatus status) override; 53 void RenderProcessGone(base::TerminationStatus status) override;
54 void DidNavigateMainFrame( 54 void DidNavigateMainFrame(
55 const content::LoadCommittedDetails& details, 55 const content::LoadCommittedDetails& details,
56 const content::FrameNavigateParams& params) override; 56 const content::FrameNavigateParams& params) override;
57 void DocumentOnLoadCompletedInMainFrame() override;
58 void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override; 57 void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override;
59 void DidUpdateFaviconURL(
60 const std::vector<content::FaviconURL>& candidates) override;
61 58
62 private: 59 private:
63 // Defines a callback for WebContents::ForEachFrame() to create a 60 // Defines a callback for WebContents::ForEachFrame() to create a
64 // corresponding task for the given |render_frame_host| and notifying the 61 // corresponding task for the given |render_frame_host| and notifying the
65 // provider's observer of the new task. 62 // provider's observer of the new task.
66 void CreateTaskForFrame(RenderFrameHost* render_frame_host); 63 void CreateTaskForFrame(RenderFrameHost* render_frame_host);
67 64
68 // Clears the task that corresponds to the given |render_frame_host| and 65 // Clears the task that corresponds to the given |render_frame_host| and
69 // notifies the provider's observer of the tasks removal. 66 // notifies the provider's observer of the tasks removal.
70 void ClearTaskForFrame(RenderFrameHost* render_frame_host); 67 void ClearTaskForFrame(RenderFrameHost* render_frame_host);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 auto itr = tasks_by_frames_.find(web_contents()->GetMainFrame()); 164 auto itr = tasks_by_frames_.find(web_contents()->GetMainFrame());
168 if (itr == tasks_by_frames_.end()) { 165 if (itr == tasks_by_frames_.end()) {
169 // TODO(afakhry): Validate whether this actually happens in practice. 166 // TODO(afakhry): Validate whether this actually happens in practice.
170 NOTREACHED(); 167 NOTREACHED();
171 return; 168 return;
172 } 169 }
173 170
174 itr->second->UpdateTitle(); 171 itr->second->UpdateTitle();
175 } 172 }
176 173
177 void WebContentsEntry::DocumentOnLoadCompletedInMainFrame() {
178 // Note: Requesting the task to update its favicon, in any earlier occurring
179 // event than this one, may not work properly. We also need to listen to
180 // WebContentsObserver::DidUpdateFaviconURL().
181 auto itr = tasks_by_frames_.find(web_contents()->GetMainFrame());
182 if (itr == tasks_by_frames_.end()) {
183 // TODO(afakhry): Validate whether this actually happens in practice.
184 NOTREACHED();
185 return;
186 }
187
188 itr->second->UpdateFavicon();
189 }
190
191 void WebContentsEntry::TitleWasSet(content::NavigationEntry* entry, 174 void WebContentsEntry::TitleWasSet(content::NavigationEntry* entry,
192 bool explicit_set) { 175 bool explicit_set) {
193 auto itr = tasks_by_frames_.find(web_contents()->GetMainFrame()); 176 auto itr = tasks_by_frames_.find(web_contents()->GetMainFrame());
194 if (itr == tasks_by_frames_.end()) { 177 if (itr == tasks_by_frames_.end()) {
195 // TODO(afakhry): Validate whether this actually happens in practice. 178 // TODO(afakhry): Validate whether this actually happens in practice.
196 NOTREACHED(); 179 NOTREACHED();
197 return; 180 return;
198 } 181 }
199 182
200 itr->second->UpdateTitle(); 183 itr->second->UpdateTitle();
201 } 184 }
202 185
203 void WebContentsEntry::DidUpdateFaviconURL(
204 const std::vector<content::FaviconURL>& candidates) {
205 auto itr = tasks_by_frames_.find(web_contents()->GetMainFrame());
206 if (itr == tasks_by_frames_.end()) {
207 // TODO(afakhry): Validate whether this actually happens in practice.
208 NOTREACHED();
209 return;
210 }
211
212 itr->second->UpdateFavicon();
213 }
214
215 void WebContentsEntry::CreateTaskForFrame(RenderFrameHost* render_frame_host) { 186 void WebContentsEntry::CreateTaskForFrame(RenderFrameHost* render_frame_host) {
216 DCHECK_EQ(0U, tasks_by_frames_.count(render_frame_host)); 187 DCHECK_EQ(0U, tasks_by_frames_.count(render_frame_host));
217 188
218 content::SiteInstance* site_instance = render_frame_host->GetSiteInstance(); 189 content::SiteInstance* site_instance = render_frame_host->GetSiteInstance();
219 if (!site_instance->GetProcess()->HasConnection()) 190 if (!site_instance->GetProcess()->HasConnection())
220 return; 191 return;
221 192
222 bool site_instance_exists = 193 bool site_instance_exists =
223 frames_by_site_instance_.count(site_instance) != 0U; 194 frames_by_site_instance_.count(site_instance) != 0U;
224 bool is_main_frame = (render_frame_host == web_contents()->GetMainFrame()); 195 bool is_main_frame = (render_frame_host == web_contents()->GetMainFrame());
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 369
399 WebContentsEntry* entry = itr->second; 370 WebContentsEntry* entry = itr->second;
400 entries_map_.erase(itr); 371 entries_map_.erase(itr);
401 372
402 // The entry we're about to delete is our caller, however its' still fine to 373 // The entry we're about to delete is our caller, however its' still fine to
403 // delete it. 374 // delete it.
404 delete entry; 375 delete entry;
405 } 376 }
406 377
407 } // namespace task_management 378 } // namespace task_management
OLDNEW
« no previous file with comments | « chrome/browser/task_management/providers/web_contents/renderer_task.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698