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 #include "google_apis/gcm/engine/rmq_store.h" | 16 #include "google_apis/gcm/engine/rmq_store.h" |
16 | 17 |
17 using namespace google::protobuf::io; | 18 using namespace google::protobuf::io; |
18 | 19 |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 | 340 |
340 state_ = CONNECTING; | 341 state_ = CONNECTING; |
341 } | 342 } |
342 | 343 |
343 void MCSClient::SendHeartbeat() { | 344 void MCSClient::SendHeartbeat() { |
344 SendMessage(MCSMessage(kHeartbeatPingTag, mcs_proto::HeartbeatPing())); | 345 SendMessage(MCSMessage(kHeartbeatPingTag, mcs_proto::HeartbeatPing())); |
345 } | 346 } |
346 | 347 |
347 void MCSClient::OnRMQUpdateFinished(bool success) { | 348 void MCSClient::OnRMQUpdateFinished(bool success) { |
348 LOG_IF(ERROR, !success) << "RMQ Update failed!"; | 349 LOG_IF(ERROR, !success) << "RMQ Update failed!"; |
| 350 UMA_HISTOGRAM_BOOLEAN("GCM.StoreUpdateSucceeded", success); |
349 // TODO(zea): Rebuild the store from scratch in case of persistence failure? | 351 // TODO(zea): Rebuild the store from scratch in case of persistence failure? |
350 } | 352 } |
351 | 353 |
352 void MCSClient::MaybeSendMessage() { | 354 void MCSClient::MaybeSendMessage() { |
353 if (to_send_.empty()) | 355 if (to_send_.empty()) |
354 return; | 356 return; |
355 | 357 |
356 // If the connection has been reset, do nothing. On reconnection | 358 // If the connection has been reset, do nothing. On reconnection |
357 // MaybeSendMessage will be automatically invoked again. | 359 // MaybeSendMessage will be automatically invoked again. |
358 // TODO(zea): consider doing TTL expiration at connection reset time, rather | 360 // TODO(zea): consider doing TTL expiration at connection reset time, rather |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 | 712 |
711 MCSClient::PersistentId MCSClient::GetNextPersistentId() { | 713 MCSClient::PersistentId MCSClient::GetNextPersistentId() { |
712 return base::Uint64ToString(base::TimeTicks::Now().ToInternalValue()); | 714 return base::Uint64ToString(base::TimeTicks::Now().ToInternalValue()); |
713 } | 715 } |
714 | 716 |
715 void MCSClient::OnConnectionResetByHeartbeat() { | 717 void MCSClient::OnConnectionResetByHeartbeat() { |
716 connection_factory_->SignalConnectionReset(); | 718 connection_factory_->SignalConnectionReset(); |
717 } | 719 } |
718 | 720 |
719 } // namespace gcm | 721 } // namespace gcm |
OLD | NEW |