1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.tracing.perfetto; 18 19 import android.annotation.Nullable; 20 21 /** 22 * @hide 23 * @param <DataSourceInstanceType> The type of datasource instance this state applied to. 24 */ 25 public class CreateTlsStateArgs<DataSourceInstanceType extends DataSourceInstance> { 26 private final DataSource<DataSourceInstanceType, Object, Object> mDataSource; 27 private final int mInstanceIndex; 28 CreateTlsStateArgs(DataSource dataSource, int instanceIndex)29 CreateTlsStateArgs(DataSource dataSource, int instanceIndex) { 30 this.mDataSource = dataSource; 31 this.mInstanceIndex = instanceIndex; 32 } 33 34 /** 35 * Gets the datasource instance for this state with a lock. 36 * releaseDataSourceInstanceLocked must be called before this can be called again. 37 * @return The data source instance for this state. 38 * Null if the datasource instance no longer exists. 39 */ getDataSourceInstanceLocked()40 public @Nullable DataSourceInstanceType getDataSourceInstanceLocked() { 41 return mDataSource.getDataSourceInstanceLocked(mInstanceIndex); 42 } 43 } 44