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

Side by Side Diff: athena/content/content_proxy.cc

Issue 593503003: Support error handling for Surface readbacks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formatted code and fixed build issue in test. Created 6 years, 1 month 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
OLDNEW
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 gfx::Size source = host->GetView()->GetViewBounds().size(); 150 gfx::Size source = host->GetView()->GetViewBounds().size();
151 gfx::Size target = gfx::Size(source.width() / 2, source.height() / 2); 151 gfx::Size target = gfx::Size(source.width() / 2, source.height() / 2);
152 host->CopyFromBackingStore( 152 host->CopyFromBackingStore(
153 gfx::Rect(), 153 gfx::Rect(),
154 target, 154 target,
155 base::Bind(&ContentProxy::OnContentImageRead, 155 base::Bind(&ContentProxy::OnContentImageRead,
156 proxy_content_to_image_factory_.GetWeakPtr()), 156 proxy_content_to_image_factory_.GetWeakPtr()),
157 kAlpha_8_SkColorType); 157 kAlpha_8_SkColorType);
158 } 158 }
159 159
160 void ContentProxy::OnContentImageRead(bool success, const SkBitmap& bitmap) { 160 void ContentProxy::OnContentImageRead(const SkBitmap& bitmap,
161 content::ReadbackResponse response) {
161 // Now we can hide the content. Note that after hiding we are freeing memory 162 // Now we can hide the content. Note that after hiding we are freeing memory
162 // and if something goes wrong we will end up with an empty page. 163 // and if something goes wrong we will end up with an empty page.
163 HideOriginalContent(); 164 HideOriginalContent();
164 165
165 if (!success || bitmap.empty() || bitmap.isNull()) 166 if (response != content::READBACK_SUCCESS || bitmap.empty() ||
167 bitmap.isNull())
166 return; 168 return;
167 169
168 // While we are encoding the image, we keep the current image as reference 170 // While we are encoding the image, we keep the current image as reference
169 // to have something for the overview mode to grab. Once we have the encoded 171 // to have something for the overview mode to grab. Once we have the encoded
170 // PNG, we will get rid of this. 172 // PNG, we will get rid of this.
171 raw_image_ = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); 173 raw_image_ = gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
172 174
173 scoped_refptr<ProxyImageData> png_image = new ProxyImageData(); 175 scoped_refptr<ProxyImageData> png_image = new ProxyImageData();
174 png_image->EncodeImage( 176 png_image->EncodeImage(
175 bitmap, 177 bitmap,
176 base::Bind(&ContentProxy::OnContentImageEncodeComplete, 178 base::Bind(&ContentProxy::OnContentImageEncodeComplete,
177 proxy_content_to_image_factory_.GetWeakPtr(), 179 proxy_content_to_image_factory_.GetWeakPtr(),
178 png_image)); 180 png_image));
179 } 181 }
180 182
181 void ContentProxy::OnContentImageEncodeComplete( 183 void ContentProxy::OnContentImageEncodeComplete(
182 scoped_refptr<ProxyImageData> image) { 184 scoped_refptr<ProxyImageData> image) {
183 png_data_ = image->data(); 185 png_data_ = image->data();
184 186
185 // From now on we decode the image as needed to save memory. 187 // From now on we decode the image as needed to save memory.
186 raw_image_ = gfx::ImageSkia(); 188 raw_image_ = gfx::ImageSkia();
187 } 189 }
188 190
189 } // namespace athena 191 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698