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_POSIX_H_ | 5 #ifndef NET_DNS_ADDRESS_SORTER_POSIX_H_ |
6 #define NET_DNS_ADDRESS_SORTER_POSIX_H_ | 6 #define NET_DNS_ADDRESS_SORTER_POSIX_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/thread_checker.h" |
13 #include "net/base/address_list.h" | 13 #include "net/base/address_list.h" |
14 #include "net/base/ip_address.h" | 14 #include "net/base/ip_address.h" |
15 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
16 #include "net/base/network_change_notifier.h" | 16 #include "net/base/network_change_notifier.h" |
17 #include "net/dns/address_sorter.h" | 17 #include "net/dns/address_sorter.h" |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 | 20 |
21 class ClientSocketFactory; | 21 class ClientSocketFactory; |
22 | 22 |
23 // This implementation uses explicit policy to perform the sorting. It is not | 23 // This implementation uses explicit policy to perform the sorting. It is not |
24 // thread-safe and always completes synchronously. | 24 // thread-safe and always completes synchronously. |
25 class NET_EXPORT_PRIVATE AddressSorterPosix | 25 class NET_EXPORT_PRIVATE AddressSorterPosix |
26 : public AddressSorter, | 26 : public AddressSorter, |
27 public base::NonThreadSafe, | |
28 public NetworkChangeNotifier::IPAddressObserver { | 27 public NetworkChangeNotifier::IPAddressObserver { |
29 public: | 28 public: |
30 // Generic policy entry. | 29 // Generic policy entry. |
31 struct PolicyEntry { | 30 struct PolicyEntry { |
32 // IPv4 addresses must be mapped to IPv6. | 31 // IPv4 addresses must be mapped to IPv6. |
33 unsigned char prefix[IPAddress::kIPv6AddressSize]; | 32 unsigned char prefix[IPAddress::kIPv6AddressSize]; |
34 unsigned prefix_length; | 33 unsigned prefix_length; |
35 unsigned value; | 34 unsigned value; |
36 }; | 35 }; |
37 | 36 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 77 |
79 // Mutable to allow using default values for source addresses which were not | 78 // Mutable to allow using default values for source addresses which were not |
80 // found in most recent OnIPAddressChanged. | 79 // found in most recent OnIPAddressChanged. |
81 mutable SourceAddressMap source_map_; | 80 mutable SourceAddressMap source_map_; |
82 | 81 |
83 ClientSocketFactory* socket_factory_; | 82 ClientSocketFactory* socket_factory_; |
84 PolicyTable precedence_table_; | 83 PolicyTable precedence_table_; |
85 PolicyTable label_table_; | 84 PolicyTable label_table_; |
86 PolicyTable ipv4_scope_table_; | 85 PolicyTable ipv4_scope_table_; |
87 | 86 |
| 87 THREAD_CHECKER(thread_checker_); |
| 88 |
88 DISALLOW_COPY_AND_ASSIGN(AddressSorterPosix); | 89 DISALLOW_COPY_AND_ASSIGN(AddressSorterPosix); |
89 }; | 90 }; |
90 | 91 |
91 } // namespace net | 92 } // namespace net |
92 | 93 |
93 #endif // NET_DNS_ADDRESS_SORTER_POSIX_H_ | 94 #endif // NET_DNS_ADDRESS_SORTER_POSIX_H_ |
OLD | NEW |