OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/web_contents_resource_provider.h" | 5 #include "chrome/browser/task_manager/web_contents_resource_provider.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 // A resource for a process hosting out-of-process iframes. | 37 // A resource for a process hosting out-of-process iframes. |
38 class SubframeResource : public RendererResource { | 38 class SubframeResource : public RendererResource { |
39 public: | 39 public: |
40 explicit SubframeResource(WebContents* web_contents, | 40 explicit SubframeResource(WebContents* web_contents, |
41 SiteInstance* site_instance, | 41 SiteInstance* site_instance, |
42 RenderFrameHost* example_rfh); | 42 RenderFrameHost* example_rfh); |
43 virtual ~SubframeResource() {} | 43 virtual ~SubframeResource() {} |
44 | 44 |
45 // Resource methods: | 45 // Resource methods: |
46 virtual Type GetType() const OVERRIDE; | 46 virtual Type GetType() const override; |
47 virtual base::string16 GetTitle() const OVERRIDE; | 47 virtual base::string16 GetTitle() const override; |
48 virtual gfx::ImageSkia GetIcon() const OVERRIDE; | 48 virtual gfx::ImageSkia GetIcon() const override; |
49 virtual WebContents* GetWebContents() const OVERRIDE; | 49 virtual WebContents* GetWebContents() const override; |
50 | 50 |
51 private: | 51 private: |
52 WebContents* web_contents_; | 52 WebContents* web_contents_; |
53 base::string16 title_; | 53 base::string16 title_; |
54 DISALLOW_COPY_AND_ASSIGN(SubframeResource); | 54 DISALLOW_COPY_AND_ASSIGN(SubframeResource); |
55 }; | 55 }; |
56 | 56 |
57 SubframeResource::SubframeResource(WebContents* web_contents, | 57 SubframeResource::SubframeResource(WebContents* web_contents, |
58 SiteInstance* subframe_site_instance, | 58 SiteInstance* subframe_site_instance, |
59 RenderFrameHost* example_rfh) | 59 RenderFrameHost* example_rfh) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // Advance to next non-duplicate entry. | 105 // Advance to next non-duplicate entry. |
106 do { | 106 do { |
107 ++j; | 107 ++j; |
108 } while (j != resources_by_site_instance_.end() && resource == j->second); | 108 } while (j != resources_by_site_instance_.end() && resource == j->second); |
109 | 109 |
110 delete resource; | 110 delete resource; |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 // content::WebContentsObserver implementation. | 114 // content::WebContentsObserver implementation. |
115 virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) OVERRIDE { | 115 virtual void RenderFrameDeleted(RenderFrameHost* render_frame_host) override { |
116 ClearResourceForFrame(render_frame_host); | 116 ClearResourceForFrame(render_frame_host); |
117 } | 117 } |
118 | 118 |
119 virtual void RenderFrameHostChanged(RenderFrameHost* old_host, | 119 virtual void RenderFrameHostChanged(RenderFrameHost* old_host, |
120 RenderFrameHost* new_host) OVERRIDE { | 120 RenderFrameHost* new_host) override { |
121 if (old_host) | 121 if (old_host) |
122 ClearResourceForFrame(old_host); | 122 ClearResourceForFrame(old_host); |
123 CreateResourceForFrame(new_host); | 123 CreateResourceForFrame(new_host); |
124 } | 124 } |
125 | 125 |
126 virtual void RenderViewReady() OVERRIDE { | 126 virtual void RenderViewReady() override { |
127 ClearAllResources(); | 127 ClearAllResources(); |
128 CreateAllResources(); | 128 CreateAllResources(); |
129 } | 129 } |
130 | 130 |
131 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE { | 131 virtual void RenderProcessGone(base::TerminationStatus status) override { |
132 ClearAllResources(); | 132 ClearAllResources(); |
133 } | 133 } |
134 | 134 |
135 virtual void WebContentsDestroyed() OVERRIDE { | 135 virtual void WebContentsDestroyed() override { |
136 ClearAllResources(); | 136 ClearAllResources(); |
137 provider_->DeleteEntry(web_contents(), this); // Deletes |this|. | 137 provider_->DeleteEntry(web_contents(), this); // Deletes |this|. |
138 } | 138 } |
139 | 139 |
140 // Called by WebContentsResourceProvider. | 140 // Called by WebContentsResourceProvider. |
141 RendererResource* GetResourceForSiteInstance(SiteInstance* site_instance) { | 141 RendererResource* GetResourceForSiteInstance(SiteInstance* site_instance) { |
142 ResourceMap::iterator i = resources_by_site_instance_.find(site_instance); | 142 ResourceMap::iterator i = resources_by_site_instance_.find(site_instance); |
143 if (i == resources_by_site_instance_.end()) | 143 if (i == resources_by_site_instance_.end()) |
144 return NULL; | 144 return NULL; |
145 return i->second; | 145 return i->second; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 WebContents* web_contents, | 331 WebContents* web_contents, |
332 TaskManagerWebContentsEntry* entry) { | 332 TaskManagerWebContentsEntry* entry) { |
333 if (!entries_.erase(web_contents)) { | 333 if (!entries_.erase(web_contents)) { |
334 NOTREACHED(); | 334 NOTREACHED(); |
335 return; | 335 return; |
336 } | 336 } |
337 delete entry; // Typically, this is our caller. Deletion is okay. | 337 delete entry; // Typically, this is our caller. Deletion is okay. |
338 } | 338 } |
339 | 339 |
340 } // namespace task_manager | 340 } // namespace task_manager |
OLD | NEW |