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 NETMANAGER_BASE_TSTATSGETUPDATEIFACEUIDSTATS_CONTEXT_H 17 #define NETMANAGER_BASE_TSTATSGETUPDATEIFACEUIDSTATS_CONTEXT_H 18 19 #include <cstddef> 20 #include <cstdint> 21 #include <string> 22 23 #include <napi/native_api.h> 24 25 #include "base_context.h" 26 #include "net_stats_info.h" 27 28 namespace OHOS { 29 namespace NetManagerStandard { 30 class UpdateIfacesStatsContext final : public BaseContext { 31 public: 32 UpdateIfacesStatsContext() = delete; 33 explicit UpdateIfacesStatsContext(napi_env env, EventManager *manager); 34 35 void SetUid(int32_t uid); 36 void SetInterfaceName(std::string interfaceName); 37 void SetStatsInfo(NetStatsInfo statsInfo); 38 void SetStart(uint32_t start); 39 void SetEnd(uint32_t end); 40 int32_t GetUid() const; 41 std::string GetInterfaceName() const; 42 NetStatsInfo GetStatsInfo() const; 43 uint32_t GetStart() const; 44 uint32_t GetEnd() const; 45 46 void ParseParams(napi_value *params, size_t paramsCount); 47 48 private: 49 int32_t uid_ = 0; 50 std::string interfaceName_; 51 NetStatsInfo statsInfo_; 52 uint32_t start_ = 0; 53 uint32_t end_ = 0; 54 55 private: 56 bool CheckParamsType(napi_value *params, size_t paramsCount); 57 }; 58 } // namespace NetManagerStandard 59 } // namespace OHOS 60 #endif // NETMANAGER_BASE_TSTATSGETUPDATEIFACEUIDSTATS_CONTEXT_H 61