| OLD | NEW |
| 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 NET_DNS_ADDRESS_SORTER_H_ | 5 #ifndef NET_DNS_ADDRESS_SORTER_H_ |
| 6 #define NET_DNS_ADDRESS_SORTER_H_ | 6 #define NET_DNS_ADDRESS_SORTER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 class AddressList; | 15 class AddressList; |
| 16 | 16 |
| 17 // Sorts AddressList according to RFC3484, by likelihood of successful | 17 // Sorts AddressList according to RFC3484, by likelihood of successful |
| 18 // connection. Depending on the platform, the sort could be performed | 18 // connection. Depending on the platform, the sort could be performed |
| 19 // asynchronously by the OS, or synchronously by local implementation. | 19 // asynchronously by the OS, or synchronously by local implementation. |
| 20 // AddressSorter does not necessarily preserve port numbers on the sorted list. | 20 // AddressSorter does not necessarily preserve port numbers on the sorted list. |
| 21 class NET_EXPORT AddressSorter { | 21 class NET_EXPORT AddressSorter { |
| 22 public: | 22 public: |
| 23 typedef base::Callback<void(bool success, | 23 typedef base::Callback<void(bool success, const AddressList& list)> |
| 24 const AddressList& list)> CallbackType; | 24 CallbackType; |
| 25 | 25 |
| 26 virtual ~AddressSorter() {} | 26 virtual ~AddressSorter() {} |
| 27 | 27 |
| 28 // Sorts |list|, which must include at least one IPv6 address. | 28 // Sorts |list|, which must include at least one IPv6 address. |
| 29 // Calls |callback| upon completion. Could complete synchronously. Could | 29 // Calls |callback| upon completion. Could complete synchronously. Could |
| 30 // complete after this AddressSorter is destroyed. | 30 // complete after this AddressSorter is destroyed. |
| 31 virtual void Sort(const AddressList& list, | 31 virtual void Sort(const AddressList& list, |
| 32 const CallbackType& callback) const = 0; | 32 const CallbackType& callback) const = 0; |
| 33 | 33 |
| 34 // Creates platform-dependent AddressSorter. | 34 // Creates platform-dependent AddressSorter. |
| 35 static scoped_ptr<AddressSorter> CreateAddressSorter(); | 35 static scoped_ptr<AddressSorter> CreateAddressSorter(); |
| 36 | 36 |
| 37 protected: | 37 protected: |
| 38 AddressSorter() {} | 38 AddressSorter() {} |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 DISALLOW_COPY_AND_ASSIGN(AddressSorter); | 41 DISALLOW_COPY_AND_ASSIGN(AddressSorter); |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 } // namespace net | 44 } // namespace net |
| 45 | 45 |
| 46 #endif // NET_DNS_ADDRESS_SORTER_H_ | 46 #endif // NET_DNS_ADDRESS_SORTER_H_ |
| OLD | NEW |