| Index: content/browser/background_sync/background_sync_network_observer.cc
|
| diff --git a/content/browser/background_sync/background_sync_network_observer.cc b/content/browser/background_sync/background_sync_network_observer.cc
|
| index 1c6f2bd98163864f14e98ed2647fdf00a6550117..a08e7d837183f989a37c46a713523ec6d84f1689 100644
|
| --- a/content/browser/background_sync/background_sync_network_observer.cc
|
| +++ b/content/browser/background_sync/background_sync_network_observer.cc
|
| @@ -11,6 +11,15 @@
|
|
|
| namespace content {
|
|
|
| +// static
|
| +bool BackgroundSyncNetworkObserver::ignore_network_change_notifier_ = false;
|
| +
|
| +// static
|
| +void BackgroundSyncNetworkObserver::SetIgnoreNetworkChangeNotifierForTests(
|
| + bool ignore) {
|
| + ignore_network_change_notifier_ = ignore;
|
| +}
|
| +
|
| BackgroundSyncNetworkObserver::BackgroundSyncNetworkObserver(
|
| const base::Closure& network_changed_callback)
|
| : connection_type_(net::NetworkChangeNotifier::GetConnectionType()),
|
| @@ -47,17 +56,18 @@ bool BackgroundSyncNetworkObserver::NetworkSufficient(
|
| return false;
|
| }
|
|
|
| -void BackgroundSyncNetworkObserver::NotifyNetworkChanged() {
|
| +void BackgroundSyncNetworkObserver::OnNetworkChanged(
|
| + net::NetworkChangeNotifier::ConnectionType connection_type) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
|
|
| - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
|
| - network_changed_callback_);
|
| + if (ignore_network_change_notifier_)
|
| + return;
|
| + NotifyManagerIfNetworkChanged(connection_type);
|
| }
|
|
|
| -void BackgroundSyncNetworkObserver::OnNetworkChanged(
|
| +void BackgroundSyncNetworkObserver::NotifyManagerIfNetworkChanged(
|
| net::NetworkChangeNotifier::ConnectionType connection_type) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| -
|
| if (connection_type == connection_type_)
|
| return;
|
|
|
| @@ -65,4 +75,11 @@ void BackgroundSyncNetworkObserver::OnNetworkChanged(
|
| NotifyNetworkChanged();
|
| }
|
|
|
| +void BackgroundSyncNetworkObserver::NotifyNetworkChanged() {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| +
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
|
| + network_changed_callback_);
|
| +}
|
| +
|
| } // namespace content
|
|
|