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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/test_runner/composite_async_then.cc
diff --git a/components/test_runner/composite_async_then.cc b/components/test_runner/composite_async_then.cc
new file mode 100644
index 0000000000000000000000000000000000000000..412d3016e11e70fce8e286d0020273748374ae6a
--- /dev/null
+++ b/components/test_runner/composite_async_then.cc
@@ -0,0 +1,65 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/test_runner/composite_async_then.h"
+
+#include "base/callback.h"
+#include "base/trace_event/trace_event.h"
+#include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallback.h"
+#include "third_party/WebKit/public/web/WebPagePopup.h"
+#include "third_party/WebKit/public/web/WebWidget.h"
+
+namespace test_runner {
+
+namespace {
+
+class CompositeCallback : public blink::WebCompositeAndReadbackAsyncCallback {
+ public:
+ CompositeCallback(const base::Closure& callback)
+ : callback_(callback), wait_for_popup_(false) {}
+ virtual ~CompositeCallback() {}
+
+ void set_wait_for_popup(bool wait) { wait_for_popup_ = wait; }
+
+ // WebCompositeAndReadbackAsyncCallback implementation.
+ bool needsBitmap() const override;
+ void didCompositeAndReadback(const SkBitmap& bitmap) override;
+
+ private:
+ base::Closure callback_;
+ bool wait_for_popup_;
+};
+
+bool CompositeCallback::needsBitmap() const {
+ return false;
+}
+
+void CompositeCallback::didCompositeAndReadback(const SkBitmap& bitmap) {
+ TRACE_EVENT0("shell", "LayoutAndPaintCallback::didComposite");
+ if (wait_for_popup_) {
+ wait_for_popup_ = false;
+ return;
+ }
+
+ if (!callback_.is_null())
+ callback_.Run();
+ delete this;
+}
+
+} // namespace
+
+void CompositeAsyncThen(blink::WebWidget* web_widget,
+ const base::Closure& callback) {
+ TRACE_EVENT0("shell", "CompositeAsyncThen");
+
+ CompositeCallback* composite_callback =
+ new CompositeCallback(callback);
+ web_widget->compositeAndReadbackAsync(composite_callback);
+ if (blink::WebPagePopup* popup = web_widget->pagePopup()) {
+ composite_callback->set_wait_for_popup(true);
+ popup->compositeAndReadbackAsync(composite_callback);
+ }
+}
+
+} // namespace test_runner
« 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