Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Unified Diff: content/browser/background_sync/background_sync_network_observer.cc

Issue 1294603003: [BackgroundSync] Trigger Background Sync events when Chrome is backgrounded on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't register observers with nonexistant Autodetector Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/background_sync/background_sync_network_observer.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « content/browser/background_sync/background_sync_network_observer.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698