Chromium Code Reviews| 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_BASE_NETWORK_CHANGE_NOTIFIER_H_ | 5 #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ |
| 6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ | 6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/observer_list_threadsafe.h" | 9 #include "base/observer_list_threadsafe.h" |
| 10 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 #endif | 123 #endif |
| 124 | 124 |
| 125 // Convenience method to determine if the user is offline. | 125 // Convenience method to determine if the user is offline. |
| 126 // Returns true if there is currently no internet connection. | 126 // Returns true if there is currently no internet connection. |
| 127 // | 127 // |
| 128 // A return value of |true| is a pretty strong indicator that the user | 128 // A return value of |true| is a pretty strong indicator that the user |
| 129 // won't be able to connect to remote sites. However, a return value of | 129 // won't be able to connect to remote sites. However, a return value of |
| 130 // |false| is inconclusive; even if some link is up, it is uncertain | 130 // |false| is inconclusive; even if some link is up, it is uncertain |
| 131 // whether a particular connection attempt to a particular remote site | 131 // whether a particular connection attempt to a particular remote site |
| 132 // will be successfully. | 132 // will be successfully. |
| 133 static bool IsOffline() { | 133 static bool IsOffline(); |
| 134 return GetConnectionType() == CONNECTION_NONE; | 134 |
| 135 } | 135 // Returns true if the current connection type uses WWAN. |
|
pauljensen
2012/10/12 14:01:15
I'd prefer "Celluar" to "WWAN" as its more common
| |
| 136 static bool IsOverWWAN(); | |
|
pauljensen
2012/10/12 14:01:15
Slight preference to "IsOn" or "IsUsing" over "IsO
| |
| 137 | |
| 138 // Returns true if |type| uses WWAN. | |
| 139 static bool IsOverWWAN(ConnectionType type); | |
| 136 | 140 |
| 137 // Like Create(), but for use in tests. The mock object doesn't monitor any | 141 // Like Create(), but for use in tests. The mock object doesn't monitor any |
| 138 // events, it merely rebroadcasts notifications when requested. | 142 // events, it merely rebroadcasts notifications when requested. |
| 139 static NetworkChangeNotifier* CreateMock(); | 143 static NetworkChangeNotifier* CreateMock(); |
| 140 | 144 |
| 141 // Registers |observer| to receive notifications of network changes. The | 145 // Registers |observer| to receive notifications of network changes. The |
| 142 // thread on which this is called is the thread on which |observer| will be | 146 // thread on which this is called is the thread on which |observer| will be |
| 143 // called back with notifications. This is safe to call if Create() has not | 147 // called back with notifications. This is safe to call if Create() has not |
| 144 // been called (as long as it doesn't race the Create() call on another | 148 // been called (as long as it doesn't race the Create() call on another |
| 145 // thread), in which case it will simply do nothing. | 149 // thread), in which case it will simply do nothing. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 | 233 |
| 230 // A little-piggy-back observer that simply logs UMA histogram data. | 234 // A little-piggy-back observer that simply logs UMA histogram data. |
| 231 scoped_ptr<HistogramWatcher> histogram_watcher_; | 235 scoped_ptr<HistogramWatcher> histogram_watcher_; |
| 232 | 236 |
| 233 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); | 237 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); |
| 234 }; | 238 }; |
| 235 | 239 |
| 236 } // namespace net | 240 } // namespace net |
| 237 | 241 |
| 238 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ | 242 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ |
| OLD | NEW |