• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_NETCONNECTION_H
17 #define NETMANAGER_BASE_NETCONNECTION_H
18 
19 #include <map>
20 
21 #include "net_conn_callback_observer.h"
22 #include "net_specifier.h"
23 #include "event_manager.h"
24 
25 namespace OHOS::NetManagerStandard {
26 class NetConnection final {
27 public:
28     bool hasNetSpecifier_;
29 
30     bool hasTimeout_;
31 
32     NetManagerStandard::NetSpecifier netSpecifier_;
33 
34     uint32_t timeout_;
35 
36 public:
37     [[nodiscard]] sptr<NetConnCallbackObserver> GetObserver() const;
38 
39     [[nodiscard]] EventManager *GetEventManager() const;
40 
41     static NetConnection *MakeNetConnection(EventManager *eventManager);
42 
43     static void DeleteNetConnection(NetConnection *netConnection);
44 
45 private:
46     sptr<NetConnCallbackObserver> observer_;
47 
48     EventManager *manager_;
49 
50     explicit NetConnection(EventManager *eventManager);
51 
52     ~NetConnection() = default;
53 };
54 
55 extern std::map<NetConnCallbackObserver *, NetConnection *> NET_CONNECTIONS;
56 extern std::mutex g_netConnectionsMutex;
57 } // namespace OHOS::NetManagerStandard
58 
59 #endif /* NETMANAGER_BASE_NETCONNECTION_H */
60