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 NWEB_WEB_STORAGE_H 17 #define NWEB_WEB_STORAGE_H 18 19 #include <memory> 20 #include <string> 21 #include <vector> 22 23 #include "nweb_export.h" 24 #include "nweb_value_callback.h" 25 26 namespace OHOS::NWeb { 27 28 class NWebWebStorageOrigin; 29 class OHOS_NWEB_EXPORT NWebWebStorage { 30 public: 31 NWebWebStorage() = default; 32 33 virtual ~NWebWebStorage() = default; 34 35 virtual void DeleteAllData(bool incognito_mode) = 0; 36 virtual int DeleteOrigin(const std::string& origin) = 0; 37 virtual void GetOrigins(std::shared_ptr<NWebWebStorageOriginVectorValueCallback> callback) = 0; 38 virtual std::vector<std::shared_ptr<NWebWebStorageOrigin>> GetOrigins() = 0; 39 virtual void GetOriginQuota(const std::string& origin, std::shared_ptr<NWebLongValueCallback> callback) = 0; 40 virtual long GetOriginQuota(const std::string& origin) = 0; 41 virtual void GetOriginUsage(const std::string& origin, std::shared_ptr<NWebLongValueCallback> callback) = 0; 42 virtual long GetOriginUsage(const std::string& origin) = 0; 43 }; 44 45 class OHOS_NWEB_EXPORT NWebWebStorageOrigin { 46 public: 47 NWebWebStorageOrigin() = default; 48 virtual ~NWebWebStorageOrigin() = default; 49 50 virtual void SetOrigin(const std::string& origin) = 0; 51 virtual void SetQuota(long quota) = 0; 52 virtual void SetUsage(long usage) = 0; 53 virtual std::string GetOrigin() = 0; 54 virtual long GetQuota() = 0; 55 virtual long GetUsage() = 0; 56 }; 57 58 } // namespace OHOS::NWeb 59 60 #endif // NWebWebStorage 61