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

Side by Side Diff: ppapi/shared_impl/private/ppb_host_resolver_shared.h

Issue 9455092: HostResolver is exposed to plugin. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: s/class HostPortPair/struct HostPortPair. Created 8 years, 9 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
OLDNEW
(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_PRIVATE_PPB_HOST_RESOLVER_SHARED_H_
6 #define PPAPI_SHARED_IMPL_PRIVATE_PPB_HOST_RESOLVER_SHARED_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "ppapi/shared_impl/resource.h"
15 #include "ppapi/shared_impl/tracked_callback.h"
16 #include "ppapi/thunk/ppb_host_resolver_private_api.h"
17
18 struct addrinfo;
19
20 namespace ppapi {
21
22 struct NameAndAddressPair {
23 std::string canonical_name;
24 PP_NetAddress_Private address;
25 };
26
27 struct HostPortPair {
28 std::string host;
29 uint16_t port;
30 };
31
32 typedef std::vector<NameAndAddressPair> NetworkList;
33
34 PPAPI_SHARED_EXPORT NetworkList*
35 CreateNetworkListFromAddrInfo(const addrinfo* ai);
36
37 class PPAPI_SHARED_EXPORT PPB_HostResolver_Shared
38 : public thunk::PPB_HostResolver_Private_API,
39 public Resource {
40 public:
41 // C-tor used in Impl case.
42 explicit PPB_HostResolver_Shared(PP_Instance instance);
43
44 // C-tor used in Proxy case.
45 explicit PPB_HostResolver_Shared(const HostResource& resource);
46
47 virtual ~PPB_HostResolver_Shared();
48
49 // Resource overrides.
50 virtual PPB_HostResolver_Private_API*
51 AsPPB_HostResolver_Private_API() OVERRIDE;
52
53 // PPB_HostResolver_Private_API implementation.
54 virtual int32_t Resolve(const char* host,
55 uint16_t port,
56 const PP_HostResolver_Private_Hint* hint,
57 PP_CompletionCallback callback) OVERRIDE;
58 virtual uint32_t GetSize() OVERRIDE;
59 virtual bool GetItem(uint32_t index,
60 PP_Var* canonical_name,
61 PP_NetAddress_Private* address) OVERRIDE;
62
63 void OnResolveCompleted(bool succeeded,
64 const NetworkList& network_list);
65
66 // Send functions that need to be implemented differently for the
67 // proxied and non-proxied derived classes.
68 virtual void SendResolve(const HostPortPair& host_port,
69 const PP_HostResolver_Private_Hint* hint) = 0;
70
71 protected:
72 static uint32 GenerateHostResolverID();
73 bool ResolveInProgress() const;
74
75 const uint32 host_resolver_id_;
76
77 scoped_refptr<TrackedCallback> resolve_callback_;
78
79 NetworkList network_list_;
80
81 DISALLOW_COPY_AND_ASSIGN(PPB_HostResolver_Shared);
82 };
83
84 } // namespace ppapi
85
86 #endif // PPAPI_SHARED_IMPL_PRIVATE_PPB_HOST_RESOLVER_SHARED_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698