Chromium Code Reviews| 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_PROXY_NETWORK_LIST_RESOURCE_H_ |
| 6 #define PPAPI_SHARED_IMPL_PPB_NETWORK_LIST_PRIVATE_SHARED_H_ | 6 #define PPAPI_PROXY_NETWORK_LIST_RESOURCE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "ppapi/c/private/ppb_net_address_private.h" | 13 #include "ppapi/c/private/ppb_net_address_private.h" |
| 14 #include "ppapi/shared_impl/resource.h" | 14 #include "ppapi/proxy/plugin_resource.h" |
| 15 #include "ppapi/thunk/ppb_network_list_api.h" | 15 #include "ppapi/thunk/ppb_network_list_api.h" |
| 16 | 16 |
| 17 namespace ppapi { | 17 namespace ppapi { |
| 18 namespace proxy { | |
| 18 | 19 |
| 19 struct PPAPI_SHARED_EXPORT NetworkInfo { | 20 struct PPAPI_PROXY_EXPORT NetworkInfo { |
| 20 NetworkInfo(); | 21 NetworkInfo(); |
| 21 ~NetworkInfo(); | 22 ~NetworkInfo(); |
| 22 | 23 |
| 23 std::string name; | 24 std::string name; |
| 24 PP_NetworkListType_Private type; | 25 PP_NetworkListType_Private type; |
| 25 PP_NetworkListState_Private state; | 26 PP_NetworkListState_Private state; |
| 26 std::vector<PP_NetAddress_Private> addresses; | 27 std::vector<PP_NetAddress_Private> addresses; |
| 27 std::string display_name; | 28 std::string display_name; |
| 28 int mtu; | 29 int mtu; |
| 29 }; | 30 }; |
| 30 typedef std::vector<NetworkInfo> NetworkList; | 31 typedef std::vector<NetworkInfo> NetworkList; |
| 31 | 32 |
| 32 // NetworkListStorage is refcounted container for NetworkList. It | 33 class NetworkListResource |
| 33 // allows sharing of one NetworkList object between multiple | 34 : public Resource, |
|
yzshen1
2013/09/13 17:47:10
You probably want to still include resource.h on l
Sergey Ulanov
2013/09/13 18:35:00
Done.
| |
| 34 // NetworkList resources. | 35 public thunk::PPB_NetworkList_API { |
| 35 class PPAPI_SHARED_EXPORT NetworkListStorage | |
| 36 : public base::RefCountedThreadSafe<NetworkListStorage> { | |
| 37 public: | 36 public: |
| 38 explicit NetworkListStorage(const NetworkList& list); | 37 NetworkListResource(ResourceObjectType type, |
|
yzshen1
2013/09/13 17:47:10
|type| is not needed, we only use it as PROXY.
Sergey Ulanov
2013/09/13 18:35:00
Done.
| |
| 39 | 38 PP_Instance instance, |
| 40 const NetworkList& list() { return list_; } | 39 const NetworkList& list); |
| 41 | 40 virtual ~NetworkListResource(); |
| 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 | 41 |
| 61 // Resource override. | 42 // Resource override. |
| 62 virtual ::ppapi::thunk::PPB_NetworkList_API* | 43 virtual thunk::PPB_NetworkList_API* AsPPB_NetworkList_API() OVERRIDE; |
| 63 AsPPB_NetworkList_API() OVERRIDE; | |
| 64 | 44 |
| 65 // PPB_NetworkList_API implementation. | 45 // PPB_NetworkList_API implementation. |
| 66 virtual const NetworkList& GetNetworkListData() const OVERRIDE; | |
| 67 virtual uint32_t GetCount() OVERRIDE; | 46 virtual uint32_t GetCount() OVERRIDE; |
| 68 virtual PP_Var GetName(uint32_t index) OVERRIDE; | 47 virtual PP_Var GetName(uint32_t index) OVERRIDE; |
| 69 virtual PP_NetworkListType_Private GetType(uint32_t index) OVERRIDE; | 48 virtual PP_NetworkListType_Private GetType(uint32_t index) OVERRIDE; |
| 70 virtual PP_NetworkListState_Private GetState(uint32_t index) OVERRIDE; | 49 virtual PP_NetworkListState_Private GetState(uint32_t index) OVERRIDE; |
| 71 virtual int32_t GetIpAddresses(uint32_t index, | 50 virtual int32_t GetIpAddresses(uint32_t index, |
| 72 const PP_ArrayOutput& output) OVERRIDE; | 51 const PP_ArrayOutput& output) OVERRIDE; |
| 73 virtual PP_Var GetDisplayName(uint32_t index) OVERRIDE; | 52 virtual PP_Var GetDisplayName(uint32_t index) OVERRIDE; |
| 74 virtual uint32_t GetMTU(uint32_t index) OVERRIDE; | 53 virtual uint32_t GetMTU(uint32_t index) OVERRIDE; |
| 75 | 54 |
| 76 private: | 55 private: |
| 77 PPB_NetworkList_Private_Shared(ResourceObjectType type, | 56 NetworkList list_; |
| 78 PP_Instance instance, | |
| 79 const scoped_refptr<NetworkListStorage>& list); | |
| 80 | 57 |
| 81 scoped_refptr<NetworkListStorage> list_; | 58 DISALLOW_COPY_AND_ASSIGN(NetworkListResource); |
| 82 | |
| 83 DISALLOW_COPY_AND_ASSIGN(PPB_NetworkList_Private_Shared); | |
| 84 }; | 59 }; |
| 85 | 60 |
| 61 } // namespace proxy | |
| 86 } // namespace ppapi | 62 } // namespace ppapi |
| 87 | 63 |
| 88 #endif // PPAPI_SHARED_IMPL_PPB_NETWORK_LIST_PRIVATE_SHARED_H_ | 64 #endif // PPAPI_PROXY_NETWORK_LIST_RESOURCE_H_ |
| OLD | NEW |