Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: ppapi/proxy/network_list_resource.h

Issue 23819033: Simplify PPB_NetworkMonitor proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compilation after r169825 Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/interface_list.cc ('k') | ppapi/proxy/network_list_resource.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/proxy/ppapi_proxy_export.h"
15 #include "ppapi/proxy/serialized_structs.h"
14 #include "ppapi/shared_impl/resource.h" 16 #include "ppapi/shared_impl/resource.h"
15 #include "ppapi/thunk/ppb_network_list_api.h" 17 #include "ppapi/thunk/ppb_network_list_api.h"
16 18
17 namespace ppapi { 19 namespace ppapi {
20 namespace proxy {
18 21
19 struct PPAPI_SHARED_EXPORT NetworkInfo { 22 class NetworkListResource
20 NetworkInfo(); 23 : public Resource,
21 ~NetworkInfo(); 24 public thunk::PPB_NetworkList_API {
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: 25 public:
38 explicit NetworkListStorage(const NetworkList& list); 26 NetworkListResource(PP_Instance instance,
39 27 const SerializedNetworkList& list);
40 const NetworkList& list() { return list_; } 28 virtual ~NetworkListResource();
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 29
61 // Resource override. 30 // Resource override.
62 virtual ::ppapi::thunk::PPB_NetworkList_API* 31 virtual thunk::PPB_NetworkList_API* AsPPB_NetworkList_API() OVERRIDE;
63 AsPPB_NetworkList_API() OVERRIDE;
64 32
65 // PPB_NetworkList_API implementation. 33 // PPB_NetworkList_API implementation.
66 virtual const NetworkList& GetNetworkListData() const OVERRIDE;
67 virtual uint32_t GetCount() OVERRIDE; 34 virtual uint32_t GetCount() OVERRIDE;
68 virtual PP_Var GetName(uint32_t index) OVERRIDE; 35 virtual PP_Var GetName(uint32_t index) OVERRIDE;
69 virtual PP_NetworkListType_Private GetType(uint32_t index) OVERRIDE; 36 virtual PP_NetworkListType_Private GetType(uint32_t index) OVERRIDE;
70 virtual PP_NetworkListState_Private GetState(uint32_t index) OVERRIDE; 37 virtual PP_NetworkListState_Private GetState(uint32_t index) OVERRIDE;
71 virtual int32_t GetIpAddresses(uint32_t index, 38 virtual int32_t GetIpAddresses(uint32_t index,
72 const PP_ArrayOutput& output) OVERRIDE; 39 const PP_ArrayOutput& output) OVERRIDE;
73 virtual PP_Var GetDisplayName(uint32_t index) OVERRIDE; 40 virtual PP_Var GetDisplayName(uint32_t index) OVERRIDE;
74 virtual uint32_t GetMTU(uint32_t index) OVERRIDE; 41 virtual uint32_t GetMTU(uint32_t index) OVERRIDE;
75 42
76 private: 43 private:
77 PPB_NetworkList_Private_Shared(ResourceObjectType type, 44 SerializedNetworkList list_;
78 PP_Instance instance,
79 const scoped_refptr<NetworkListStorage>& list);
80 45
81 scoped_refptr<NetworkListStorage> list_; 46 DISALLOW_COPY_AND_ASSIGN(NetworkListResource);
82
83 DISALLOW_COPY_AND_ASSIGN(PPB_NetworkList_Private_Shared);
84 }; 47 };
85 48
49 } // namespace proxy
86 } // namespace ppapi 50 } // namespace ppapi
87 51
88 #endif // PPAPI_SHARED_IMPL_PPB_NETWORK_LIST_PRIVATE_SHARED_H_ 52 #endif // PPAPI_PROXY_NETWORK_LIST_RESOURCE_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/interface_list.cc ('k') | ppapi/proxy/network_list_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698