| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "blimp/engine/browser_tests/blimp_contents_view_readback_helper.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "third_party/skia/include/core/SkBitmap.h" | |
| 9 | |
| 10 namespace blimp { | |
| 11 | |
| 12 BlimpContentsViewReadbackHelper::BlimpContentsViewReadbackHelper() | |
| 13 : event_(base::WaitableEvent::ResetPolicy::MANUAL, | |
| 14 base::WaitableEvent::InitialState::NOT_SIGNALED), | |
| 15 weak_ptr_factory_(this) {} | |
| 16 | |
| 17 BlimpContentsViewReadbackHelper::~BlimpContentsViewReadbackHelper() = default; | |
| 18 | |
| 19 client::BlimpContentsView::ReadbackRequestCallback | |
| 20 BlimpContentsViewReadbackHelper::GetCallback() { | |
| 21 return base::Bind(&BlimpContentsViewReadbackHelper::OnReadbackComplete, | |
| 22 weak_ptr_factory_.GetWeakPtr()); | |
| 23 } | |
| 24 | |
| 25 SkBitmap* BlimpContentsViewReadbackHelper::GetBitmap() const { | |
| 26 return bitmap_.get(); | |
| 27 } | |
| 28 | |
| 29 void BlimpContentsViewReadbackHelper::OnReadbackComplete( | |
| 30 std::unique_ptr<SkBitmap> bitmap) { | |
| 31 bitmap_ = std::move(bitmap); | |
| 32 event_.Signal(); | |
| 33 } | |
| 34 | |
| 35 } // namespace blimp | |
| OLD | NEW |