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

Side by Side Diff: content/browser/background_sync/background_sync_network_observer.h

Issue 1376563003: Revert of [BackgroundSync] Trigger Background Sync events when Chrome is backgrounded on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
OLDNEW
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 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_NETWORK_OBSERVER_H_ 5 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_NETWORK_OBSERVER_H_
6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_NETWORK_OBSERVER_H_ 6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_NETWORK_OBSERVER_H_
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "content/browser/background_sync/background_sync.pb.h" 9 #include "content/browser/background_sync/background_sync.pb.h"
10 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
11 #include "net/base/network_change_notifier.h" 11 #include "net/base/network_change_notifier.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 class CONTENT_EXPORT BackgroundSyncNetworkObserver 15 class CONTENT_EXPORT BackgroundSyncNetworkObserver
16 : public net::NetworkChangeNotifier::NetworkChangeObserver { 16 : net::NetworkChangeNotifier::NetworkChangeObserver {
17 public: 17 public:
18 // Creates a BackgroundSyncNetworkObserver. |network_changed_callback| is 18 // Creates a BackgroundSyncNetworkObserver. |network_changed_callback| is
19 // called when the network connection changes asynchronously via PostMessage. 19 // called when the network connection changes asynchronously via PostMessage.
20 BackgroundSyncNetworkObserver(const base::Closure& network_changed_callback); 20 BackgroundSyncNetworkObserver(const base::Closure& network_changed_callback);
21 21
22 ~BackgroundSyncNetworkObserver() override; 22 ~BackgroundSyncNetworkObserver() override;
23 23
24 // Enable or disable notifications coming from the NetworkChangeNotifier. (For
25 // preventing flakes in tests)
26 static void SetIgnoreNetworkChangeNotifierForTests(bool ignore);
27
28 // Returns true if the state of the network meets the needs of 24 // Returns true if the state of the network meets the needs of
29 // |network_state|. 25 // |network_state|.
30 bool NetworkSufficient(SyncNetworkState network_state); 26 bool NetworkSufficient(SyncNetworkState network_state);
31 27
28 private:
29 void NotifyNetworkChanged();
30
32 // NetworkChangeObserver overrides 31 // NetworkChangeObserver overrides
33 void OnNetworkChanged( 32 void OnNetworkChanged(
34 net::NetworkChangeNotifier::ConnectionType connection_type) override; 33 net::NetworkChangeNotifier::ConnectionType connection_type) override;
35 34
36 private:
37 friend class BackgroundSyncBrowserTest;
38 friend class BackgroundSyncManagerTest;
39
40 // Calls NotifyNetworkChanged if the connection type has changed.
41 void NotifyManagerIfNetworkChanged(
42 net::NetworkChangeNotifier::ConnectionType connection_type);
43
44 void NotifyNetworkChanged();
45
46 net::NetworkChangeNotifier::ConnectionType connection_type_; 35 net::NetworkChangeNotifier::ConnectionType connection_type_;
47 36
48 // The callback to run when the network changes. 37 // The callback to run when the network changes.
49 base::Closure network_changed_callback_; 38 base::Closure network_changed_callback_;
50 39
51 // Set true to ignore notifications coming from the NetworkChangeNotifier
52 // (to prevent flakes in tests).
53 static bool ignore_network_change_notifier_;
54
55 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncNetworkObserver); 40 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncNetworkObserver);
56 }; 41 };
57 42
58 } // namespace content 43 } // namespace content
59 44
60 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_NETWORK_OBSERVER_H_ 45 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_NETWORK_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698