• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 #ifndef WORKSCHED_EXTENSION_H
17 #define WORKSCHED_EXTENSION_H
18 
19 #include <memory>
20 #include "ability_local_record.h"
21 #include "ohos_application.h"
22 #include "ability_handler.h"
23 #include "runtime.h"
24 #include "extension_base.h"
25 #include "work_info.h"
26 #include "work_scheduler_extension_context.h"
27 
28 namespace OHOS {
29 namespace WorkScheduler {
30 class WorkSchedulerExtension : public AbilityRuntime::ExtensionBase<WorkSchedulerExtensionContext> {
31 public:
32     WorkSchedulerExtension() = default;
33     virtual ~WorkSchedulerExtension() = default;
34 
35     std::shared_ptr<WorkSchedulerExtensionContext> CreateAndInitContext(
36         const std::shared_ptr<AppExecFwk::AbilityLocalRecord>& record,
37         const std::shared_ptr<AppExecFwk::OHOSApplication>& application,
38         std::shared_ptr<AppExecFwk::AbilityHandler>& handler,
39         const sptr<IRemoteObject>& token) override;
40 
41     void Init(const std::shared_ptr<AppExecFwk::AbilityLocalRecord>& record,
42         const std::shared_ptr<AppExecFwk::OHOSApplication>& application,
43         std::shared_ptr<AppExecFwk::AbilityHandler>& handler,
44         const sptr<IRemoteObject>& token) override;
45 
46     static WorkSchedulerExtension* Create(const std::unique_ptr<AbilityRuntime::Runtime>& runtime);
47 
48     virtual void OnWorkStart(WorkInfo& workInfo);
49 
50     virtual void OnWorkStop(WorkInfo& workInfo);
51 };
52 }  // namespace WorkScheduler
53 }  // namespace OHOS
54 #endif  // WORKSCHED_EXTENSION_H