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

Side by Side Diff: google_apis/gcm/engine/connection_factory_impl.h

Issue 2481873002: Added ClientEvent proto and structure for storing events in the factory. (Closed)
Patch Set: Rebase and address code review comments. Created 4 years 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 unified diff | Download patch
OLDNEW
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 <stddef.h> 10 #include <stddef.h>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "google_apis/gcm/engine/connection_event_tracker.h"
15 #include "google_apis/gcm/engine/connection_handler.h" 16 #include "google_apis/gcm/engine/connection_handler.h"
16 #include "google_apis/gcm/protocol/mcs.pb.h" 17 #include "google_apis/gcm/protocol/mcs.pb.h"
17 #include "net/base/backoff_entry.h" 18 #include "net/base/backoff_entry.h"
18 #include "net/base/network_change_notifier.h" 19 #include "net/base/network_change_notifier.h"
19 #include "net/log/net_log_with_source.h" 20 #include "net/log/net_log_with_source.h"
20 #include "net/proxy/proxy_info.h" 21 #include "net/proxy/proxy_info.h"
21 #include "net/proxy/proxy_service.h" 22 #include "net/proxy/proxy_service.h"
22 #include "net/socket/client_socket_handle.h" 23 #include "net/socket/client_socket_handle.h"
23 #include "url/gurl.h" 24 #include "url/gurl.h"
24 25
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 72
72 // Returns the server to which the factory is currently connected, or if 73 // Returns the server to which the factory is currently connected, or if
73 // a connection is currently pending, the server to which the next connection 74 // a connection is currently pending, the server to which the next connection
74 // attempt will be made. 75 // attempt will be made.
75 GURL GetCurrentEndpoint() const; 76 GURL GetCurrentEndpoint() const;
76 77
77 // Returns the IPEndpoint to which the factory is currently connected. If no 78 // Returns the IPEndpoint to which the factory is currently connected. If no
78 // connection is active, returns an empty IPEndpoint. 79 // connection is active, returns an empty IPEndpoint.
79 net::IPEndPoint GetPeerIP(); 80 net::IPEndPoint GetPeerIP();
80 81
82 ConnectionEventTracker* GetEventTrackerForTesting() {
Peter Beverloo 2016/12/05 16:29:35 nit: prefer making this private w/ a friends decla
harkness 2016/12/06 12:53:35 Done.
83 return &event_tracker_;
84 }
85
81 protected: 86 protected:
82 // Implementation of Connect(..). If not in backoff, uses |login_request_| 87 // Initiate the connection to the GCM server.
83 // in attempting a connection/handshake. On connection/handshake failure, goes
84 // into backoff.
85 // Virtual for testing. 88 // Virtual for testing.
86 virtual void ConnectImpl(); 89 virtual void StartConnection();
87 90
88 // Helper method for initalizing the connection hander. 91 // Helper method for initalizing the connection hander.
89 // Virtual for testing. 92 // Virtual for testing.
90 virtual void InitHandler(); 93 virtual void InitHandler();
91 94
92 // Helper method for creating a backoff entry. 95 // Helper method for creating a backoff entry.
93 // Virtual for testing. 96 // Virtual for testing.
94 virtual std::unique_ptr<net::BackoffEntry> CreateBackoffEntry( 97 virtual std::unique_ptr<net::BackoffEntry> CreateBackoffEntry(
95 const net::BackoffEntry::Policy* const policy); 98 const net::BackoffEntry::Policy* const policy);
96 99
(...skipping 13 matching lines...) Expand all
110 void OnConnectDone(int result); 113 void OnConnectDone(int result);
111 114
112 // ConnectionHandler callback for connection issues. 115 // ConnectionHandler callback for connection issues.
113 void ConnectionHandlerCallback(int result); 116 void ConnectionHandlerCallback(int result);
114 117
115 private: 118 private:
116 // Helper method for checking backoff and triggering a connection as 119 // Helper method for checking backoff and triggering a connection as
117 // necessary. 120 // necessary.
118 void ConnectWithBackoff(); 121 void ConnectWithBackoff();
119 122
123 // Implementation of Connect(..). If not in backoff, uses |login_request_|
Peter Beverloo 2016/12/05 16:29:35 nit: |login_request_| does not exist. Mind updatin
harkness 2016/12/06 12:53:35 Done.
124 // in attempting a connection/handshake. On connection/handshake failure, goes
125 // into backoff.
126 void ConnectImpl();
127
120 // Proxy resolution and connection functions. 128 // Proxy resolution and connection functions.
121 void OnProxyResolveDone(int status); 129 void OnProxyResolveDone(int status);
122 void OnProxyConnectDone(int status); 130 void OnProxyConnectDone(int status);
123 int ReconsiderProxyAfterError(int error); 131 int ReconsiderProxyAfterError(int error);
124 void ReportSuccessfulProxyConnection(); 132 void ReportSuccessfulProxyConnection();
125 133
126 // Closes the local socket if one is present, and resets connection handler. 134 // Closes the local socket if one is present, and resets connection handler.
127 void CloseSocket(); 135 void CloseSocket();
128 136
129 // Updates the GCM Network Session's HttpAuthCache with the HTTP Network 137 // Updates the GCM Network Session's HttpAuthCache with the HTTP Network
130 // Session's cache, if available. 138 // Session's cache, if available.
131 void RebuildNetworkSessionAuthCache(); 139 void RebuildNetworkSessionAuthCache();
132 140
141 // The tracker will maintain a list of all connection attempts with GCM,
142 // whether they suceeded, and their duration.
Peter Beverloo 2016/12/05 16:29:35 nit: s/suceeded/succeeded/
harkness 2016/12/06 12:53:35 Done.
143 ConnectionEventTracker event_tracker_;
144
133 // The MCS endpoints to make connections to, sorted in order of priority. 145 // The MCS endpoints to make connections to, sorted in order of priority.
134 const std::vector<GURL> mcs_endpoints_; 146 const std::vector<GURL> mcs_endpoints_;
135 // Index to the endpoint for which a connection should be attempted next. 147 // Index to the endpoint for which a connection should be attempted next.
136 size_t next_endpoint_; 148 size_t next_endpoint_;
137 // Index to the endpoint that was last successfully connected. 149 // Index to the endpoint that was last successfully connected.
138 size_t last_successful_endpoint_; 150 size_t last_successful_endpoint_;
139 151
140 // The backoff policy to use. 152 // The backoff policy to use.
141 const net::BackoffEntry::Policy backoff_policy_; 153 const net::BackoffEntry::Policy backoff_policy_;
142 154
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 ConnectionListener* listener_; 212 ConnectionListener* listener_;
201 213
202 base::WeakPtrFactory<ConnectionFactoryImpl> weak_ptr_factory_; 214 base::WeakPtrFactory<ConnectionFactoryImpl> weak_ptr_factory_;
203 215
204 DISALLOW_COPY_AND_ASSIGN(ConnectionFactoryImpl); 216 DISALLOW_COPY_AND_ASSIGN(ConnectionFactoryImpl);
205 }; 217 };
206 218
207 } // namespace gcm 219 } // namespace gcm
208 220
209 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_ 221 #endif // GOOGLE_APIS_GCM_ENGINE_CONNECTION_FACTORY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698