100aff185Sopenharmony_ci/* 200aff185Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 300aff185Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 400aff185Sopenharmony_ci * you may not use this file except in compliance with the License. 500aff185Sopenharmony_ci * You may obtain a copy of the License at 600aff185Sopenharmony_ci * 700aff185Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 800aff185Sopenharmony_ci * 900aff185Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1000aff185Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1100aff185Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1200aff185Sopenharmony_ci * See the License for the specific language governing permissions and 1300aff185Sopenharmony_ci * limitations under the License. 1400aff185Sopenharmony_ci */ 1500aff185Sopenharmony_ci 1600aff185Sopenharmony_ciimport type { AsyncCallback, TimelineData } from '@ohos/common'; 1700aff185Sopenharmony_ciimport { Log, TraceControllerUtils } from '@ohos/common'; 1800aff185Sopenharmony_ciimport { TimelineDataSource } from './TimelineDataSource'; 1900aff185Sopenharmony_ci 2000aff185Sopenharmony_ciconst TAG: string = 'timeline_GetTimelineDataCallback'; 2100aff185Sopenharmony_ci 2200aff185Sopenharmony_ci// Datasource requests media timeline group data callback 2300aff185Sopenharmony_ciexport class GetTimelineDataCallback implements AsyncCallback<TimelineData[]> { 2400aff185Sopenharmony_ci source: TimelineDataSource; 2500aff185Sopenharmony_ci requestTime: number; 2600aff185Sopenharmony_ci 2700aff185Sopenharmony_ci constructor(source: TimelineDataSource) { 2800aff185Sopenharmony_ci this.source = source; 2900aff185Sopenharmony_ci this.requestTime = Date.now(); 3000aff185Sopenharmony_ci TraceControllerUtils.startTraceWithTaskId('getGroupData', this.requestTime); 3100aff185Sopenharmony_ci } 3200aff185Sopenharmony_ci 3300aff185Sopenharmony_ci callback(groupDataList: TimelineData[]) { 3400aff185Sopenharmony_ci TraceControllerUtils.finishTraceWithTaskId('getGroupData', this.requestTime); 3500aff185Sopenharmony_ci Log.info(TAG, `took ${Date.now() - this.requestTime} ms to get group data: ${groupDataList.length}`); 3600aff185Sopenharmony_ci this.source.updateGroupData(this.requestTime, groupDataList); 3700aff185Sopenharmony_ci } 3800aff185Sopenharmony_ci}