1 /* 2 * Copyright (c) 2021-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 DEFERRED_PHOTO_PROXY_NAPI_H_ 17 #define DEFERRED_PHOTO_PROXY_NAPI_H_ 18 19 #include "deferred_photo_proxy.h" 20 #include "photo_proxy_napi.h" 21 #include "camera_napi_utils.h" 22 23 namespace OHOS { 24 namespace CameraStandard { 25 static const char DEFERRED_PHOTO_NAPI_CLASS_NAME[] = "DeferredPhotoProxy"; 26 27 class DeferredPhotoProxyNapi : public Media::PhotoProxyNapi { 28 public: 29 static napi_value Init(napi_env env, napi_value exports); 30 static napi_value CreateDeferredPhotoProxy(napi_env env, sptr<DeferredPhotoProxy> deferredPhotoProxy); 31 DeferredPhotoProxyNapi(); 32 ~DeferredPhotoProxyNapi(); 33 34 static napi_value GetThumbnail(napi_env env, napi_callback_info info); 35 static napi_value Release(napi_env env, napi_callback_info info); 36 37 sptr<DeferredPhotoProxy> deferredPhotoProxy_; 38 39 private: 40 static void DeferredPhotoProxyNapiDestructor(napi_env env, void* nativeObject, void* finalize_hint); 41 static napi_value DeferredPhotoProxyNapiConstructor(napi_env env, napi_callback_info info); 42 static void DeferredPhotoAsyncTaskComplete(napi_env env, napi_status status, void* data); 43 44 static thread_local napi_ref sConstructor_; 45 static thread_local uint32_t deferredPhotoProxyTaskId; 46 47 napi_env env_; 48 }; 49 50 struct DeferredPhotoProxAsyncContext : public AsyncContext { 51 DeferredPhotoProxyNapi* objectInfo; 52 }; 53 } // namespace CameraStandard 54 } // namespace OHOS 55 #endif /* DEFERRED_PHOTO_PROXY_NAPI_H_ */