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