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

Side by Side 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: Addressing review comments 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 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 : net::NetworkChangeNotifier::NetworkChangeObserver { 16 : public 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 // 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
25 // |network_state|. 25 // |network_state|.
26 bool NetworkSufficient(SyncNetworkState network_state); 26 bool NetworkSufficient(SyncNetworkState network_state);
27 27
28 private:
29 void NotifyNetworkChanged();
30
31 // NetworkChangeObserver overrides 28 // NetworkChangeObserver overrides
32 void OnNetworkChanged( 29 void OnNetworkChanged(
33 net::NetworkChangeNotifier::ConnectionType connection_type) override; 30 net::NetworkChangeNotifier::ConnectionType connection_type) override;
34 31
32 private:
33 void NotifyNetworkChanged();
34
35 net::NetworkChangeNotifier::ConnectionType connection_type_; 35 net::NetworkChangeNotifier::ConnectionType connection_type_;
36 36
37 // The callback to run when the network changes. 37 // The callback to run when the network changes.
38 base::Closure network_changed_callback_; 38 base::Closure network_changed_callback_;
39 39
40 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncNetworkObserver); 40 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncNetworkObserver);
41 }; 41 };
42 42
43 } // namespace content 43 } // namespace content
44 44
45 #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