• 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 FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_EXPIRED_CALLBACK_H
17 #define FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_EXPIRED_CALLBACK_H
18 
19 #include <iremote_broker.h>
20 
21 #include "expired_callback_stub.h"
22 #include "ibackground_task_mgr.h"
23 
24 namespace OHOS {
25 namespace BackgroundTaskMgr {
26 class ExpiredCallback {
27 public:
28     /**
29      * Default constructor used to create a instance.
30      */
31     ExpiredCallback();
32 
33     /**
34      * Default destructor.
35      */
36     virtual ~ExpiredCallback();
37 
38     /**
39      * Callback when the transient task will be overtime.
40      */
41     virtual void OnExpired()= 0;
42 
43 private:
44     class ExpiredCallbackImpl final : public ExpiredCallbackStub {
45     public:
46         ExpiredCallbackImpl(ExpiredCallback &callback);
~ExpiredCallbackImpl()47         ~ExpiredCallbackImpl() {};
48         void OnExpired() override;
49 
50     public:
51         ExpiredCallback &callback_;
52     };
53 
54 private:
55     const sptr<ExpiredCallbackImpl> GetImpl() const;
56 
57 private:
58     sptr<ExpiredCallbackImpl> impl_ = nullptr;
59 
60     friend class BackgroundTaskManager;
61 };
62 }  // namespace BackgroundTaskMgr
63 }  // namespace OHOS
64 #endif  // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_EXPIRED_CALLBACK_H