Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / net / dns / address_sorter.h
blob6ac943086ef6f78c1094ff307605135006c6d156
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 NET_DNS_ADDRESS_SORTER_H_
6 #define NET_DNS_ADDRESS_SORTER_H_
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "net/base/net_export.h"
13 namespace net {
15 class AddressList;
17 // Sorts AddressList according to RFC3484, by likelihood of successful
18 // connection. Depending on the platform, the sort could be performed
19 // asynchronously by the OS, or synchronously by local implementation.
20 // AddressSorter does not necessarily preserve port numbers on the sorted list.
21 class NET_EXPORT AddressSorter {
22 public:
23 typedef base::Callback<void(bool success,
24 const AddressList& list)> CallbackType;
26 virtual ~AddressSorter() {}
28 // Sorts |list|, which must include at least one IPv6 address.
29 // Calls |callback| upon completion. Could complete synchronously. Could
30 // complete after this AddressSorter is destroyed.
31 virtual void Sort(const AddressList& list,
32 const CallbackType& callback) const = 0;
34 // Creates platform-dependent AddressSorter.
35 static scoped_ptr<AddressSorter> CreateAddressSorter();
37 protected:
38 AddressSorter() {}
40 private:
41 DISALLOW_COPY_AND_ASSIGN(AddressSorter);
44 } // namespace net
46 #endif // NET_DNS_ADDRESS_SORTER_H_