Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/gcm_driver/gcm_internals_helper.h" | 5 #include "components/gcm_driver/gcm_internals_helper.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| 11 #include "base/i18n/time_formatting.h" | |
| 11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/strings/utf_string_conversions.h" | |
| 14 #include "base/values.h" | 16 #include "base/values.h" |
| 15 #include "components/gcm_driver/gcm_activity.h" | 17 #include "components/gcm_driver/gcm_activity.h" |
| 16 #include "components/gcm_driver/gcm_internals_constants.h" | 18 #include "components/gcm_driver/gcm_internals_constants.h" |
| 17 #include "components/gcm_driver/gcm_profile_service.h" | 19 #include "components/gcm_driver/gcm_profile_service.h" |
| 18 | 20 |
| 19 namespace gcm_driver { | 21 namespace gcm_driver { |
| 20 | 22 |
| 21 namespace { | 23 namespace { |
| 22 | 24 |
| 23 void SetCheckinInfo(const std::vector<gcm::CheckinActivity>& checkins, | 25 void SetCheckinInfo(const std::vector<gcm::CheckinActivity>& checkins, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 if (stats) { | 113 if (stats) { |
| 112 results->SetBoolean(kIsRecording, stats->is_recording); | 114 results->SetBoolean(kIsRecording, stats->is_recording); |
| 113 device_info->SetBoolean(kGcmClientCreated, stats->gcm_client_created); | 115 device_info->SetBoolean(kGcmClientCreated, stats->gcm_client_created); |
| 114 device_info->SetString(kGcmClientState, stats->gcm_client_state); | 116 device_info->SetString(kGcmClientState, stats->gcm_client_state); |
| 115 device_info->SetBoolean(kConnectionClientCreated, | 117 device_info->SetBoolean(kConnectionClientCreated, |
| 116 stats->connection_client_created); | 118 stats->connection_client_created); |
| 117 device_info->SetString(kRegisteredAppIds, | 119 device_info->SetString(kRegisteredAppIds, |
| 118 base::JoinString(stats->registered_app_ids, ",")); | 120 base::JoinString(stats->registered_app_ids, ",")); |
| 119 if (stats->connection_client_created) | 121 if (stats->connection_client_created) |
| 120 device_info->SetString(kConnectionState, stats->connection_state); | 122 device_info->SetString(kConnectionState, stats->connection_state); |
| 123 device_info->SetString( | |
| 124 kLastCheckin, base::UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime( | |
| 125 stats->last_checkin))); | |
|
Peter Beverloo
2016/10/28 15:52:30
last_checkin can be NULL here when the CheckinRequ
Nicolas Zea
2016/11/01 00:18:16
Done.
| |
| 126 if (!stats->next_checkin.is_null()) { | |
| 127 device_info->SetString( | |
| 128 kNextCheckin, base::UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime( | |
| 129 stats->next_checkin))); | |
| 130 } | |
| 121 if (stats->android_id > 0) { | 131 if (stats->android_id > 0) { |
| 122 device_info->SetString( | 132 device_info->SetString( |
| 123 kAndroidId, base::StringPrintf("0x%" PRIx64, stats->android_id)); | 133 kAndroidId, base::StringPrintf("0x%" PRIx64, stats->android_id)); |
| 124 } | 134 } |
| 125 device_info->SetInteger(kSendQueueSize, stats->send_queue_size); | 135 device_info->SetInteger(kSendQueueSize, stats->send_queue_size); |
| 126 device_info->SetInteger(kResendQueueSize, stats->resend_queue_size); | 136 device_info->SetInteger(kResendQueueSize, stats->resend_queue_size); |
| 127 | 137 |
| 128 if (stats->recorded_activities.checkin_activities.size() > 0) { | 138 if (stats->recorded_activities.checkin_activities.size() > 0) { |
| 129 base::ListValue* checkin_info = new base::ListValue(); | 139 base::ListValue* checkin_info = new base::ListValue(); |
| 130 results->Set(kCheckinInfo, checkin_info); | 140 results->Set(kCheckinInfo, checkin_info); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 159 base::ListValue* failure_info = new base::ListValue(); | 169 base::ListValue* failure_info = new base::ListValue(); |
| 160 results->Set(kDecryptionFailureInfo, failure_info); | 170 results->Set(kDecryptionFailureInfo, failure_info); |
| 161 SetDecryptionFailureInfo( | 171 SetDecryptionFailureInfo( |
| 162 stats->recorded_activities.decryption_failure_activities, | 172 stats->recorded_activities.decryption_failure_activities, |
| 163 failure_info); | 173 failure_info); |
| 164 } | 174 } |
| 165 } | 175 } |
| 166 } | 176 } |
| 167 | 177 |
| 168 } // namespace gcm_driver | 178 } // namespace gcm_driver |
| OLD | NEW |