• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "native_startup_task.h"
17 
18 #include "hilog_tag_wrapper.h"
19 
20 namespace OHOS {
21 namespace AbilityRuntime {
22 const std::string NativeStartupTask::TASK_TYPE = "Native";
23 
NativeStartupTask(const std::string & name,TaskInitFunc taskInitFunc)24 NativeStartupTask::NativeStartupTask(const std::string& name, TaskInitFunc taskInitFunc) : StartupTask(name),
25     taskInitFunc_(std::move(taskInitFunc))
26 {
27 }
28 
29 NativeStartupTask::~NativeStartupTask() = default;
30 
GetType() const31 const std::string &NativeStartupTask::GetType() const
32 {
33     return TASK_TYPE;
34 }
35 
RunTaskInit(std::unique_ptr<StartupTaskResultCallback> callback)36 int32_t NativeStartupTask::RunTaskInit(std::unique_ptr<StartupTaskResultCallback> callback)
37 {
38     if (taskInitFunc_ == nullptr) {
39         TAG_LOGE(AAFwkTag::STARTUP, "task: %{public}s, taskInitFunc_ is null", name_.c_str());
40     }
41     return taskInitFunc_(std::move(callback));
42 }
43 
RunTaskOnDependencyCompleted(const std::string & dependencyName,const std::shared_ptr<StartupTaskResult> & result)44 int32_t NativeStartupTask::RunTaskOnDependencyCompleted(const std::string& dependencyName,
45     const std::shared_ptr<StartupTaskResult>& result)
46 {
47     // no onDependencyCompleted callback, do nothing
48     return ERR_OK;
49 }
50 } // namespace AbilityRuntime
51 } // namespace OHOS
52