Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ | 5 #ifndef GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ |
| 6 #define GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ | 6 #define GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ |
| 7 | 7 |
| 8 #include "google_apis/gcm/engine/connection_factory.h" | 8 #include "google_apis/gcm/engine/connection_factory.h" |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 virtual ~ConnectionFactoryImpl(); | 41 virtual ~ConnectionFactoryImpl(); |
| 42 | 42 |
| 43 // ConnectionFactory implementation. | 43 // ConnectionFactory implementation. |
| 44 virtual void Initialize( | 44 virtual void Initialize( |
| 45 const BuildLoginRequestCallback& request_builder, | 45 const BuildLoginRequestCallback& request_builder, |
| 46 const ConnectionHandler::ProtoReceivedCallback& read_callback, | 46 const ConnectionHandler::ProtoReceivedCallback& read_callback, |
| 47 const ConnectionHandler::ProtoSentCallback& write_callback) OVERRIDE; | 47 const ConnectionHandler::ProtoSentCallback& write_callback) OVERRIDE; |
| 48 virtual ConnectionHandler* GetConnectionHandler() const OVERRIDE; | 48 virtual ConnectionHandler* GetConnectionHandler() const OVERRIDE; |
| 49 virtual void Connect() OVERRIDE; | 49 virtual void Connect() OVERRIDE; |
| 50 virtual bool IsEndpointReachable() const OVERRIDE; | 50 virtual bool IsEndpointReachable() const OVERRIDE; |
| 51 virtual std::string GetConnectionStateString() const OVERRIDE; | |
| 51 virtual base::TimeTicks NextRetryAttempt() const OVERRIDE; | 52 virtual base::TimeTicks NextRetryAttempt() const OVERRIDE; |
| 52 virtual void SignalConnectionReset(ConnectionResetReason reason) OVERRIDE; | 53 virtual void SignalConnectionReset(ConnectionResetReason reason) OVERRIDE; |
| 54 virtual void SetConnectionListener(ConnectionListener* listener) OVERRIDE; | |
| 53 | 55 |
| 54 // NetworkChangeNotifier observer implementations. | 56 // NetworkChangeNotifier observer implementations. |
| 55 virtual void OnConnectionTypeChanged( | 57 virtual void OnConnectionTypeChanged( |
| 56 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; | 58 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; |
| 57 virtual void OnIPAddressChanged() OVERRIDE; | 59 virtual void OnIPAddressChanged() OVERRIDE; |
| 58 | 60 |
| 59 // Returns the server to which the factory is currently connected, or if | 61 // Returns the server to which the factory is currently connected, or if |
| 60 // a connection is currently pending, the server to which the next connection | 62 // a connection is currently pending, the server to which the next connection |
| 61 // attempt will be made. | 63 // attempt will be made. |
| 62 GURL GetCurrentEndpoint() const; | 64 GURL GetCurrentEndpoint() const; |
| 63 | 65 |
| 66 // Returns the IPEndpoint to which the factory is currently connected. If no | |
| 67 // connection is active, returns an empty IPEndpoint. | |
| 68 net::IPEndPoint GetCurrentIP(); | |
|
fgorski
2014/06/05 00:03:11
Could we change the name to reflect that we mean t
Nicolas Zea
2014/06/05 20:17:27
Done.
| |
| 69 | |
| 64 protected: | 70 protected: |
| 65 // Implementation of Connect(..). If not in backoff, uses |login_request_| | 71 // Implementation of Connect(..). If not in backoff, uses |login_request_| |
| 66 // in attempting a connection/handshake. On connection/handshake failure, goes | 72 // in attempting a connection/handshake. On connection/handshake failure, goes |
| 67 // into backoff. | 73 // into backoff. |
| 68 // Virtual for testing. | 74 // Virtual for testing. |
| 69 virtual void ConnectImpl(); | 75 virtual void ConnectImpl(); |
| 70 | 76 |
| 71 // Helper method for initalizing the connection hander. | 77 // Helper method for initalizing the connection hander. |
| 72 // Virtual for testing. | 78 // Virtual for testing. |
| 73 virtual void InitHandler(); | 79 virtual void InitHandler(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 | 160 |
| 155 // The current connection handler, if one exists. | 161 // The current connection handler, if one exists. |
| 156 scoped_ptr<ConnectionHandler> connection_handler_; | 162 scoped_ptr<ConnectionHandler> connection_handler_; |
| 157 | 163 |
| 158 // Builder for generating new login requests. | 164 // Builder for generating new login requests. |
| 159 BuildLoginRequestCallback request_builder_; | 165 BuildLoginRequestCallback request_builder_; |
| 160 | 166 |
| 161 // Recorder that records GCM activities for debugging purpose. Not owned. | 167 // Recorder that records GCM activities for debugging purpose. Not owned. |
| 162 GCMStatsRecorder* recorder_; | 168 GCMStatsRecorder* recorder_; |
| 163 | 169 |
| 170 // Listener for connection change events. | |
| 171 ConnectionListener* listener_; | |
| 172 | |
| 164 base::WeakPtrFactory<ConnectionFactoryImpl> weak_ptr_factory_; | 173 base::WeakPtrFactory<ConnectionFactoryImpl> weak_ptr_factory_; |
| 165 | 174 |
| 166 DISALLOW_COPY_AND_ASSIGN(ConnectionFactoryImpl); | 175 DISALLOW_COPY_AND_ASSIGN(ConnectionFactoryImpl); |
| 167 }; | 176 }; |
| 168 | 177 |
| 169 } // namespace gcm | 178 } // namespace gcm |
| 170 | 179 |
| 171 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ | 180 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ |
| OLD | NEW |