| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/background_sync/background_sync_network_observer.h" | 5 #include "content/browser/background_sync/background_sync_network_observer.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 void BackgroundSyncNetworkObserver::OnNetworkChanged( | 59 void BackgroundSyncNetworkObserver::OnNetworkChanged( |
| 60 net::NetworkChangeNotifier::ConnectionType connection_type) { | 60 net::NetworkChangeNotifier::ConnectionType connection_type) { |
| 61 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 61 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 62 | 62 |
| 63 if (ignore_network_change_notifier_) | 63 if (ignore_network_change_notifier_) |
| 64 return; | 64 return; |
| 65 NotifyManagerIfNetworkChanged(connection_type); | 65 NotifyManagerIfNetworkChanged(connection_type); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void BackgroundSyncNetworkObserver::NotifyManagerIfNetworkChangedForTesting( |
| 69 net::NetworkChangeNotifier::ConnectionType connection_type) { |
| 70 NotifyManagerIfNetworkChanged(connection_type); |
| 71 } |
| 72 |
| 68 void BackgroundSyncNetworkObserver::NotifyManagerIfNetworkChanged( | 73 void BackgroundSyncNetworkObserver::NotifyManagerIfNetworkChanged( |
| 69 net::NetworkChangeNotifier::ConnectionType connection_type) { | 74 net::NetworkChangeNotifier::ConnectionType connection_type) { |
| 70 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 75 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 71 if (connection_type == connection_type_) | 76 if (connection_type == connection_type_) |
| 72 return; | 77 return; |
| 73 | 78 |
| 74 connection_type_ = connection_type; | 79 connection_type_ = connection_type; |
| 75 NotifyNetworkChanged(); | 80 NotifyNetworkChanged(); |
| 76 } | 81 } |
| 77 | 82 |
| 78 void BackgroundSyncNetworkObserver::NotifyNetworkChanged() { | 83 void BackgroundSyncNetworkObserver::NotifyNetworkChanged() { |
| 79 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 84 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 80 | 85 |
| 81 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | 86 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 82 network_changed_callback_); | 87 network_changed_callback_); |
| 83 } | 88 } |
| 84 | 89 |
| 85 } // namespace content | 90 } // namespace content |
| OLD | NEW |