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.
5 #ifndef PPAPI_SHARED_IMPL_PPB_NETWORK_LIST_PRIVATE_SHARED_H_
6 #define PPAPI_SHARED_IMPL_PPB_NETWORK_LIST_PRIVATE_SHARED_H_
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "ppapi/shared_impl/resource.h"
14 #include "ppapi/thunk/ppb_network_list_api.h"
18 struct PPAPI_SHARED_EXPORT NetworkInfo
{
23 PP_NetworkListType_Private type
;
24 PP_NetworkListState_Private state
;
25 std::vector
<PP_NetAddress_Private
> addresses
;
26 std::string display_name
;
29 typedef std::vector
<NetworkInfo
> NetworkList
;
31 // NetworkListStorage is refcounted container for NetworkList. It
32 // allows sharing of one NetworkList object between multiple
33 // NetworkList resources.
34 class PPAPI_SHARED_EXPORT NetworkListStorage
35 : public base::RefCountedThreadSafe
<NetworkListStorage
> {
37 explicit NetworkListStorage(const NetworkList
& list
);
39 const NetworkList
& list() { return list_
; }
42 friend class base::RefCountedThreadSafe
<NetworkListStorage
>;
43 ~NetworkListStorage();
47 DISALLOW_COPY_AND_ASSIGN(NetworkListStorage
);
50 class PPAPI_SHARED_EXPORT PPB_NetworkList_Private_Shared
51 : public ::ppapi::Resource
,
52 public ::ppapi::thunk::PPB_NetworkList_API
{
54 static PP_Resource
Create(ResourceObjectType type
,
56 const scoped_refptr
<NetworkListStorage
>& list
);
58 virtual ~PPB_NetworkList_Private_Shared();
61 virtual ::ppapi::thunk::PPB_NetworkList_API
*
62 AsPPB_NetworkList_API() OVERRIDE
;
64 // PPB_NetworkList_API implementation.
65 virtual const NetworkList
& GetNetworkListData() const OVERRIDE
;
66 virtual uint32_t GetCount() OVERRIDE
;
67 virtual PP_Var
GetName(uint32_t index
) OVERRIDE
;
68 virtual PP_NetworkListType_Private
GetType(uint32_t index
) OVERRIDE
;
69 virtual PP_NetworkListState_Private
GetState(uint32_t index
) OVERRIDE
;
70 virtual int32_t GetIpAddresses(uint32_t index
,
71 PP_NetAddress_Private addresses
[],
72 uint32_t count
) OVERRIDE
;
73 virtual PP_Var
GetDisplayName(uint32_t index
) OVERRIDE
;
74 virtual uint32_t GetMTU(uint32_t index
) OVERRIDE
;
77 PPB_NetworkList_Private_Shared(ResourceObjectType type
,
79 const scoped_refptr
<NetworkListStorage
>& list
);
81 scoped_refptr
<NetworkListStorage
> list_
;
83 DISALLOW_COPY_AND_ASSIGN(PPB_NetworkList_Private_Shared
);
88 #endif // PPAPI_SHARED_IMPL_PPB_NETWORK_LIST_PRIVATE_SHARED_H_