| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef PPAPI_SHARED_IMPL_PPB_NETWORK_LIST_PRIVATE_SHARED_H_ | |
| 6 #define PPAPI_SHARED_IMPL_PPB_NETWORK_LIST_PRIVATE_SHARED_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "ppapi/c/private/ppb_net_address_private.h" | |
| 14 #include "ppapi/shared_impl/resource.h" | |
| 15 #include "ppapi/thunk/ppb_network_list_api.h" | |
| 16 | |
| 17 namespace ppapi { | |
| 18 | |
| 19 struct PPAPI_SHARED_EXPORT NetworkInfo { | |
| 20 NetworkInfo(); | |
| 21 ~NetworkInfo(); | |
| 22 | |
| 23 std::string name; | |
| 24 PP_NetworkListType_Private type; | |
| 25 PP_NetworkListState_Private state; | |
| 26 std::vector<PP_NetAddress_Private> addresses; | |
| 27 std::string display_name; | |
| 28 int mtu; | |
| 29 }; | |
| 30 typedef std::vector<NetworkInfo> NetworkList; | |
| 31 | |
| 32 // NetworkListStorage is refcounted container for NetworkList. It | |
| 33 // allows sharing of one NetworkList object between multiple | |
| 34 // NetworkList resources. | |
| 35 class PPAPI_SHARED_EXPORT NetworkListStorage | |
| 36 : public base::RefCountedThreadSafe<NetworkListStorage> { | |
| 37 public: | |
| 38 explicit NetworkListStorage(const NetworkList& list); | |
| 39 | |
| 40 const NetworkList& list() { return list_; } | |
| 41 | |
| 42 private: | |
| 43 friend class base::RefCountedThreadSafe<NetworkListStorage>; | |
| 44 ~NetworkListStorage(); | |
| 45 | |
| 46 NetworkList list_; | |
| 47 | |
| 48 DISALLOW_COPY_AND_ASSIGN(NetworkListStorage); | |
| 49 }; | |
| 50 | |
| 51 class PPAPI_SHARED_EXPORT PPB_NetworkList_Private_Shared | |
| 52 : public ::ppapi::Resource, | |
| 53 public ::ppapi::thunk::PPB_NetworkList_API { | |
| 54 public: | |
| 55 static PP_Resource Create(ResourceObjectType type, | |
| 56 PP_Instance instance, | |
| 57 const scoped_refptr<NetworkListStorage>& list); | |
| 58 | |
| 59 virtual ~PPB_NetworkList_Private_Shared(); | |
| 60 | |
| 61 // Resource override. | |
| 62 virtual ::ppapi::thunk::PPB_NetworkList_API* | |
| 63 AsPPB_NetworkList_API() OVERRIDE; | |
| 64 | |
| 65 // PPB_NetworkList_API implementation. | |
| 66 virtual const NetworkList& GetNetworkListData() const OVERRIDE; | |
| 67 virtual uint32_t GetCount() OVERRIDE; | |
| 68 virtual PP_Var GetName(uint32_t index) OVERRIDE; | |
| 69 virtual PP_NetworkListType_Private GetType(uint32_t index) OVERRIDE; | |
| 70 virtual PP_NetworkListState_Private GetState(uint32_t index) OVERRIDE; | |
| 71 virtual int32_t GetIpAddresses(uint32_t index, | |
| 72 const PP_ArrayOutput& output) OVERRIDE; | |
| 73 virtual PP_Var GetDisplayName(uint32_t index) OVERRIDE; | |
| 74 virtual uint32_t GetMTU(uint32_t index) OVERRIDE; | |
| 75 | |
| 76 private: | |
| 77 PPB_NetworkList_Private_Shared(ResourceObjectType type, | |
| 78 PP_Instance instance, | |
| 79 const scoped_refptr<NetworkListStorage>& list); | |
| 80 | |
| 81 scoped_refptr<NetworkListStorage> list_; | |
| 82 | |
| 83 DISALLOW_COPY_AND_ASSIGN(PPB_NetworkList_Private_Shared); | |
| 84 }; | |
| 85 | |
| 86 } // namespace ppapi | |
| 87 | |
| 88 #endif // PPAPI_SHARED_IMPL_PPB_NETWORK_LIST_PRIVATE_SHARED_H_ | |
| OLD | NEW |