1 // Copyright 2013 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_PROXY_HOST_RESOLVER_RESOURCE_BASE_H_
6 #define PPAPI_PROXY_HOST_RESOLVER_RESOURCE_BASE_H_
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
14 #include "ppapi/c/private/ppb_host_resolver_private.h"
15 #include "ppapi/proxy/plugin_resource.h"
16 #include "ppapi/proxy/ppapi_proxy_export.h"
20 class TrackedCallback
;
29 class NetAddressResource
;
31 class PPAPI_PROXY_EXPORT HostResolverResourceBase
: public PluginResource
{
33 HostResolverResourceBase(Connection connection
, PP_Instance instance
);
34 virtual ~HostResolverResourceBase();
36 int32_t ResolveImpl(const char* host
,
38 const PP_HostResolver_Private_Hint
* hint
,
39 scoped_refptr
<TrackedCallback
> callback
);
40 PP_Var
GetCanonicalNameImpl();
41 uint32_t GetSizeImpl();
42 scoped_refptr
<NetAddressResource
> GetNetAddressImpl(uint32_t index
);
45 // IPC message handlers.
46 void OnPluginMsgResolveReply(
47 const ResourceMessageReplyParams
& params
,
48 const std::string
& canonical_name
,
49 const std::vector
<PP_NetAddress_Private
>& net_address_list
);
51 void SendResolve(const HostPortPair
& host_port
,
52 const PP_HostResolver_Private_Hint
* hint
);
54 bool ResolveInProgress() const;
56 scoped_refptr
<TrackedCallback
> resolve_callback_
;
58 // Set to false if there is a pending resolve request or the previous request
60 bool allow_get_results_
;
61 std::string canonical_name_
;
62 std::vector
<scoped_refptr
<NetAddressResource
> > net_address_list_
;
64 DISALLOW_COPY_AND_ASSIGN(HostResolverResourceBase
);
70 #endif // PPAPI_PROXY_HOST_RESOLVER_RESOURCE_BASE_H_