OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_BASE_NETWORK_STATUS_DETECTOR_TASK_H_ |
| 6 #define CHROME_BROWSER_SYNC_NOTIFIER_BASE_NETWORK_STATUS_DETECTOR_TASK_H_ |
| 7 |
| 8 #include "chrome/browser/sync/notifier/base/time.h" |
| 9 #include "talk/base/sigslot.h" |
| 10 #include "talk/base/task.h" |
| 11 |
| 12 namespace notifier { |
| 13 class AsyncNetworkAlive; |
| 14 |
| 15 // Detects the current network state and any changes to that. |
| 16 class NetworkStatusDetectorTask : public talk_base::Task, |
| 17 public sigslot::has_slots<> { |
| 18 public: |
| 19 // Create an instance of (a subclass of) this class. |
| 20 static NetworkStatusDetectorTask* Create(talk_base::Task* parent); |
| 21 |
| 22 // Determines the current network state and |
| 23 // then calls SignalNetworkStateDetected. |
| 24 void DetectNetworkState(); |
| 25 |
| 26 // Fires whenever the network state is detected. |
| 27 // SignalNetworkStateDetected(was_alive, is_alive); |
| 28 sigslot::signal2<bool, bool> SignalNetworkStateDetected; |
| 29 |
| 30 protected: |
| 31 explicit NetworkStatusDetectorTask(talk_base::Task* parent) |
| 32 : talk_base::Task(parent), |
| 33 initial_detection_done_(false), |
| 34 is_alive_(false) { |
| 35 } |
| 36 |
| 37 virtual ~NetworkStatusDetectorTask() { } |
| 38 |
| 39 virtual int ProcessStart() = 0; |
| 40 |
| 41 // Stay around until aborted. |
| 42 virtual int ProcessResponse() { |
| 43 return STATE_BLOCKED; |
| 44 } |
| 45 |
| 46 void SetNetworkAlive(bool is_alive); |
| 47 |
| 48 private: |
| 49 bool initial_detection_done_; |
| 50 bool is_alive_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(NetworkStatusDetectorTask); |
| 53 }; |
| 54 } // namespace notifier |
| 55 #endif // CHROME_BROWSER_SYNC_NOTIFIER_BASE_NETWORK_STATUS_DETECTOR_TASK_H_ |
OLD | NEW |