• 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 #ifndef FOUNDATION_RESOURCESCHEDULE_WORKSCHEDULER_WORK_SCHED_SERVICE_PROXY_H
16 #define FOUNDATION_RESOURCESCHEDULE_WORKSCHEDULER_WORK_SCHED_SERVICE_PROXY_H
17 
18 #include <list>
19 #include <memory>
20 
21 #include <iremote_proxy.h>
22 #include <nocopyable.h>
23 #include "refbase.h"
24 
25 #include "iwork_sched_service.h"
26 
27 namespace OHOS {
28 namespace WorkScheduler {
29 class WorkSchedServiceProxy : public IRemoteProxy<IWorkSchedService> {
30 public:
WorkSchedServiceProxy(const sptr<IRemoteObject> & impl)31     explicit WorkSchedServiceProxy(const sptr<IRemoteObject>& impl) :
32     IRemoteProxy<IWorkSchedService>(impl) {}
33     ~WorkSchedServiceProxy() = default;
34     DISALLOW_COPY_AND_MOVE(WorkSchedServiceProxy);
35 
36     /**
37      * @brief Start work.
38      *
39      * @param workInfo The info of work.
40      * @return error code, ERR_OK if success.
41      */
42     int32_t StartWork(WorkInfo& workInfo) override;
43     /**
44      * @brief Stop work.
45      *
46      * @param workInfo The info of work.
47      * @return error code, ERR_OK if success.
48      */
49     int32_t StopWork(WorkInfo& workInfo) override;
50     /**
51      * @brief Stop and cancel work.
52      *
53      * @param workInfo The info of work.
54      * @return error code, ERR_OK if success.
55      */
56     int32_t StopAndCancelWork(WorkInfo& workInfo) override;
57     /**
58      * @brief Stop and clear works.
59      *
60      * @return error code, ERR_OK if success.
61      */
62     int32_t StopAndClearWorks() override;
63     /**
64      * @brief The last work time out.
65      *
66      * @param workId The id of work.
67      * @param result True if the work executed time out, else false.
68      * @return error code, ERR_OK if success.
69      */
70     int32_t IsLastWorkTimeout(int32_t workId, bool &result) override;
71     /**
72      * @brief Obtain all works.
73      *
74      * @param uid The uid.
75      * @param pid The pid.
76      * @param workInfos The infos of work.
77      * @return error code, ERR_OK if success.
78      */
79     int32_t ObtainAllWorks(int32_t &uid, int32_t &pid, std::list<std::shared_ptr<WorkInfo>>& workInfos) override;
80     /**
81      * @brief Get the status of work.
82      *
83      * @param uid The uid.
84      * @param workId The id of work.
85      * @param workInfo The info of work.
86      * @return error code, ERR_OK if success.
87      */
88     int32_t GetWorkStatus(int32_t &uid, int32_t &workId, std::shared_ptr<WorkInfo>& workInfo) override;
89 private:
90     static inline BrokerDelegator<WorkSchedServiceProxy> delegator_;
91 };
92 } // namespace WorkScheduler
93 } // namespace OHOS
94 #endif // FOUNDATION_RESOURCESCHEDULE_WORKSCHEDULER_WORK_SCHED_SERVICE_PROXY_H