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

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/compositor/Invalidator.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 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
Index: chrome/android/java_staging/src/org/chromium/chrome/browser/compositor/Invalidator.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/compositor/Invalidator.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/compositor/Invalidator.java
new file mode 100644
index 0000000000000000000000000000000000000000..784946833bf77a06fb2a9412379482f78711e1d2
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/compositor/Invalidator.java
@@ -0,0 +1,55 @@
+// Copyright 2015 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.
+
+package org.chromium.chrome.browser.compositor;
+
+/**
+ * The {@link Invalidator} invalidates a client when it is the right time.
+ */
+public class Invalidator {
+ /**
+ * Interface for the client that gets invalidated.
+ */
+ public interface Client {
+ /**
+ * Do the invalidation.
+ */
+ void doInvalidate();
+ }
+
+ /**
+ * Interface for the host that drives the invalidations.
+ */
+ public interface Host {
+ /**
+ * Requests an invalidation of the view.
+ *
+ * @param view The {@link View} to invalidate.
+ */
+ void deferInvalidate(Client view);
+ }
+
+ private Host mHost;
+
+ /**
+ * @param host The invalidator host, responsible for invalidating views.
+ */
+ public void set(Host host) {
+ mHost = host;
+ }
+
+ /**
+ * Invalidates either immediately (if no host is specified) or at time
+ * triggered by the host.
+ *
+ * @param client The {@link Client} to invalidate, most likely a view.
+ */
+ public void invalidate(Client client) {
+ if (mHost != null) {
+ mHost.deferInvalidate(client);
+ } else {
+ client.doInvalidate();
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698