OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/thumbnails/thumbnail_tab_helper.h" | 5 #include "chrome/browser/thumbnails/thumbnail_tab_helper.h" |
6 | 6 |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/thumbnails/thumbnail_service.h" | 9 #include "chrome/browser/thumbnails/thumbnail_service.h" |
10 #include "chrome/browser/thumbnails/thumbnail_service_factory.h" | 10 #include "chrome/browser/thumbnails/thumbnail_service_factory.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 const SkBitmap& bitmap, | 67 const SkBitmap& bitmap, |
68 content::ReadbackResponse response) { | 68 content::ReadbackResponse response) { |
69 if (response != content::READBACK_SUCCESS) | 69 if (response != content::READBACK_SUCCESS) |
70 return; | 70 return; |
71 | 71 |
72 // On success, we must be on the UI thread (on failure because of shutdown we | 72 // On success, we must be on the UI thread (on failure because of shutdown we |
73 // are not on the UI thread). | 73 // are not on the UI thread). |
74 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 74 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
75 | 75 |
76 algorithm->ProcessBitmap(context, base::Bind(&UpdateThumbnail), bitmap); | 76 algorithm->ProcessBitmap(context, base::Bind(&UpdateThumbnail), bitmap); |
77 | |
78 context->web_contents->DecrementCapturerCount(); | |
danakj
2015/09/17 17:54:14
Do you not want to do this if the result wasn't SU
shrike
2015/09/28 21:24:11
Thank you for catching that. Done.
| |
77 } | 79 } |
78 | 80 |
79 void AsyncProcessThumbnail(content::WebContents* web_contents, | 81 void AsyncProcessThumbnail(content::WebContents* web_contents, |
80 scoped_refptr<ThumbnailingContext> context, | 82 scoped_refptr<ThumbnailingContext> context, |
81 scoped_refptr<ThumbnailingAlgorithm> algorithm) { | 83 scoped_refptr<ThumbnailingAlgorithm> algorithm) { |
82 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 84 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
83 RenderWidgetHost* render_widget_host = web_contents->GetRenderViewHost(); | 85 RenderWidgetHost* render_widget_host = web_contents->GetRenderViewHost(); |
84 content::RenderWidgetHostView* view = render_widget_host->GetView(); | 86 content::RenderWidgetHostView* view = render_widget_host->GetView(); |
85 if (!view) | 87 if (!view) |
86 return; | 88 return; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 | 191 |
190 scoped_refptr<thumbnails::ThumbnailService> thumbnail_service = | 192 scoped_refptr<thumbnails::ThumbnailService> thumbnail_service = |
191 ThumbnailServiceFactory::GetForProfile(profile); | 193 ThumbnailServiceFactory::GetForProfile(profile); |
192 | 194 |
193 // Skip if we don't need to update the thumbnail. | 195 // Skip if we don't need to update the thumbnail. |
194 if (thumbnail_service.get() == NULL || | 196 if (thumbnail_service.get() == NULL || |
195 !thumbnail_service->ShouldAcquirePageThumbnail(url)) { | 197 !thumbnail_service->ShouldAcquirePageThumbnail(url)) { |
196 return; | 198 return; |
197 } | 199 } |
198 | 200 |
201 gfx::Size empty_size; | |
danakj
2015/09/17 17:54:14
you could just pass the gfx::Size() directly if th
shrike
2015/09/28 21:24:11
Yeah, you're right about passing it directly. And
| |
202 web_contents->IncrementCapturerCount(empty_size); | |
203 | |
199 scoped_refptr<thumbnails::ThumbnailingAlgorithm> algorithm( | 204 scoped_refptr<thumbnails::ThumbnailingAlgorithm> algorithm( |
200 thumbnail_service->GetThumbnailingAlgorithm()); | 205 thumbnail_service->GetThumbnailingAlgorithm()); |
201 | 206 |
202 scoped_refptr<ThumbnailingContext> context(new ThumbnailingContext( | 207 scoped_refptr<ThumbnailingContext> context(new ThumbnailingContext( |
203 web_contents, thumbnail_service.get(), load_interrupted_)); | 208 web_contents, thumbnail_service.get(), load_interrupted_)); |
204 AsyncProcessThumbnail(web_contents, context, algorithm); | 209 AsyncProcessThumbnail(web_contents, context, algorithm); |
205 } | 210 } |
206 | 211 |
207 void ThumbnailTabHelper::RenderViewHostCreated( | 212 void ThumbnailTabHelper::RenderViewHostCreated( |
208 content::RenderViewHost* renderer) { | 213 content::RenderViewHost* renderer) { |
(...skipping 10 matching lines...) Expand all Loading... | |
219 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, | 224 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, |
220 content::Source<RenderWidgetHost>(renderer)); | 225 content::Source<RenderWidgetHost>(renderer)); |
221 } | 226 } |
222 } | 227 } |
223 | 228 |
224 void ThumbnailTabHelper::WidgetHidden(RenderWidgetHost* widget) { | 229 void ThumbnailTabHelper::WidgetHidden(RenderWidgetHost* widget) { |
225 if (!enabled_) | 230 if (!enabled_) |
226 return; | 231 return; |
227 UpdateThumbnailIfNecessary(web_contents()); | 232 UpdateThumbnailIfNecessary(web_contents()); |
228 } | 233 } |
OLD | NEW |