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

Side by Side Diff: content/browser/renderer_host/pepper/pepper_lookup_request.h

Issue 2214693002: First step to remove SingleRequestHostResolver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: single Created 4 years, 4 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
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 CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_LOOKUP_REQUEST_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_LOOKUP_REQUEST_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_LOOKUP_REQUEST_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_LOOKUP_REQUEST_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "net/base/address_list.h" 12 #include "net/base/address_list.h"
13 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 #include "net/dns/host_resolver.h" 14 #include "net/dns/host_resolver.h"
15 #include "net/dns/single_request_host_resolver.h"
16 15
17 namespace content { 16 namespace content {
18 17
19 template <class T> 18 template <class T>
20 class PepperLookupRequest { 19 class PepperLookupRequest {
21 public: 20 public:
22 typedef base::Callback<void(int, const net::AddressList&, const T&)> 21 typedef base::Callback<void(int, const net::AddressList&, const T&)>
23 LookupRequestCallback; 22 LookupRequestCallback;
24 23
25 // Takes ownership over |bound_info|. |bound_info| will be passed to 24 // Takes ownership over |bound_info|. |bound_info| will be passed to
26 // callback, when lookup will finish. 25 // callback, when lookup will finish.
27 PepperLookupRequest(net::HostResolver* resolver, 26 PepperLookupRequest(net::HostResolver* resolver,
28 const net::HostResolver::RequestInfo& request_info, 27 const net::HostResolver::RequestInfo& request_info,
29 net::RequestPriority priority, 28 net::RequestPriority priority,
30 T* bound_info, 29 T* bound_info,
31 const LookupRequestCallback& callback) 30 const LookupRequestCallback& callback)
32 : resolver_(resolver), 31 : resolver_(resolver),
33 request_info_(request_info), 32 request_info_(request_info),
34 priority_(priority), 33 priority_(priority),
35 bound_info_(bound_info), 34 bound_info_(bound_info),
36 callback_(callback) {} 35 callback_(callback) {}
37 36
38 void Start() { 37 void Start() {
39 int result = 38 int result =
40 resolver_.Resolve(request_info_, 39 resolver_->Resolve(request_info_, priority_, &addresses_,
41 priority_, 40 base::Bind(&PepperLookupRequest<T>::OnLookupFinished,
42 &addresses_, 41 base::Unretained(this)),
43 base::Bind(&PepperLookupRequest<T>::OnLookupFinished, 42 &request_, net::BoundNetLog());
44 base::Unretained(this)),
45 net::BoundNetLog());
46 if (result != net::ERR_IO_PENDING) 43 if (result != net::ERR_IO_PENDING)
47 OnLookupFinished(result); 44 OnLookupFinished(result);
48 } 45 }
49 46
50 private: 47 private:
51 void OnLookupFinished(int result) { 48 void OnLookupFinished(int result) {
52 callback_.Run(result, addresses_, *bound_info_); 49 callback_.Run(result, addresses_, *bound_info_);
53 delete this; 50 delete this;
54 } 51 }
55 52
56 net::SingleRequestHostResolver resolver_; 53 net::HostResolver* resolver_;
54 std::unique_ptr<net::HostResolver::Request> request_;
57 net::HostResolver::RequestInfo request_info_; 55 net::HostResolver::RequestInfo request_info_;
58 net::RequestPriority priority_; 56 net::RequestPriority priority_;
59 std::unique_ptr<T> bound_info_; 57 std::unique_ptr<T> bound_info_;
60 LookupRequestCallback callback_; 58 LookupRequestCallback callback_;
61 59
62 net::AddressList addresses_; 60 net::AddressList addresses_;
63 61
64 DISALLOW_COPY_AND_ASSIGN(PepperLookupRequest); 62 DISALLOW_COPY_AND_ASSIGN(PepperLookupRequest);
65 }; 63 };
66 64
67 } // namespace content 65 } // namespace content
68 66
69 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_LOOKUP_REQUEST_H_ 67 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_LOOKUP_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698