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 #include "google_apis/gcm/engine/connection_factory_impl.h" | 5 #include "google_apis/gcm/engine/connection_factory_impl.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/metrics/histogram.h" |
| 9 #include "base/metrics/sparse_histogram.h" |
8 #include "google_apis/gcm/engine/connection_handler_impl.h" | 10 #include "google_apis/gcm/engine/connection_handler_impl.h" |
9 #include "google_apis/gcm/protocol/mcs.pb.h" | 11 #include "google_apis/gcm/protocol/mcs.pb.h" |
10 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
11 #include "net/http/http_network_session.h" | 13 #include "net/http/http_network_session.h" |
12 #include "net/http/http_request_headers.h" | 14 #include "net/http/http_request_headers.h" |
13 #include "net/proxy/proxy_info.h" | 15 #include "net/proxy/proxy_info.h" |
14 #include "net/socket/client_socket_handle.h" | 16 #include "net/socket/client_socket_handle.h" |
15 #include "net/socket/client_socket_pool_manager.h" | 17 #include "net/socket/client_socket_pool_manager.h" |
16 #include "net/ssl/ssl_config_service.h" | 18 #include "net/ssl/ssl_config_service.h" |
17 | 19 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 206 |
205 scoped_ptr<net::BackoffEntry> ConnectionFactoryImpl::CreateBackoffEntry( | 207 scoped_ptr<net::BackoffEntry> ConnectionFactoryImpl::CreateBackoffEntry( |
206 const net::BackoffEntry::Policy* const policy) { | 208 const net::BackoffEntry::Policy* const policy) { |
207 return scoped_ptr<net::BackoffEntry>(new net::BackoffEntry(policy)); | 209 return scoped_ptr<net::BackoffEntry>(new net::BackoffEntry(policy)); |
208 } | 210 } |
209 | 211 |
210 void ConnectionFactoryImpl::OnConnectDone(int result) { | 212 void ConnectionFactoryImpl::OnConnectDone(int result) { |
211 if (result != net::OK) { | 213 if (result != net::OK) { |
212 LOG(ERROR) << "Failed to connect to MCS endpoint with error " << result; | 214 LOG(ERROR) << "Failed to connect to MCS endpoint with error " << result; |
213 backoff_entry_->InformOfRequest(false); | 215 backoff_entry_->InformOfRequest(false); |
| 216 UMA_HISTOGRAM_SPARSE_SLOWLY("GCM.ConnectionFailureErrorCode", result); |
214 Connect(); | 217 Connect(); |
215 return; | 218 return; |
216 } | 219 } |
217 | 220 |
218 DVLOG(1) << "MCS endpoint socket connection success, starting handshake."; | 221 DVLOG(1) << "MCS endpoint socket connection success, starting handshake."; |
219 InitHandler(); | 222 InitHandler(); |
220 } | 223 } |
221 | 224 |
222 void ConnectionFactoryImpl::ConnectionHandlerCallback(int result) { | 225 void ConnectionFactoryImpl::ConnectionHandlerCallback(int result) { |
223 if (result == net::OK) { | 226 if (result == net::OK) { |
224 // Handshake succeeded, reset the backoff. | 227 // Handshake succeeded, reset the backoff. |
225 connecting_ = false; | 228 connecting_ = false; |
226 backoff_reset_time_ = base::TimeTicks::Now(); | 229 backoff_reset_time_ = base::TimeTicks::Now(); |
227 previous_backoff_.swap(backoff_entry_); | 230 previous_backoff_.swap(backoff_entry_); |
228 backoff_entry_->Reset(); | 231 backoff_entry_->Reset(); |
229 return; | 232 return; |
230 } | 233 } |
| 234 |
| 235 if (!connecting_) |
| 236 UMA_HISTOGRAM_SPARSE_SLOWLY("GCM.ConnectionDisconnectErrorCode", result); |
| 237 |
231 // TODO(zea): Consider how to handle errors that may require some sort of | 238 // TODO(zea): Consider how to handle errors that may require some sort of |
232 // user intervention (login page, etc.). | 239 // user intervention (login page, etc.). |
233 LOG(ERROR) << "Connection reset with error " << result; | 240 LOG(ERROR) << "Connection reset with error " << result; |
234 backoff_entry_->InformOfRequest(false); | 241 backoff_entry_->InformOfRequest(false); |
235 Connect(); | 242 Connect(); |
236 } | 243 } |
237 | 244 |
238 } // namespace gcm | 245 } // namespace gcm |
OLD | NEW |