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

Side by Side Diff: chrome/browser/sync/notifier/communicator/auto_reconnect.h

Issue 194065: Initial commit of sync engine code to browser/sync.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fixes to gtest include path, reverted syncapi. Created 11 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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_COMMUNICATOR_AUTO_RECONNECT_H_
6 #define CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_AUTO_RECONNECT_H_
7 #include <string>
8
9 #include "chrome/browser/sync/notifier/base/time.h"
10 #include "chrome/browser/sync/notifier/communicator/login.h"
11 #include "talk/base/sigslot.h"
12
13 namespace talk_base {
14 class Task;
15 }
16
17 namespace notifier {
18 class NetworkStatusDetectorTask;
19 class Timer;
20
21 class AutoReconnect : public sigslot::has_slots<> {
22 public:
23 AutoReconnect(talk_base::Task* parent,
24 NetworkStatusDetectorTask* network_status);
25 void StartReconnectTimer();
26 void StopReconnectTimer();
27 void OnClientStateChange(Login::ConnectionState state);
28
29 // Callback when power is suspended
30 void OnPowerSuspend(bool suspended);
31
32 void set_idle(bool idle) {
33 is_idle_ = idle;
34 }
35
36 // Returns true if the auto-retry is to be done (pending a countdown)
37 bool is_retrying() const {
38 return reconnect_timer_ != NULL;
39 }
40
41 int seconds_until() const;
42 sigslot::signal0<> SignalTimerStartStop;
43 sigslot::signal0<> SignalStartConnection;
44 private:
45 void StartReconnectTimerWithInterval(time64 interval_ns);
46 void DoReconnect();
47 void ResetState();
48 void SetupReconnectInterval();
49 void StopDelayedResetTimer();
50
51 void OnNetworkStateDetected(bool was_alive, bool is_alive);
52
53 time64 reconnect_interval_ns_;
54 Timer* reconnect_timer_;
55 Timer* delayed_reset_timer_;
56 talk_base::Task* parent_;
57
58 bool is_idle_;
59 DISALLOW_COPY_AND_ASSIGN(AutoReconnect);
60 };
61
62 // Wait 2 seconds until after we actually connect to
63 // reset reconnect related items.
64 //
65 // The reason for this delay is to avoid the situation in which buzz
66 // is trying to block the client due to abuse and the client responses
67 // by going into rapid reconnect mode, which makes the problem more severe.
68 extern const int kResetReconnectInfoDelaySec;
69
70 } // namespace notifier
idana 2009/09/10 05:44:37 Add extra blank space.
71 #endif // CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_AUTO_RECONNECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698