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 #include "chrome/browser/chromeos/net/network_change_notifier_network_library.h" | 5 #include "chrome/browser/chromeos/net/network_change_notifier_network_library.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "chrome/browser/chromeos/cros/cros_library.h" | 10 #include "chrome/browser/chromeos/cros/cros_library.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 base::TimeDelta::FromMilliseconds(kInitialNotificationCheckDelayMS)); | 64 base::TimeDelta::FromMilliseconds(kInitialNotificationCheckDelayMS)); |
65 } | 65 } |
66 | 66 |
67 NetworkChangeNotifierNetworkLibrary::~NetworkChangeNotifierNetworkLibrary() { | 67 NetworkChangeNotifierNetworkLibrary::~NetworkChangeNotifierNetworkLibrary() { |
68 } | 68 } |
69 | 69 |
70 void NetworkChangeNotifierNetworkLibrary::Init() { | 70 void NetworkChangeNotifierNetworkLibrary::Init() { |
71 chromeos::NetworkLibrary* network_library = | 71 chromeos::NetworkLibrary* network_library = |
72 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 72 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
73 network_library->AddNetworkManagerObserver(this); | 73 network_library->AddNetworkManagerObserver(this); |
74 | 74 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
75 DBusThreadManager::Get()->GetRootPowerManagerClient()->AddObserver(this); | 75 DBusThreadManager::Get()->GetRootPowerManagerClient()->AddObserver(this); |
76 | 76 |
77 dns_config_service_.reset(new DnsConfigServiceChromeos()); | 77 dns_config_service_.reset(new DnsConfigServiceChromeos()); |
78 dns_config_service_->WatchConfig( | 78 dns_config_service_->WatchConfig( |
79 base::Bind(NetworkChangeNotifier::SetDnsConfig)); | 79 base::Bind(NetworkChangeNotifier::SetDnsConfig)); |
80 | 80 |
81 UpdateNetworkState(network_library); | 81 UpdateNetworkState(network_library); |
82 } | 82 } |
83 | 83 |
84 void NetworkChangeNotifierNetworkLibrary::Shutdown() { | 84 void NetworkChangeNotifierNetworkLibrary::Shutdown() { |
85 weak_factory_.InvalidateWeakPtrs(); | 85 weak_factory_.InvalidateWeakPtrs(); |
86 | 86 |
87 dns_config_service_.reset(); | 87 dns_config_service_.reset(); |
88 | 88 |
89 if (!chromeos::CrosLibrary::Get()) | 89 if (!chromeos::CrosLibrary::Get()) |
90 return; | 90 return; |
91 | 91 |
92 chromeos::NetworkLibrary* lib = | 92 chromeos::NetworkLibrary* lib = |
93 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 93 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
94 lib->RemoveNetworkManagerObserver(this); | 94 lib->RemoveNetworkManagerObserver(this); |
95 lib->RemoveObserverForAllNetworks(this); | 95 lib->RemoveObserverForAllNetworks(this); |
96 | 96 |
97 DBusThreadManager::Get()->GetRootPowerManagerClient()->RemoveObserver(this); | 97 DBusThreadManager::Get()->GetRootPowerManagerClient()->RemoveObserver(this); |
| 98 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
98 } | 99 } |
99 | 100 |
100 void NetworkChangeNotifierNetworkLibrary::OnResume( | 101 void NetworkChangeNotifierNetworkLibrary::SystemResumed( |
101 const base::TimeDelta& sleep_duration) { | 102 const base::TimeDelta& sleep_duration) { |
102 // Force invalidation of various net resources on system resume. | 103 // Force invalidation of various net resources on system resume. |
103 BrowserThread::PostTask( | 104 BrowserThread::PostTask( |
104 BrowserThread::IO, FROM_HERE, | 105 BrowserThread::IO, FROM_HERE, |
105 base::Bind( | 106 base::Bind( |
106 &NetworkChangeNotifier::NotifyObserversOfIPAddressChange)); | 107 &NetworkChangeNotifier::NotifyObserversOfIPAddressChange)); |
107 } | 108 } |
108 | 109 |
| 110 void NetworkChangeNotifierNetworkLibrary::OnResume( |
| 111 const base::TimeDelta& sleep_duration) { |
| 112 SystemResumed(sleep_duration); |
| 113 } |
| 114 |
109 | 115 |
110 void NetworkChangeNotifierNetworkLibrary::OnNetworkManagerChanged( | 116 void NetworkChangeNotifierNetworkLibrary::OnNetworkManagerChanged( |
111 chromeos::NetworkLibrary* cros) { | 117 chromeos::NetworkLibrary* cros) { |
112 UpdateNetworkState(cros); | 118 UpdateNetworkState(cros); |
113 } | 119 } |
114 | 120 |
115 net::NetworkChangeNotifier::ConnectionType | 121 net::NetworkChangeNotifier::ConnectionType |
116 NetworkChangeNotifierNetworkLibrary::GetCurrentConnectionType() const { | 122 NetworkChangeNotifierNetworkLibrary::GetCurrentConnectionType() const { |
117 return connection_type_; | 123 return connection_type_; |
118 } | 124 } |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 // Delay values arrived at by simple experimentation and adjusted so as to | 349 // Delay values arrived at by simple experimentation and adjusted so as to |
344 // produce a single signal when switching between network connections. | 350 // produce a single signal when switching between network connections. |
345 params.ip_address_offline_delay_ = base::TimeDelta::FromMilliseconds(4000); | 351 params.ip_address_offline_delay_ = base::TimeDelta::FromMilliseconds(4000); |
346 params.ip_address_online_delay_ = base::TimeDelta::FromMilliseconds(1000); | 352 params.ip_address_online_delay_ = base::TimeDelta::FromMilliseconds(1000); |
347 params.connection_type_offline_delay_ = base::TimeDelta::FromMilliseconds(0); | 353 params.connection_type_offline_delay_ = base::TimeDelta::FromMilliseconds(0); |
348 params.connection_type_online_delay_ = base::TimeDelta::FromMilliseconds(0); | 354 params.connection_type_online_delay_ = base::TimeDelta::FromMilliseconds(0); |
349 return params; | 355 return params; |
350 } | 356 } |
351 | 357 |
352 } // namespace chromeos | 358 } // namespace chromeos |
OLD | NEW |