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

Unified Diff: google_apis/gcm/engine/connection_factory.h

Issue 317723004: [GCM] Add ConnectionListener support, and hook up to debug page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
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..1888c19f8b59e18f22dfbd4ece906920db916995 100644
--- a/google_apis/gcm/engine/connection_factory.h
+++ b/google_apis/gcm/engine/connection_factory.h
@@ -9,6 +9,12 @@
#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 +42,22 @@ class GCM_EXPORT ConnectionFactory {
CONNECTION_RESET_COUNT,
};
+ // Listener interface to be notified of endpoint connection events.
+ class ConnectionListener {
+ public:
+ ConnectionListener();
+ virtual ~ConnectionListener();
+
+ // Notifies the listener that GCM has performed a handshake with and is now
+ // actively connected to |current_endpoint|. |socket_ip| is the resolved
+ // ip address/port through which the connection is being made.
+ virtual void OnConnected(const GURL& current_endpoint,
+ const net::IPEndPoint& socket_ip) = 0;
+
+ // Notifies the listener that the connection has been interrupted.
+ virtual void OnDisconnected() = 0;
+ };
+
ConnectionFactory();
virtual ~ConnectionFactory();
@@ -66,6 +88,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 +101,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
« no previous file with comments | « no previous file | google_apis/gcm/engine/connection_factory.cc » ('j') | google_apis/gcm/engine/connection_factory_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698