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 CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_LOOKUP_REQUEST_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_LOOKUP_REQUEST_H_
8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "net/base/address_list.h"
11 #include "net/base/net_errors.h"
12 #include "net/dns/host_resolver.h"
13 #include "net/dns/single_request_host_resolver.h"
18 class PepperLookupRequest
{
20 typedef base::Callback
<void(int, const net::AddressList
&, const T
&)>
21 LookupRequestCallback
;
23 // Takes ownership over |bound_info|. |bound_info| will be passed to
24 // callback, when lookup will finish.
25 PepperLookupRequest(net::HostResolver
* resolver
,
26 const net::HostResolver::RequestInfo
& request_info
,
27 net::RequestPriority priority
,
29 const LookupRequestCallback
& callback
)
30 : resolver_(resolver
),
31 request_info_(request_info
),
33 bound_info_(bound_info
),
34 callback_(callback
) {}
38 resolver_
.Resolve(request_info_
,
41 base::Bind(&PepperLookupRequest
<T
>::OnLookupFinished
,
42 base::Unretained(this)),
44 if (result
!= net::ERR_IO_PENDING
)
45 OnLookupFinished(result
);
49 void OnLookupFinished(int result
) {
50 callback_
.Run(result
, addresses_
, *bound_info_
);
54 net::SingleRequestHostResolver resolver_
;
55 net::HostResolver::RequestInfo request_info_
;
56 net::RequestPriority priority_
;
57 scoped_ptr
<T
> bound_info_
;
58 LookupRequestCallback callback_
;
60 net::AddressList addresses_
;
62 DISALLOW_COPY_AND_ASSIGN(PepperLookupRequest
);
65 } // namespace content
67 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_LOOKUP_REQUEST_H_