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 "athena/content/content_proxy.h" | 5 #include "athena/content/content_proxy.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/threading/worker_pool.h" | 8 #include "base/threading/worker_pool.h" |
9 #include "content/public/browser/render_view_host.h" | 9 #include "content/public/browser/render_view_host.h" |
10 #include "content/public/browser/render_widget_host_view.h" | 10 #include "content/public/browser/render_widget_host_view.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 void ContentProxy::CreateProxyContent() { | 138 void ContentProxy::CreateProxyContent() { |
139 DCHECK(!content_creation_called_); | 139 DCHECK(!content_creation_called_); |
140 content_creation_called_ = true; | 140 content_creation_called_ = true; |
141 // Unit tests might not have a |web_view_|. | 141 // Unit tests might not have a |web_view_|. |
142 if (!web_view_) | 142 if (!web_view_) |
143 return; | 143 return; |
144 | 144 |
145 content::RenderViewHost* host = | 145 content::RenderViewHost* host = |
146 web_view_->GetWebContents()->GetRenderViewHost(); | 146 web_view_->GetWebContents()->GetRenderViewHost(); |
147 DCHECK(host && host->GetView()); | 147 DCHECK(host); |
| 148 // A never fully initialized content can come here with no view. |
| 149 if (!host->GetView()) |
| 150 return; |
148 gfx::Size source = host->GetView()->GetViewBounds().size(); | 151 gfx::Size source = host->GetView()->GetViewBounds().size(); |
149 gfx::Size target = gfx::Size(source.width() / 2, source.height() / 2); | 152 gfx::Size target = gfx::Size(source.width() / 2, source.height() / 2); |
150 host->CopyFromBackingStore( | 153 host->CopyFromBackingStore( |
151 gfx::Rect(), | 154 gfx::Rect(), |
152 target, | 155 target, |
153 base::Bind(&ContentProxy::OnContentImageRead, | 156 base::Bind(&ContentProxy::OnContentImageRead, |
154 proxy_content_to_image_factory_.GetWeakPtr()), | 157 proxy_content_to_image_factory_.GetWeakPtr()), |
155 kAlpha_8_SkColorType); | 158 kAlpha_8_SkColorType); |
156 } | 159 } |
157 | 160 |
(...skipping 20 matching lines...) Expand all Loading... |
178 | 181 |
179 void ContentProxy::OnContentImageEncodeComplete( | 182 void ContentProxy::OnContentImageEncodeComplete( |
180 scoped_refptr<ProxyImageData> image) { | 183 scoped_refptr<ProxyImageData> image) { |
181 png_data_ = image->data(); | 184 png_data_ = image->data(); |
182 | 185 |
183 // From now on we decode the image as needed to save memory. | 186 // From now on we decode the image as needed to save memory. |
184 raw_image_ = gfx::ImageSkia(); | 187 raw_image_ = gfx::ImageSkia(); |
185 } | 188 } |
186 | 189 |
187 } // namespace athena | 190 } // namespace athena |
OLD | NEW |