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

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

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
Index: content/browser/background_sync/background_sync_network_observer.h
diff --git a/content/browser/background_sync/background_sync_network_observer.h b/content/browser/background_sync/background_sync_network_observer.h
index 7c81f738a92c01b799441e14a3366d71d4741f28..4d47cc6a6c3970396a3195a31a271ab3df2122f4 100644
--- a/content/browser/background_sync/background_sync_network_observer.h
+++ b/content/browser/background_sync/background_sync_network_observer.h
@@ -13,7 +13,7 @@
namespace content {
class CONTENT_EXPORT BackgroundSyncNetworkObserver
- : net::NetworkChangeNotifier::NetworkChangeObserver {
+ : public net::NetworkChangeNotifier::NetworkChangeObserver {
public:
// Creates a BackgroundSyncNetworkObserver. |network_changed_callback| is
// called when the network connection changes asynchronously via PostMessage.
@@ -21,22 +21,37 @@ class CONTENT_EXPORT BackgroundSyncNetworkObserver
~BackgroundSyncNetworkObserver() override;
+ // Enable or disable notifications coming from the NetworkChangeNotifier. (For
+ // preventing flakes in tests)
+ static void SetIgnoreNetworkChangeNotifierForTests(bool ignore);
+
// Returns true if the state of the network meets the needs of
// |network_state|.
bool NetworkSufficient(SyncNetworkState network_state);
- private:
- void NotifyNetworkChanged();
-
// NetworkChangeObserver overrides
void OnNetworkChanged(
net::NetworkChangeNotifier::ConnectionType connection_type) override;
+ private:
+ friend class BackgroundSyncBrowserTest;
+ friend class BackgroundSyncManagerTest;
+
+ // Calls NotifyNetworkChanged if the connection type has changed.
+ void NotifyManagerIfNetworkChanged(
+ net::NetworkChangeNotifier::ConnectionType connection_type);
+
+ void NotifyNetworkChanged();
+
net::NetworkChangeNotifier::ConnectionType connection_type_;
// The callback to run when the network changes.
base::Closure network_changed_callback_;
+ // Set true to ignore notifications coming from the NetworkChangeNotifier
+ // (to prevent flakes in tests).
+ static bool ignore_network_change_notifier_;
+
DISALLOW_COPY_AND_ASSIGN(BackgroundSyncNetworkObserver);
};

Powered by Google App Engine
This is Rietveld 408576698