1 /* 2 * Copyright (c) 2023-2023 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 #include <vector> 16 #include <shared_mutex> 17 #include <iostream> 18 19 #include "user_initiated_strategy.h" 20 #include "dp_log.h" 21 22 namespace OHOS { 23 namespace CameraStandard { 24 namespace DeferredProcessing { UserInitiatedStrategy(std::shared_ptr<PhotoJobRepository> photoJobRepository)25UserInitiatedStrategy::UserInitiatedStrategy(std::shared_ptr<PhotoJobRepository> photoJobRepository) 26 : photoJobRepository_(photoJobRepository) 27 { 28 DP_DEBUG_LOG("entered"); 29 } 30 ~UserInitiatedStrategy()31UserInitiatedStrategy::~UserInitiatedStrategy() 32 { 33 DP_DEBUG_LOG("entered"); 34 photoJobRepository_ = nullptr; 35 } 36 GetWork()37DeferredPhotoWorkPtr UserInitiatedStrategy::GetWork() 38 { 39 DP_INFO_LOG("entered"); 40 DeferredPhotoJobPtr jobPtr = GetJob(); 41 ExecutionMode mode = GetExecutionMode(); 42 if ((jobPtr != nullptr) && (mode != ExecutionMode::DUMMY)) { 43 return std::make_shared<DeferredPhotoWork>(jobPtr, mode); 44 } 45 return nullptr; 46 } 47 GetJob()48DeferredPhotoJobPtr UserInitiatedStrategy::GetJob() 49 { 50 return photoJobRepository_->GetHighPriorityJob(); 51 } 52 GetExecutionMode()53ExecutionMode UserInitiatedStrategy::GetExecutionMode() 54 { 55 return ExecutionMode::HIGH_PERFORMANCE; 56 } 57 } // namespace DeferredProcessing 58 } // namespace CameraStandard 59 } // namespace OHOS