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> |
| 8 #include <utility> |
| 9 |
7 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
8 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
11 #include "base/values.h" | 14 #include "base/values.h" |
12 #include "components/gcm_driver/gcm_activity.h" | 15 #include "components/gcm_driver/gcm_activity.h" |
13 #include "components/gcm_driver/gcm_internals_constants.h" | 16 #include "components/gcm_driver/gcm_internals_constants.h" |
14 #include "components/gcm_driver/gcm_profile_service.h" | 17 #include "components/gcm_driver/gcm_profile_service.h" |
15 | 18 |
16 namespace gcm_driver { | 19 namespace gcm_driver { |
17 | 20 |
18 namespace { | 21 namespace { |
19 | 22 |
20 void SetCheckinInfo(const std::vector<gcm::CheckinActivity>& checkins, | 23 void SetCheckinInfo(const std::vector<gcm::CheckinActivity>& checkins, |
21 base::ListValue* checkin_info) { | 24 base::ListValue* checkin_info) { |
22 for (const gcm::CheckinActivity& checkin : checkins) { | 25 for (const gcm::CheckinActivity& checkin : checkins) { |
23 base::ListValue* row = new base::ListValue(); | 26 std::unique_ptr<base::ListValue> row(new base::ListValue()); |
24 checkin_info->Append(row); | |
25 | |
26 row->AppendDouble(checkin.time.ToJsTime()); | 27 row->AppendDouble(checkin.time.ToJsTime()); |
27 row->AppendString(checkin.event); | 28 row->AppendString(checkin.event); |
28 row->AppendString(checkin.details); | 29 row->AppendString(checkin.details); |
| 30 checkin_info->Append(std::move(row)); |
29 } | 31 } |
30 } | 32 } |
31 | 33 |
32 void SetConnectionInfo(const std::vector<gcm::ConnectionActivity>& connections, | 34 void SetConnectionInfo(const std::vector<gcm::ConnectionActivity>& connections, |
33 base::ListValue* connection_info) { | 35 base::ListValue* connection_info) { |
34 for (const gcm::ConnectionActivity& connection : connections) { | 36 for (const gcm::ConnectionActivity& connection : connections) { |
35 base::ListValue* row = new base::ListValue(); | 37 std::unique_ptr<base::ListValue> row(new base::ListValue()); |
36 connection_info->Append(row); | |
37 | |
38 row->AppendDouble(connection.time.ToJsTime()); | 38 row->AppendDouble(connection.time.ToJsTime()); |
39 row->AppendString(connection.event); | 39 row->AppendString(connection.event); |
40 row->AppendString(connection.details); | 40 row->AppendString(connection.details); |
| 41 connection_info->Append(std::move(row)); |
41 } | 42 } |
42 } | 43 } |
43 | 44 |
44 void SetRegistrationInfo( | 45 void SetRegistrationInfo( |
45 const std::vector<gcm::RegistrationActivity>& registrations, | 46 const std::vector<gcm::RegistrationActivity>& registrations, |
46 base::ListValue* registration_info) { | 47 base::ListValue* registration_info) { |
47 for (const gcm::RegistrationActivity& registration : registrations) { | 48 for (const gcm::RegistrationActivity& registration : registrations) { |
48 base::ListValue* row = new base::ListValue(); | 49 std::unique_ptr<base::ListValue> row(new base::ListValue()); |
49 registration_info->Append(row); | |
50 | |
51 row->AppendDouble(registration.time.ToJsTime()); | 50 row->AppendDouble(registration.time.ToJsTime()); |
52 row->AppendString(registration.app_id); | 51 row->AppendString(registration.app_id); |
53 row->AppendString(registration.source); | 52 row->AppendString(registration.source); |
54 row->AppendString(registration.event); | 53 row->AppendString(registration.event); |
55 row->AppendString(registration.details); | 54 row->AppendString(registration.details); |
| 55 registration_info->Append(std::move(row)); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 void SetReceivingInfo(const std::vector<gcm::ReceivingActivity>& receives, | 59 void SetReceivingInfo(const std::vector<gcm::ReceivingActivity>& receives, |
60 base::ListValue* receive_info) { | 60 base::ListValue* receive_info) { |
61 for (const gcm::ReceivingActivity& receive : receives) { | 61 for (const gcm::ReceivingActivity& receive : receives) { |
62 base::ListValue* row = new base::ListValue(); | 62 std::unique_ptr<base::ListValue> row(new base::ListValue()); |
63 receive_info->Append(row); | |
64 | |
65 row->AppendDouble(receive.time.ToJsTime()); | 63 row->AppendDouble(receive.time.ToJsTime()); |
66 row->AppendString(receive.app_id); | 64 row->AppendString(receive.app_id); |
67 row->AppendString(receive.from); | 65 row->AppendString(receive.from); |
68 row->AppendString(base::IntToString(receive.message_byte_size)); | 66 row->AppendString(base::IntToString(receive.message_byte_size)); |
69 row->AppendString(receive.event); | 67 row->AppendString(receive.event); |
70 row->AppendString(receive.details); | 68 row->AppendString(receive.details); |
| 69 receive_info->Append(std::move(row)); |
71 } | 70 } |
72 } | 71 } |
73 | 72 |
74 void SetSendingInfo(const std::vector<gcm::SendingActivity>& sends, | 73 void SetSendingInfo(const std::vector<gcm::SendingActivity>& sends, |
75 base::ListValue* send_info) { | 74 base::ListValue* send_info) { |
76 for (const gcm::SendingActivity& send : sends) { | 75 for (const gcm::SendingActivity& send : sends) { |
77 base::ListValue* row = new base::ListValue(); | 76 std::unique_ptr<base::ListValue> row(new base::ListValue()); |
78 send_info->Append(row); | |
79 | |
80 row->AppendDouble(send.time.ToJsTime()); | 77 row->AppendDouble(send.time.ToJsTime()); |
81 row->AppendString(send.app_id); | 78 row->AppendString(send.app_id); |
82 row->AppendString(send.receiver_id); | 79 row->AppendString(send.receiver_id); |
83 row->AppendString(send.message_id); | 80 row->AppendString(send.message_id); |
84 row->AppendString(send.event); | 81 row->AppendString(send.event); |
85 row->AppendString(send.details); | 82 row->AppendString(send.details); |
| 83 send_info->Append(std::move(row)); |
86 } | 84 } |
87 } | 85 } |
88 | 86 |
89 void SetDecryptionFailureInfo( | 87 void SetDecryptionFailureInfo( |
90 const std::vector<gcm::DecryptionFailureActivity>& failures, | 88 const std::vector<gcm::DecryptionFailureActivity>& failures, |
91 base::ListValue* failure_info) { | 89 base::ListValue* failure_info) { |
92 for (const gcm::DecryptionFailureActivity& failure : failures) { | 90 for (const gcm::DecryptionFailureActivity& failure : failures) { |
93 base::ListValue* row = new base::ListValue(); | 91 std::unique_ptr<base::ListValue> row(new base::ListValue()); |
94 failure_info->Append(row); | |
95 | |
96 row->AppendDouble(failure.time.ToJsTime()); | 92 row->AppendDouble(failure.time.ToJsTime()); |
97 row->AppendString(failure.app_id); | 93 row->AppendString(failure.app_id); |
98 row->AppendString(failure.details); | 94 row->AppendString(failure.details); |
| 95 failure_info->Append(std::move(row)); |
99 } | 96 } |
100 } | 97 } |
101 | 98 |
102 } // namespace | 99 } // namespace |
103 | 100 |
104 void SetGCMInternalsInfo(const gcm::GCMClient::GCMStatistics* stats, | 101 void SetGCMInternalsInfo(const gcm::GCMClient::GCMStatistics* stats, |
105 gcm::GCMProfileService* profile_service, | 102 gcm::GCMProfileService* profile_service, |
106 PrefService* prefs, | 103 PrefService* prefs, |
107 base::DictionaryValue* results) { | 104 base::DictionaryValue* results) { |
108 base::DictionaryValue* device_info = new base::DictionaryValue(); | 105 base::DictionaryValue* device_info = new base::DictionaryValue(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 base::ListValue* failure_info = new base::ListValue(); | 159 base::ListValue* failure_info = new base::ListValue(); |
163 results->Set(kDecryptionFailureInfo, failure_info); | 160 results->Set(kDecryptionFailureInfo, failure_info); |
164 SetDecryptionFailureInfo( | 161 SetDecryptionFailureInfo( |
165 stats->recorded_activities.decryption_failure_activities, | 162 stats->recorded_activities.decryption_failure_activities, |
166 failure_info); | 163 failure_info); |
167 } | 164 } |
168 } | 165 } |
169 } | 166 } |
170 | 167 |
171 } // namespace gcm_driver | 168 } // namespace gcm_driver |
OLD | NEW |