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

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: Fix compile + rebase 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
« no previous file with comments | « components/gcm_driver/gcm_client_impl.cc ('k') | google_apis/gcm/engine/connection_factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « components/gcm_driver/gcm_client_impl.cc ('k') | google_apis/gcm/engine/connection_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698