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; 6 7 import org.chromium.base.annotations.CalledByNative; 8 9 /** 10 * A simple 2-argument callback with an int and a String as arguments. 11 * 12 * This is used to call a 2-argument Java callback from C++ code. The generic {@link 13 * org.chromium.base.Callback} cannot be used because it is limited to a single argument. 14 * Alternative approaches like encoding the two arguments into one string or one array of objects 15 * with different types were considered, but their downside was both a lot of boilerplate (creating 16 * the composed object in C++ and checking and decoding it in Java) and lack of clarity. This 17 * 2-argument callback also adds a few code lines but it is clear and the compiler does the type 18 * checking. 19 */ 20 public interface IntStringCallback { 21 /** 22 * Invoked with the result of a computation. 23 * 24 * @param number Integer part of the result. 25 * @param string String part of the result. 26 */ 27 @CalledByNative onResult(int number, String string)28 void onResult(int number, String string); 29 } 30