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 //////////////////////////////////////////////////////////////////////////////// | 5 //////////////////////////////////////////////////////////////////////////////// |
6 // Threading considerations: | 6 // Threading considerations: |
7 // | 7 // |
8 // This class is designed to meet various threading guarantees starting from the | 8 // This class is designed to meet various threading guarantees starting from the |
9 // ones imposed by NetworkChangeNotifier: | 9 // ones imposed by NetworkChangeNotifier: |
10 // - The notifier can be constructed on any thread. | 10 // - The notifier can be constructed on any thread. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // delegate then forwards these notifications to the threads of each observer | 52 // delegate then forwards these notifications to the threads of each observer |
53 // (network change notifier). The network change notifier than processes the | 53 // (network change notifier). The network change notifier than processes the |
54 // state change, and notifies each of its observers on their threads. | 54 // state change, and notifies each of its observers on their threads. |
55 // | 55 // |
56 // This can also be seen as: | 56 // This can also be seen as: |
57 // Android platform -> NetworkChangeNotifier (Java) -> | 57 // Android platform -> NetworkChangeNotifier (Java) -> |
58 // NetworkChangeNotifierDelegateAndroid -> NetworkChangeNotifierAndroid. | 58 // NetworkChangeNotifierDelegateAndroid -> NetworkChangeNotifierAndroid. |
59 | 59 |
60 #include "net/android/network_change_notifier_android.h" | 60 #include "net/android/network_change_notifier_android.h" |
61 | 61 |
62 #include <unordered_set> | |
63 | |
64 #include "base/android/build_info.h" | 62 #include "base/android/build_info.h" |
65 #include "base/macros.h" | 63 #include "base/macros.h" |
66 #include "base/metrics/histogram_macros.h" | 64 #include "base/metrics/histogram_macros.h" |
67 #include "base/threading/thread.h" | 65 #include "base/threading/thread.h" |
68 #include "net/base/address_tracker_linux.h" | 66 #include "net/base/address_tracker_linux.h" |
69 #include "net/dns/dns_config_service_posix.h" | 67 #include "net/dns/dns_config_service_posix.h" |
70 | 68 |
71 namespace net { | 69 namespace net { |
72 | 70 |
73 // Expose kInvalidNetworkHandle out to Java as NetId.INVALID. The notion of | 71 // Expose kInvalidNetworkHandle out to Java as NetId.INVALID. The notion of |
(...skipping 14 matching lines...) Expand all Loading... |
88 public NetworkChangeNotifier::NetworkChangeObserver { | 86 public NetworkChangeNotifier::NetworkChangeObserver { |
89 public: | 87 public: |
90 explicit DnsConfigServiceThread(const DnsConfig* dns_config_for_testing) | 88 explicit DnsConfigServiceThread(const DnsConfig* dns_config_for_testing) |
91 : base::Thread("DnsConfigService"), | 89 : base::Thread("DnsConfigService"), |
92 dns_config_for_testing_(dns_config_for_testing), | 90 dns_config_for_testing_(dns_config_for_testing), |
93 creation_time_(base::Time::Now()), | 91 creation_time_(base::Time::Now()), |
94 address_tracker_(base::Bind(base::DoNothing), | 92 address_tracker_(base::Bind(base::DoNothing), |
95 base::Bind(base::DoNothing), | 93 base::Bind(base::DoNothing), |
96 // We're only interested in tunnel interface changes. | 94 // We're only interested in tunnel interface changes. |
97 base::Bind(NotifyNetworkChangeNotifierObservers), | 95 base::Bind(NotifyNetworkChangeNotifierObservers), |
98 std::unordered_set<std::string>()) {} | 96 base::hash_set<std::string>()) {} |
99 | 97 |
100 ~DnsConfigServiceThread() override { | 98 ~DnsConfigServiceThread() override { |
101 NetworkChangeNotifier::RemoveNetworkChangeObserver(this); | 99 NetworkChangeNotifier::RemoveNetworkChangeObserver(this); |
102 Stop(); | 100 Stop(); |
103 } | 101 } |
104 | 102 |
105 void InitAfterStart() { | 103 void InitAfterStart() { |
106 DCHECK(IsRunning()); | 104 DCHECK(IsRunning()); |
107 NetworkChangeNotifier::AddNetworkChangeObserver(this); | 105 NetworkChangeNotifier::AddNetworkChangeObserver(this); |
108 } | 106 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 NetworkChangeNotifier::GetConnectionType(); | 273 NetworkChangeNotifier::GetConnectionType(); |
276 NetworkChangeNotifier::LogOperatorCodeHistogram(type); | 274 NetworkChangeNotifier::LogOperatorCodeHistogram(type); |
277 if (NetworkChangeNotifier::IsConnectionCellular(type)) { | 275 if (NetworkChangeNotifier::IsConnectionCellular(type)) { |
278 UMA_HISTOGRAM_ENUMERATION("NCN.CellularConnectionSubtype", | 276 UMA_HISTOGRAM_ENUMERATION("NCN.CellularConnectionSubtype", |
279 delegate_->GetCurrentConnectionSubtype(), | 277 delegate_->GetCurrentConnectionSubtype(), |
280 SUBTYPE_LAST + 1); | 278 SUBTYPE_LAST + 1); |
281 } | 279 } |
282 } | 280 } |
283 | 281 |
284 } // namespace net | 282 } // namespace net |
OLD | NEW |