OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/mcs_client.h" | 5 #include "google_apis/gcm/engine/mcs_client.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/metrics/histogram.h" |
9 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
10 #include "base/time/clock.h" | 11 #include "base/time/clock.h" |
11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
12 #include "google_apis/gcm/base/mcs_util.h" | 13 #include "google_apis/gcm/base/mcs_util.h" |
13 #include "google_apis/gcm/base/socket_stream.h" | 14 #include "google_apis/gcm/base/socket_stream.h" |
14 #include "google_apis/gcm/engine/connection_factory.h" | 15 #include "google_apis/gcm/engine/connection_factory.h" |
15 | 16 |
16 using namespace google::protobuf::io; | 17 using namespace google::protobuf::io; |
17 | 18 |
18 namespace gcm { | 19 namespace gcm { |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 | 339 |
339 state_ = CONNECTING; | 340 state_ = CONNECTING; |
340 } | 341 } |
341 | 342 |
342 void MCSClient::SendHeartbeat() { | 343 void MCSClient::SendHeartbeat() { |
343 SendMessage(MCSMessage(kHeartbeatPingTag, mcs_proto::HeartbeatPing())); | 344 SendMessage(MCSMessage(kHeartbeatPingTag, mcs_proto::HeartbeatPing())); |
344 } | 345 } |
345 | 346 |
346 void MCSClient::OnGCMUpdateFinished(bool success) { | 347 void MCSClient::OnGCMUpdateFinished(bool success) { |
347 LOG_IF(ERROR, !success) << "GCM Update failed!"; | 348 LOG_IF(ERROR, !success) << "GCM Update failed!"; |
| 349 UMA_HISTOGRAM_BOOLEAN("GCM.StoreUpdateSucceeded", success); |
348 // TODO(zea): Rebuild the store from scratch in case of persistence failure? | 350 // TODO(zea): Rebuild the store from scratch in case of persistence failure? |
349 } | 351 } |
350 | 352 |
351 void MCSClient::MaybeSendMessage() { | 353 void MCSClient::MaybeSendMessage() { |
352 if (to_send_.empty()) | 354 if (to_send_.empty()) |
353 return; | 355 return; |
354 | 356 |
355 // If the connection has been reset, do nothing. On reconnection | 357 // If the connection has been reset, do nothing. On reconnection |
356 // MaybeSendMessage will be automatically invoked again. | 358 // MaybeSendMessage will be automatically invoked again. |
357 // TODO(zea): consider doing TTL expiration at connection reset time, rather | 359 // TODO(zea): consider doing TTL expiration at connection reset time, rather |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 | 714 |
713 MCSClient::PersistentId MCSClient::GetNextPersistentId() { | 715 MCSClient::PersistentId MCSClient::GetNextPersistentId() { |
714 return base::Uint64ToString(base::TimeTicks::Now().ToInternalValue()); | 716 return base::Uint64ToString(base::TimeTicks::Now().ToInternalValue()); |
715 } | 717 } |
716 | 718 |
717 void MCSClient::OnConnectionResetByHeartbeat() { | 719 void MCSClient::OnConnectionResetByHeartbeat() { |
718 connection_factory_->SignalConnectionReset(); | 720 connection_factory_->SignalConnectionReset(); |
719 } | 721 } |
720 | 722 |
721 } // namespace gcm | 723 } // namespace gcm |
OLD | NEW |