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

Side by Side Diff: components/test_runner/composite_async_then.cc

Issue 2034393003: testRunner.layoutAndPaintAsyncThen ==> testRunner.compositeAsyncThen (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months 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
« no previous file with comments | « components/test_runner/composite_async_then.h ('k') | components/test_runner/pixel_dump.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 "components/test_runner/composite_async_then.h"
6
7 #include "base/callback.h"
8 #include "base/trace_event/trace_event.h"
9 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac k.h"
10 #include "third_party/WebKit/public/web/WebPagePopup.h"
11 #include "third_party/WebKit/public/web/WebWidget.h"
12
13 namespace test_runner {
14
15 namespace {
16
17 class CompositeCallback : public blink::WebCompositeAndReadbackAsyncCallback {
18 public:
19 CompositeCallback(const base::Closure& callback)
20 : callback_(callback), wait_for_popup_(false) {}
21 virtual ~CompositeCallback() {}
22
23 void set_wait_for_popup(bool wait) { wait_for_popup_ = wait; }
24
25 // WebCompositeAndReadbackAsyncCallback implementation.
26 bool needsBitmap() const override;
27 void didCompositeAndReadback(const SkBitmap& bitmap) override;
28
29 private:
30 base::Closure callback_;
31 bool wait_for_popup_;
32 };
33
34 bool CompositeCallback::needsBitmap() const {
35 return false;
36 }
37
38 void CompositeCallback::didCompositeAndReadback(const SkBitmap& bitmap) {
39 TRACE_EVENT0("shell", "LayoutAndPaintCallback::didComposite");
40 if (wait_for_popup_) {
41 wait_for_popup_ = false;
42 return;
43 }
44
45 if (!callback_.is_null())
46 callback_.Run();
47 delete this;
48 }
49
50 } // namespace
51
52 void CompositeAsyncThen(blink::WebWidget* web_widget,
53 const base::Closure& callback) {
54 TRACE_EVENT0("shell", "CompositeAsyncThen");
55
56 CompositeCallback* composite_callback =
57 new CompositeCallback(callback);
58 web_widget->compositeAndReadbackAsync(composite_callback);
59 if (blink::WebPagePopup* popup = web_widget->pagePopup()) {
60 composite_callback->set_wait_for_popup(true);
61 popup->compositeAndReadbackAsync(composite_callback);
62 }
63 }
64
65 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/composite_async_then.h ('k') | components/test_runner/pixel_dump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698