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_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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 void RenderFrameHostChanged(RenderFrameHost* old_host, | 45 void RenderFrameHostChanged(RenderFrameHost* old_host, |
46 RenderFrameHost* new_host) override; | 46 RenderFrameHost* new_host) override; |
47 void RenderViewReady() override; | 47 void RenderViewReady() override; |
48 void WebContentsDestroyed() override; | 48 void WebContentsDestroyed() override; |
49 void RenderProcessGone(base::TerminationStatus status) override; | 49 void RenderProcessGone(base::TerminationStatus status) override; |
50 void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override; | 50 void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override; |
51 void DidUpdateFaviconURL( | 51 void DidUpdateFaviconURL( |
52 const std::vector<content::FaviconURL>& candidates) override; | 52 const std::vector<content::FaviconURL>& candidates) override; |
53 | 53 |
54 private: | 54 private: |
55 friend class WebContentsTaskProvider; | |
ncarter (slow)
2015/06/19 19:50:51
WebContentsTaskProvider is the only class that can
afakhry
2015/06/19 21:49:22
Done.
| |
55 // Defines a callback for WebContents::ForEachFrame() to create a | 56 // Defines a callback for WebContents::ForEachFrame() to create a |
56 // corresponding task for the given |render_frame_host| and notifying the | 57 // corresponding task for the given |render_frame_host| and notifying the |
57 // provider's observer of the new task. | 58 // provider's observer of the new task. |
58 void CreateTaskForFrame(RenderFrameHost* render_frame_host); | 59 void CreateTaskForFrame(RenderFrameHost* render_frame_host); |
59 | 60 |
60 // Clears the task that corresponds to the given |render_frame_host| and | 61 // Clears the task that corresponds to the given |render_frame_host| and |
61 // notifies the provider's observer of the tasks removal. | 62 // notifies the provider's observer of the tasks removal. |
62 void ClearTaskForFrame(RenderFrameHost* render_frame_host); | 63 void ClearTaskForFrame(RenderFrameHost* render_frame_host); |
63 | 64 |
64 // Clears all the tasks in this entry. The provider's observer will be | 65 // Clears all the tasks in this entry. The provider's observer will be |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 // notification of its connection hasn't been fired yet. In this case we | 276 // notification of its connection hasn't been fired yet. In this case we |
276 // ignore it since we're already tracking it. | 277 // ignore it since we're already tracking it. |
277 return; | 278 return; |
278 } | 279 } |
279 | 280 |
280 WebContentsEntry* entry = new WebContentsEntry(web_contents, this); | 281 WebContentsEntry* entry = new WebContentsEntry(web_contents, this); |
281 entries_map_[web_contents] = entry; | 282 entries_map_[web_contents] = entry; |
282 entry->CreateAllTasks(); | 283 entry->CreateAllTasks(); |
283 } | 284 } |
284 | 285 |
286 void WebContentsTaskProvider::OnWebContentsTagRemoved(WebContentsTag* tag) { | |
287 DCHECK(tag); | |
288 content::WebContents* web_contents = tag->web_contents(); | |
289 DCHECK(web_contents); | |
290 | |
291 auto itr = entries_map_.find(web_contents); | |
292 DCHECK(itr != entries_map_.end()); | |
293 WebContentsEntry* entry = itr->second; | |
294 | |
295 // Must manually clear the tasks and notifying the observer. | |
ncarter (slow)
2015/06/19 19:50:51
notifying->notify
afakhry
2015/06/19 21:49:22
Done.
| |
296 entry->ClearAllTasks(true); | |
297 entries_map_.erase(itr); | |
298 delete entry; | |
299 } | |
300 | |
285 Task* WebContentsTaskProvider::GetTaskOfUrlRequest(int origin_pid, | 301 Task* WebContentsTaskProvider::GetTaskOfUrlRequest(int origin_pid, |
286 int child_id, | 302 int child_id, |
287 int route_id) { | 303 int route_id) { |
288 // If an origin PID was specified then the URL request originated in a plugin | 304 // If an origin PID was specified then the URL request originated in a plugin |
289 // working on the WebContents' behalf, so ignore it. | 305 // working on the WebContents' behalf, so ignore it. |
290 if (origin_pid) | 306 if (origin_pid) |
291 return nullptr; | 307 return nullptr; |
292 | 308 |
293 content::RenderFrameHost* rfh = | 309 content::RenderFrameHost* rfh = |
294 content::RenderFrameHost::FromID(child_id, route_id); | 310 content::RenderFrameHost::FromID(child_id, route_id); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
337 | 353 |
338 WebContentsEntry* entry = itr->second; | 354 WebContentsEntry* entry = itr->second; |
339 entries_map_.erase(itr); | 355 entries_map_.erase(itr); |
340 | 356 |
341 // The entry we're about to delete is our caller, however its' still fine to | 357 // The entry we're about to delete is our caller, however its' still fine to |
342 // delete it. | 358 // delete it. |
343 delete entry; | 359 delete entry; |
344 } | 360 } |
345 | 361 |
346 } // namespace task_management | 362 } // namespace task_management |
OLD | NEW |