Index: google_apis/gcm/engine/connection_factory.h |
diff --git a/google_apis/gcm/engine/connection_factory.h b/google_apis/gcm/engine/connection_factory.h |
index 393d6a9ca247d32030abd1baa9170f3913f9c8b4..1db02a6ca137f5f88c5725b9948aae6de8441233 100644 |
--- a/google_apis/gcm/engine/connection_factory.h |
+++ b/google_apis/gcm/engine/connection_factory.h |
@@ -5,10 +5,18 @@ |
#ifndef GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_H_ |
#define GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_H_ |
+#include <string> |
+ |
#include "base/time/time.h" |
#include "google_apis/gcm/base/gcm_export.h" |
#include "google_apis/gcm/engine/connection_handler.h" |
+class GURL; |
+ |
+namespace net { |
+class IPEndPoint; |
+} |
+ |
namespace mcs_proto { |
class LoginRequest; |
} |
@@ -36,6 +44,22 @@ class GCM_EXPORT ConnectionFactory { |
CONNECTION_RESET_COUNT, |
}; |
+ // Listener interface to be notified of endpoint connection events. |
+ class GCM_EXPORT ConnectionListener { |
+ public: |
+ ConnectionListener(); |
+ virtual ~ConnectionListener(); |
+ |
+ // Notifies the listener that GCM has performed a handshake with and is now |
+ // actively connected to |current_server|. |ip_endpoint| is the resolved |
+ // ip address/port through which the connection is being made. |
+ virtual void OnConnected(const GURL& current_server, |
+ const net::IPEndPoint& ip_endpoint) = 0; |
+ |
+ // Notifies the listener that the connection has been interrupted. |
+ virtual void OnDisconnected() = 0; |
+ }; |
+ |
ConnectionFactory(); |
virtual ~ConnectionFactory(); |
@@ -66,6 +90,9 @@ class GCM_EXPORT ConnectionFactory { |
// connection. |
virtual bool IsEndpointReachable() const = 0; |
+ // Returns a debug string describing the connection state. |
+ virtual std::string GetConnectionStateString() const = 0; |
+ |
// If in backoff, the time at which the next retry will be made. Otherwise, |
// a null time, indicating either no attempt to connect has been made or no |
// backoff is in progress. |
@@ -76,6 +103,11 @@ class GCM_EXPORT ConnectionFactory { |
// If the last connection was made within kConnectionResetWindowSecs, the old |
// backoff is restored, else a new backoff kicks off. |
virtual void SignalConnectionReset(ConnectionResetReason reason) = 0; |
+ |
+ // Sets the current connection listener. Only one listener is supported at a |
+ // time, and the listener must either outlive the connection factory or |
+ // call SetConnectionListener(NULL) upon destruction. |
+ virtual void SetConnectionListener(ConnectionListener* listener) = 0; |
}; |
} // namespace gcm |