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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_NETWORK_OBSERVER_H_
6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_NETWORK_OBSERVER_H_
9 #include "content/browser/background_sync/background_sync.pb.h"
10 #include "content/common/content_export.h"
11 #include "net/base/network_change_notifier.h"
15 class CONTENT_EXPORT BackgroundSyncNetworkObserver
16 : net::NetworkChangeNotifier::NetworkChangeObserver
{
18 // Creates a BackgroundSyncNetworkObserver. |network_changed_callback| is
19 // called when the network connection changes asynchronously via PostMessage.
20 BackgroundSyncNetworkObserver(const base::Closure
& network_changed_callback
);
22 ~BackgroundSyncNetworkObserver() override
;
24 // Returns true if the state of the network meets the needs of
26 bool NetworkSufficient(SyncNetworkState network_state
);
29 void NotifyNetworkChanged();
31 // NetworkChangeObserver overrides
32 void OnNetworkChanged(
33 net::NetworkChangeNotifier::ConnectionType connection_type
) override
;
35 net::NetworkChangeNotifier::ConnectionType connection_type_
;
37 // The callback to run when the network changes.
38 base::Closure network_changed_callback_
;
40 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncNetworkObserver
);
43 } // namespace content
45 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_NETWORK_OBSERVER_H_