1 // Copyright 2018 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 package org.chromium.base.task; 6 7 /** 8 * A task queue that posts Java tasks onto the C++ browser scheduler, if loaded. Otherwise this 9 * will be backed by an {@link android.os.Handler} or the java thread pool. The TaskQueue interface 10 * provides no guarantee over the order or the thread on which the task will be executed. 11 * 12 * Very similar to {@link java.util.concurrent.Executor} but conforms to chromium terminology. 13 */ 14 public interface TaskRunner { 15 /** 16 * Posts a task to run immediately. 17 * 18 * @param task The task to be run immediately. 19 */ postTask(Runnable task)20 void postTask(Runnable task); 21 22 /** 23 * Posts a task to run after a specified delay. 24 * 25 * @param task The task to be run. 26 * @param delay The delay in milliseconds before the task can be run. 27 */ postDelayedTask(Runnable task, long delay)28 void postDelayedTask(Runnable task, long delay); 29 } 30