X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fgoogle_apis%2Fgcm%2Fengine%2Fconnection_factory_impl.h;h=7326d7969e8b7fff61c8325224fe609dfcc040a2;hb=ff3e2503a20db9193d323c1d19c38c68004dec4a;hp=3827b1c8ccd308a41e6fdb409bc1dcb493020940;hpb=7338fba38ba696536d1cc9d389afd716a6ab2fe6;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/google_apis/gcm/engine/connection_factory_impl.h b/src/google_apis/gcm/engine/connection_factory_impl.h index 3827b1c..7326d79 100644 --- a/src/google_apis/gcm/engine/connection_factory_impl.h +++ b/src/google_apis/gcm/engine/connection_factory_impl.h @@ -8,6 +8,7 @@ #include "google_apis/gcm/engine/connection_factory.h" #include "base/memory/weak_ptr.h" +#include "base/time/time.h" #include "google_apis/gcm/protocol/mcs.pb.h" #include "net/base/backoff_entry.h" #include "net/base/network_change_notifier.h" @@ -30,6 +31,7 @@ class GCM_EXPORT ConnectionFactoryImpl : public: ConnectionFactoryImpl( const GURL& mcs_endpoint, + const net::BackoffEntry::Policy& backoff_policy, scoped_refptr network_session, net::NetLog* net_log); virtual ~ConnectionFactoryImpl(); @@ -43,7 +45,7 @@ class GCM_EXPORT ConnectionFactoryImpl : virtual void Connect() OVERRIDE; virtual bool IsEndpointReachable() const OVERRIDE; virtual base::TimeTicks NextRetryAttempt() const OVERRIDE; - virtual void SignalConnectionReset() OVERRIDE; + virtual void SignalConnectionReset(ConnectionResetReason reason) OVERRIDE; // NetworkChangeNotifier observer implementations. virtual void OnConnectionTypeChanged( @@ -80,6 +82,9 @@ class GCM_EXPORT ConnectionFactoryImpl : // The MCS endpoint to make connections to. const GURL mcs_endpoint_; + // The backoff policy to use. + const net::BackoffEntry::Policy backoff_policy_; + // ---- net:: components for establishing connections. ---- // Network session for creating new connections. const scoped_refptr network_session_; @@ -87,17 +92,26 @@ class GCM_EXPORT ConnectionFactoryImpl : net::NetLog* const net_log_; // The handle to the socket for the current connection, if one exists. net::ClientSocketHandle socket_handle_; - // Connection attempt backoff policy. + // Current backoff entry. scoped_ptr backoff_entry_; - // Backoff policy from previous backoff attempt. + // Backoff entry from previous connection attempt. Updated on each login + // completion. scoped_ptr previous_backoff_; - base::TimeTicks backoff_reset_time_; // Whether a connection attempt is currently in progress or we're in backoff // waiting until the next connection attempt. |!connecting_| denotes // steady state with an active connection. bool connecting_; + // Whether login successfully completed after the connection was established. + // If a connection reset happens while attempting to log in, the current + // backoff entry is reused (after incrementing with a new failure). + bool logging_in_; + + // The time of the last login completion. Used for calculating whether to + // restore a previous backoff entry and for measuring uptime. + base::TimeTicks last_login_time_; + // The current connection handler, if one exists. scoped_ptr connection_handler_;