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 "distributed_file_daemon_manager.h" 17 #include "pasteboard_hilog.h" 18 #include "pasteboard_progress_signal.h" 19 20 namespace OHOS { 21 namespace MiscServices { GetInstance()22ProgressSignalClient &ProgressSignalClient::GetInstance() 23 { 24 static ProgressSignalClient instance; 25 return instance; 26 } 27 Init()28void ProgressSignalClient::Init() 29 { 30 needCancel_.store(false); 31 remoteTask_.store(false); 32 } 33 Cancel()34void ProgressSignalClient::Cancel() 35 { 36 PASTEBOARD_HILOGD(PASTEBOARD_MODULE_CLIENT, "ProgressSignalClient Cancel in!"); 37 needCancel_.store(true); 38 } 39 IsCanceled()40bool ProgressSignalClient::IsCanceled() 41 { 42 return needCancel_.load() || remoteTask_.load(); 43 } 44 CheckCancelIfNeed()45bool ProgressSignalClient::CheckCancelIfNeed() 46 { 47 if (!needCancel_.load()) { 48 return false; 49 } 50 return true; 51 } 52 SetRemoteTaskCancel()53void ProgressSignalClient::SetRemoteTaskCancel() 54 { 55 needCancel_.store(true); 56 } 57 } // namespace MiscServices 58 } // namespace OHOS