OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/sync/driver/about_sync_util.h" | 5 #include "components/sync/driver/about_sync_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "components/signin/core/browser/signin_manager_base.h" | 16 #include "components/signin/core/browser/signin_manager_base.h" |
17 #include "components/sync/driver/sync_service.h" | 17 #include "components/sync/driver/sync_service.h" |
18 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" | 18 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" |
19 #include "components/sync/engine/sync_status.h" | 19 #include "components/sync/engine/sync_status.h" |
20 #include "components/sync/engine/sync_string_conversions.h" | 20 #include "components/sync/engine/sync_string_conversions.h" |
21 #include "components/sync/model/time.h" | 21 #include "components/sync/model/time.h" |
22 #include "components/sync/protocol/proto_enum_conversions.h" | 22 #include "components/sync/protocol/proto_enum_conversions.h" |
23 | 23 |
24 using base::DictionaryValue; | 24 using base::DictionaryValue; |
25 using base::ListValue; | 25 using base::Value; |
26 | 26 |
27 namespace syncer { | 27 namespace syncer { |
28 | 28 |
29 namespace sync_ui_util { | 29 namespace sync_ui_util { |
30 | 30 |
31 const char kIdentityTitle[] = "Identity"; | 31 const char kIdentityTitle[] = "Identity"; |
32 const char kDetailsKey[] = "details"; | 32 const char kDetailsKey[] = "details"; |
33 | 33 |
34 // Resource paths. | 34 // Resource paths. |
35 const char kAboutJS[] = "about.js"; | 35 const char kAboutJS[] = "about.js"; |
(...skipping 27 matching lines...) Expand all Loading... |
63 const char kOnReceivedListOfTypes[] = "onReceivedListOfTypes"; | 63 const char kOnReceivedListOfTypes[] = "onReceivedListOfTypes"; |
64 const char kStatus[] = "status"; | 64 const char kStatus[] = "status"; |
65 const char kTypes[] = "types"; | 65 const char kTypes[] = "types"; |
66 const char kUpdate[] = "update"; | 66 const char kUpdate[] = "update"; |
67 | 67 |
68 namespace { | 68 namespace { |
69 | 69 |
70 // Creates a 'section' for display on about:sync, consisting of a title and a | 70 // Creates a 'section' for display on about:sync, consisting of a title and a |
71 // list of fields. Returns a pointer to the new section. Note that | 71 // list of fields. Returns a pointer to the new section. Note that |
72 // |parent_list|, not the caller, owns the newly added section. | 72 // |parent_list|, not the caller, owns the newly added section. |
73 base::ListValue* AddSection(base::ListValue* parent_list, | 73 base::Value* AddSection(base::Value* parent_list, const std::string& title) { |
74 const std::string& title) { | 74 base::DictionaryValue section; |
75 std::unique_ptr<base::DictionaryValue> section(new base::DictionaryValue()); | 75 base::Value* section_contents = new base::Value(base::Value::Type::LIST); |
76 base::ListValue* section_contents = new base::ListValue(); | 76 section.SetString("title", title); |
77 section->SetString("title", title); | 77 section.Set("data", section_contents); |
78 section->Set("data", section_contents); | 78 section.SetBoolean("is_sensitive", false); |
79 section->SetBoolean("is_sensitive", false); | |
80 // If the following |Append| results in a reallocation, pointers to the | 79 // If the following |Append| results in a reallocation, pointers to the |
81 // members of |parent_list| will be invalidated. This would result in | 80 // members of |parent_list| will be invalidated. This would result in |
82 // use-after-free in |*SyncStat::SetValue|. This is why the following CHECK is | 81 // use-after-free in |*SyncStat::SetValue|. This is why the following CHECK is |
83 // necessary to ensure no reallocation takes place. | 82 // necessary to ensure no reallocation takes place. |
84 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 83 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
85 CHECK_LT(parent_list->GetSize(), parent_list->capacity()); | 84 CHECK_LT(parent_list->GetList().size(), parent_list->GetList().capacity()); |
86 parent_list->Append(std::move(section)); | 85 parent_list->GetList().push_back(std::move(section)); |
87 return section_contents; | 86 return section_contents; |
88 } | 87 } |
89 | 88 |
90 // Same as AddSection, but for data that should be elided when dumped into text | 89 // Same as AddSection, but for data that should be elided when dumped into text |
91 // form and posted in a public forum (e.g. unique identifiers). | 90 // form and posted in a public forum (e.g. unique identifiers). |
92 base::ListValue* AddSensitiveSection(base::ListValue* parent_list, | 91 base::Value* AddSensitiveSection(base::Value* parent_list, |
93 const std::string& title) { | 92 const std::string& title) { |
94 std::unique_ptr<base::DictionaryValue> section(new base::DictionaryValue()); | 93 base::DictionaryValue section; |
95 base::ListValue* section_contents = new base::ListValue(); | 94 base::Value* section_contents = new base::Value(base::Value::Type::LIST); |
96 section->SetString("title", title); | 95 section.SetString("title", title); |
97 section->Set("data", section_contents); | 96 section.Set("data", section_contents); |
98 section->SetBoolean("is_sensitive", true); | 97 section.SetBoolean("is_sensitive", true); |
99 // If the following |Append| results in a reallocation, pointers to | 98 // If the following |Append| results in a reallocation, pointers to |
100 // |parent_list| and its members will be invalidated. This would result in | 99 // |parent_list| and its members will be invalidated. This would result in |
101 // use-after-free in |*SyncStat::SetValue|. This is why the following CHECK is | 100 // use-after-free in |*SyncStat::SetValue|. This is why the following CHECK is |
102 // necessary to ensure no reallocation takes place. | 101 // necessary to ensure no reallocation takes place. |
103 CHECK_LT(parent_list->GetSize(), parent_list->capacity()); | 102 CHECK_LT(parent_list->GetList().size(), parent_list->GetList().capacity()); |
104 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 103 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
105 parent_list->Append(std::move(section)); | 104 parent_list->GetList().push_back(std::move(section)); |
106 return section_contents; | 105 return section_contents; |
107 } | 106 } |
108 | 107 |
109 // The following helper classes help manage the about:sync fields which will be | 108 // The following helper classes help manage the about:sync fields which will be |
110 // populated in method in ConstructAboutInformation. | 109 // populated in method in ConstructAboutInformation. |
111 // | 110 // |
112 // Each instance of one of thse classes indicates a field in about:sync. Each | 111 // Each instance of one of thse classes indicates a field in about:sync. Each |
113 // field will be serialized to a DictionaryValue with entries for 'stat_name', | 112 // field will be serialized to a DictionaryValue with entries for 'stat_name', |
114 // 'stat_value' and 'is_valid'. | 113 // 'stat_value' and 'is_valid'. |
115 | 114 |
116 class StringSyncStat { | 115 class StringSyncStat { |
117 public: | 116 public: |
118 StringSyncStat(base::ListValue* section, const std::string& key); | 117 StringSyncStat(base::Value* section, const std::string& key); |
119 void SetValue(const std::string& value); | 118 void SetValue(const std::string& value); |
120 void SetValue(const base::string16& value); | 119 void SetValue(const base::string16& value); |
121 | 120 |
122 private: | 121 private: |
123 // Owned by the |section| passed in during construction. | 122 // Owned by the |section| passed in during construction. |
124 base::DictionaryValue* stat_; | 123 base::DictionaryValue* stat_; |
125 }; | 124 }; |
126 | 125 |
127 StringSyncStat::StringSyncStat(base::ListValue* section, | 126 StringSyncStat::StringSyncStat(base::Value* section, const std::string& key) { |
128 const std::string& key) { | |
129 stat_ = new base::DictionaryValue(); | 127 stat_ = new base::DictionaryValue(); |
130 stat_->SetString("stat_name", key); | 128 stat_->SetString("stat_name", key); |
131 stat_->SetString("stat_value", "Uninitialized"); | 129 stat_->SetString("stat_value", "Uninitialized"); |
132 stat_->SetBoolean("is_valid", false); | 130 stat_->SetBoolean("is_valid", false); |
133 // |stat_| will be invalidated by |Append|, so it needs to be reset. | 131 // |stat_| will be invalidated by |Append|, so it needs to be reset. |
134 // Furthermore, if |Append| results in a reallocation, |stat_| members of | 132 // Furthermore, if |Append| results in a reallocation, |stat_| members of |
135 // other SyncStats will be invalidated. This is why the following check is | 133 // other SyncStats will be invalidated. This is why the following check is |
136 // necessary, so that it is guaranteed that a reallocation will not happen. | 134 // necessary, so that it is guaranteed that a reallocation will not happen. |
137 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 135 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
138 CHECK_LT(section->GetSize(), section->capacity()); | 136 CHECK_LT(section->GetList().size(), section->GetList().capacity()); |
139 section->Append(base::WrapUnique(stat_)); | 137 section->GetList().push_back(std::move(*stat_)); |
140 section->GetDictionary(section->GetSize() - 1, &stat_); | 138 stat_ = static_cast<base::DictionaryValue*>(§ion->GetList().back()); |
141 } | 139 } |
142 | 140 |
143 void StringSyncStat::SetValue(const std::string& value) { | 141 void StringSyncStat::SetValue(const std::string& value) { |
144 stat_->SetString("stat_value", value); | 142 stat_->SetString("stat_value", value); |
145 stat_->SetBoolean("is_valid", true); | 143 stat_->SetBoolean("is_valid", true); |
146 } | 144 } |
147 | 145 |
148 void StringSyncStat::SetValue(const base::string16& value) { | 146 void StringSyncStat::SetValue(const base::string16& value) { |
149 stat_->SetString("stat_value", value); | 147 stat_->SetString("stat_value", value); |
150 stat_->SetBoolean("is_valid", true); | 148 stat_->SetBoolean("is_valid", true); |
151 } | 149 } |
152 | 150 |
153 class BoolSyncStat { | 151 class BoolSyncStat { |
154 public: | 152 public: |
155 BoolSyncStat(base::ListValue* section, const std::string& key); | 153 BoolSyncStat(base::Value* section, const std::string& key); |
156 void SetValue(bool value); | 154 void SetValue(bool value); |
157 | 155 |
158 private: | 156 private: |
159 // Owned by the |section| passed in during construction. | 157 // Owned by the |section| passed in during construction. |
160 base::DictionaryValue* stat_; | 158 base::DictionaryValue* stat_; |
161 }; | 159 }; |
162 | 160 |
163 BoolSyncStat::BoolSyncStat(base::ListValue* section, const std::string& key) { | 161 BoolSyncStat::BoolSyncStat(base::Value* section, const std::string& key) { |
164 stat_ = new base::DictionaryValue(); | 162 stat_ = new base::DictionaryValue(); |
165 stat_->SetString("stat_name", key); | 163 stat_->SetString("stat_name", key); |
166 stat_->SetBoolean("stat_value", false); | 164 stat_->SetBoolean("stat_value", false); |
167 stat_->SetBoolean("is_valid", false); | 165 stat_->SetBoolean("is_valid", false); |
168 // |stat_| will be invalidated by |Append|, so it needs to be reset. | 166 // |stat_| will be invalidated by |Append|, so it needs to be reset. |
169 // Furthermore, if |Append| results in a reallocation, |stat_| members of | 167 // Furthermore, if |Append| results in a reallocation, |stat_| members of |
170 // other SyncStats will be invalidated. This is why the following check is | 168 // other SyncStats will be invalidated. This is why the following check is |
171 // necessary, so that it is guaranteed that a reallocation will not happen. | 169 // necessary, so that it is guaranteed that a reallocation will not happen. |
172 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 170 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
173 CHECK_LT(section->GetSize(), section->capacity()); | 171 CHECK_LT(section->GetList().size(), section->GetList().capacity()); |
174 section->Append(base::WrapUnique(stat_)); | 172 section->GetList().push_back(std::move(*stat_)); |
175 section->GetDictionary(section->GetSize() - 1, &stat_); | 173 stat_ = static_cast<base::DictionaryValue*>(§ion->GetList().back()); |
176 } | 174 } |
177 | 175 |
178 void BoolSyncStat::SetValue(bool value) { | 176 void BoolSyncStat::SetValue(bool value) { |
179 stat_->SetBoolean("stat_value", value); | 177 stat_->SetBoolean("stat_value", value); |
180 stat_->SetBoolean("is_valid", true); | 178 stat_->SetBoolean("is_valid", true); |
181 } | 179 } |
182 | 180 |
183 class IntSyncStat { | 181 class IntSyncStat { |
184 public: | 182 public: |
185 IntSyncStat(base::ListValue* section, const std::string& key); | 183 IntSyncStat(base::Value* section, const std::string& key); |
186 void SetValue(int value); | 184 void SetValue(int value); |
187 | 185 |
188 private: | 186 private: |
189 // Owned by the |section| passed in during construction. | 187 // Owned by the |section| passed in during construction. |
190 base::DictionaryValue* stat_; | 188 base::DictionaryValue* stat_; |
191 }; | 189 }; |
192 | 190 |
193 IntSyncStat::IntSyncStat(base::ListValue* section, const std::string& key) { | 191 IntSyncStat::IntSyncStat(base::Value* section, const std::string& key) { |
194 stat_ = new base::DictionaryValue(); | 192 stat_ = new base::DictionaryValue(); |
195 stat_->SetString("stat_name", key); | 193 stat_->SetString("stat_name", key); |
196 stat_->SetInteger("stat_value", 0); | 194 stat_->SetInteger("stat_value", 0); |
197 stat_->SetBoolean("is_valid", false); | 195 stat_->SetBoolean("is_valid", false); |
198 // |stat_| will be invalidated by |Append|, so it needs to be reset. | 196 // |stat_| will be invalidated by |Append|, so it needs to be reset. |
199 // Furthermore, if |Append| results in a reallocation, |stat_| members of | 197 // Furthermore, if |Append| results in a reallocation, |stat_| members of |
200 // other SyncStats will be invalidated. This is why the following check is | 198 // other SyncStats will be invalidated. This is why the following check is |
201 // necessary, so that it is guaranteed that a reallocation will not happen. | 199 // necessary, so that it is guaranteed that a reallocation will not happen. |
202 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 200 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
203 CHECK_LT(section->GetSize(), section->capacity()); | 201 CHECK_LT(section->GetList().size(), section->GetList().capacity()); |
204 section->Append(base::WrapUnique(stat_)); | 202 section->GetList().push_back(std::move(*stat_)); |
205 section->GetDictionary(section->GetSize() - 1, &stat_); | 203 stat_ = static_cast<base::DictionaryValue*>(§ion->GetList().back()); |
206 } | 204 } |
207 | 205 |
208 void IntSyncStat::SetValue(int value) { | 206 void IntSyncStat::SetValue(int value) { |
209 stat_->SetInteger("stat_value", value); | 207 stat_->SetInteger("stat_value", value); |
210 stat_->SetBoolean("is_valid", true); | 208 stat_->SetBoolean("is_valid", true); |
211 } | 209 } |
212 | 210 |
213 // Returns a string describing the chrome version environment. Version format: | 211 // Returns a string describing the chrome version environment. Version format: |
214 // <Build Info> <OS> <Version number> (<Last change>)<channel or "-devel"> | 212 // <Build Info> <OS> <Version number> (<Last change>)<channel or "-devel"> |
215 // If version information is unavailable, returns "invalid." | 213 // If version information is unavailable, returns "invalid." |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // which are grouped into sections and populated with the help of the SyncStat | 275 // which are grouped into sections and populated with the help of the SyncStat |
278 // classes defined above. | 276 // classes defined above. |
279 std::unique_ptr<base::DictionaryValue> ConstructAboutInformation( | 277 std::unique_ptr<base::DictionaryValue> ConstructAboutInformation( |
280 SyncService* service, | 278 SyncService* service, |
281 SigninManagerBase* signin, | 279 SigninManagerBase* signin, |
282 version_info::Channel channel) { | 280 version_info::Channel channel) { |
283 std::unique_ptr<base::DictionaryValue> about_info( | 281 std::unique_ptr<base::DictionaryValue> about_info( |
284 new base::DictionaryValue()); | 282 new base::DictionaryValue()); |
285 | 283 |
286 // 'details': A list of sections. | 284 // 'details': A list of sections. |
287 base::ListValue* stats_list = new base::ListValue(); | 285 base::Value* stats_list = new base::Value(base::Value::Type::LIST); |
288 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 286 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
289 stats_list->Reserve(12); | 287 stats_list->GetList().reserve(12); |
290 | 288 |
291 // The following lines define the sections and their fields. For each field, | 289 // The following lines define the sections and their fields. For each field, |
292 // a class is instantiated, which allows us to reference the fields in | 290 // a class is instantiated, which allows us to reference the fields in |
293 // 'setter' code later on in this function. | 291 // 'setter' code later on in this function. |
294 base::ListValue* section_summary = AddSection(stats_list, "Summary"); | 292 base::Value* section_summary = AddSection(stats_list, "Summary"); |
295 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 293 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
296 section_summary->Reserve(1); | 294 section_summary->GetList().reserve(1); |
297 StringSyncStat summary_string(section_summary, "Summary"); | 295 StringSyncStat summary_string(section_summary, "Summary"); |
298 | 296 |
299 base::ListValue* section_version = AddSection(stats_list, "Version Info"); | 297 base::Value* section_version = AddSection(stats_list, "Version Info"); |
300 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 298 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
301 section_version->Reserve(2); | 299 section_version->GetList().reserve(2); |
302 StringSyncStat client_version(section_version, "Client Version"); | 300 StringSyncStat client_version(section_version, "Client Version"); |
303 StringSyncStat server_url(section_version, "Server URL"); | 301 StringSyncStat server_url(section_version, "Server URL"); |
304 | 302 |
305 base::ListValue* section_identity = | 303 base::Value* section_identity = |
306 AddSensitiveSection(stats_list, kIdentityTitle); | 304 AddSensitiveSection(stats_list, kIdentityTitle); |
307 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 305 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
308 section_identity->Reserve(3); | 306 section_identity->GetList().reserve(3); |
309 StringSyncStat sync_id(section_identity, "Sync Client ID"); | 307 StringSyncStat sync_id(section_identity, "Sync Client ID"); |
310 StringSyncStat invalidator_id(section_identity, "Invalidator Client ID"); | 308 StringSyncStat invalidator_id(section_identity, "Invalidator Client ID"); |
311 StringSyncStat username(section_identity, "Username"); | 309 StringSyncStat username(section_identity, "Username"); |
312 | 310 |
313 base::ListValue* section_credentials = AddSection(stats_list, "Credentials"); | 311 base::Value* section_credentials = AddSection(stats_list, "Credentials"); |
314 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 312 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
315 section_credentials->Reserve(4); | 313 section_credentials->GetList().reserve(4); |
316 StringSyncStat request_token_time(section_credentials, "Requested Token"); | 314 StringSyncStat request_token_time(section_credentials, "Requested Token"); |
317 StringSyncStat receive_token_time(section_credentials, "Received Token"); | 315 StringSyncStat receive_token_time(section_credentials, "Received Token"); |
318 StringSyncStat token_request_status(section_credentials, | 316 StringSyncStat token_request_status(section_credentials, |
319 "Token Request Status"); | 317 "Token Request Status"); |
320 StringSyncStat next_token_request(section_credentials, "Next Token Request"); | 318 StringSyncStat next_token_request(section_credentials, "Next Token Request"); |
321 | 319 |
322 base::ListValue* section_local = AddSection(stats_list, "Local State"); | 320 base::Value* section_local = AddSection(stats_list, "Local State"); |
323 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 321 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
324 section_local->Reserve(7); | 322 section_local->GetList().reserve(7); |
325 StringSyncStat server_connection(section_local, "Server Connection"); | 323 StringSyncStat server_connection(section_local, "Server Connection"); |
326 StringSyncStat last_synced(section_local, "Last Synced"); | 324 StringSyncStat last_synced(section_local, "Last Synced"); |
327 BoolSyncStat is_setup_complete(section_local, | 325 BoolSyncStat is_setup_complete(section_local, |
328 "Sync First-Time Setup Complete"); | 326 "Sync First-Time Setup Complete"); |
329 StringSyncStat backend_initialization(section_local, | 327 StringSyncStat backend_initialization(section_local, |
330 "Sync Backend Initialization"); | 328 "Sync Backend Initialization"); |
331 BoolSyncStat is_syncing(section_local, "Syncing"); | 329 BoolSyncStat is_syncing(section_local, "Syncing"); |
332 BoolSyncStat is_local_sync_enabled(section_local, | 330 BoolSyncStat is_local_sync_enabled(section_local, |
333 "Local sync backend enabled"); | 331 "Local sync backend enabled"); |
334 StringSyncStat local_backend_path(section_local, "Local backend path"); | 332 StringSyncStat local_backend_path(section_local, "Local backend path"); |
335 | 333 |
336 base::ListValue* section_network = AddSection(stats_list, "Network"); | 334 base::Value* section_network = AddSection(stats_list, "Network"); |
337 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 335 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
338 section_network->Reserve(3); | 336 section_network->GetList().reserve(3); |
339 BoolSyncStat is_throttled(section_network, "Throttled"); | 337 BoolSyncStat is_throttled(section_network, "Throttled"); |
340 StringSyncStat retry_time(section_network, "Retry time (maybe stale)"); | 338 StringSyncStat retry_time(section_network, "Retry time (maybe stale)"); |
341 BoolSyncStat are_notifications_enabled(section_network, | 339 BoolSyncStat are_notifications_enabled(section_network, |
342 "Notifications Enabled"); | 340 "Notifications Enabled"); |
343 | 341 |
344 base::ListValue* section_encryption = AddSection(stats_list, "Encryption"); | 342 base::Value* section_encryption = AddSection(stats_list, "Encryption"); |
345 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 343 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
346 section_encryption->Reserve(9); | 344 section_encryption->GetList().reserve(9); |
347 BoolSyncStat is_using_explicit_passphrase(section_encryption, | 345 BoolSyncStat is_using_explicit_passphrase(section_encryption, |
348 "Explicit Passphrase"); | 346 "Explicit Passphrase"); |
349 BoolSyncStat is_passphrase_required(section_encryption, | 347 BoolSyncStat is_passphrase_required(section_encryption, |
350 "Passphrase Required"); | 348 "Passphrase Required"); |
351 BoolSyncStat is_cryptographer_ready(section_encryption, | 349 BoolSyncStat is_cryptographer_ready(section_encryption, |
352 "Cryptographer Ready"); | 350 "Cryptographer Ready"); |
353 BoolSyncStat has_pending_keys(section_encryption, | 351 BoolSyncStat has_pending_keys(section_encryption, |
354 "Cryptographer Has Pending Keys"); | 352 "Cryptographer Has Pending Keys"); |
355 StringSyncStat encrypted_types(section_encryption, "Encrypted Types"); | 353 StringSyncStat encrypted_types(section_encryption, "Encrypted Types"); |
356 BoolSyncStat has_keystore_key(section_encryption, "Has Keystore Key"); | 354 BoolSyncStat has_keystore_key(section_encryption, "Has Keystore Key"); |
357 StringSyncStat keystore_migration_time(section_encryption, | 355 StringSyncStat keystore_migration_time(section_encryption, |
358 "Keystore Migration Time"); | 356 "Keystore Migration Time"); |
359 StringSyncStat passphrase_type(section_encryption, "Passphrase Type"); | 357 StringSyncStat passphrase_type(section_encryption, "Passphrase Type"); |
360 StringSyncStat passphrase_time(section_encryption, "Passphrase Time"); | 358 StringSyncStat passphrase_time(section_encryption, "Passphrase Time"); |
361 | 359 |
362 base::ListValue* section_last_session = | 360 base::Value* section_last_session = |
363 AddSection(stats_list, "Status from Last Completed Session"); | 361 AddSection(stats_list, "Status from Last Completed Session"); |
364 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 362 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
365 section_last_session->Reserve(4); | 363 section_last_session->GetList().reserve(4); |
366 StringSyncStat session_source(section_last_session, "Sync Source"); | 364 StringSyncStat session_source(section_last_session, "Sync Source"); |
367 StringSyncStat get_key_result(section_last_session, "GetKey Step Result"); | 365 StringSyncStat get_key_result(section_last_session, "GetKey Step Result"); |
368 StringSyncStat download_result(section_last_session, "Download Step Result"); | 366 StringSyncStat download_result(section_last_session, "Download Step Result"); |
369 StringSyncStat commit_result(section_last_session, "Commit Step Result"); | 367 StringSyncStat commit_result(section_last_session, "Commit Step Result"); |
370 | 368 |
371 base::ListValue* section_counters = AddSection(stats_list, "Running Totals"); | 369 base::Value* section_counters = AddSection(stats_list, "Running Totals"); |
372 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 370 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
373 section_counters->Reserve(7); | 371 section_counters->GetList().reserve(7); |
374 IntSyncStat notifications_received(section_counters, | 372 IntSyncStat notifications_received(section_counters, |
375 "Notifications Received"); | 373 "Notifications Received"); |
376 IntSyncStat updates_received(section_counters, "Updates Downloaded"); | 374 IntSyncStat updates_received(section_counters, "Updates Downloaded"); |
377 IntSyncStat tombstone_updates(section_counters, "Tombstone Updates"); | 375 IntSyncStat tombstone_updates(section_counters, "Tombstone Updates"); |
378 IntSyncStat reflected_updates(section_counters, "Reflected Updates"); | 376 IntSyncStat reflected_updates(section_counters, "Reflected Updates"); |
379 IntSyncStat successful_commits(section_counters, "Successful Commits"); | 377 IntSyncStat successful_commits(section_counters, "Successful Commits"); |
380 IntSyncStat conflicts_resolved_local_wins(section_counters, | 378 IntSyncStat conflicts_resolved_local_wins(section_counters, |
381 "Conflicts Resolved: Client Wins"); | 379 "Conflicts Resolved: Client Wins"); |
382 IntSyncStat conflicts_resolved_server_wins(section_counters, | 380 IntSyncStat conflicts_resolved_server_wins(section_counters, |
383 "Conflicts Resolved: Server Wins"); | 381 "Conflicts Resolved: Server Wins"); |
384 | 382 |
385 base::ListValue* section_this_cycle = | 383 base::Value* section_this_cycle = |
386 AddSection(stats_list, "Transient Counters (this cycle)"); | 384 AddSection(stats_list, "Transient Counters (this cycle)"); |
387 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 385 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
388 section_this_cycle->Reserve(4); | 386 section_this_cycle->GetList().reserve(4); |
389 IntSyncStat encryption_conflicts(section_this_cycle, "Encryption Conflicts"); | 387 IntSyncStat encryption_conflicts(section_this_cycle, "Encryption Conflicts"); |
390 IntSyncStat hierarchy_conflicts(section_this_cycle, "Hierarchy Conflicts"); | 388 IntSyncStat hierarchy_conflicts(section_this_cycle, "Hierarchy Conflicts"); |
391 IntSyncStat server_conflicts(section_this_cycle, "Server Conflicts"); | 389 IntSyncStat server_conflicts(section_this_cycle, "Server Conflicts"); |
392 IntSyncStat committed_items(section_this_cycle, "Committed Items"); | 390 IntSyncStat committed_items(section_this_cycle, "Committed Items"); |
393 | 391 |
394 base::ListValue* section_that_cycle = AddSection( | 392 base::Value* section_that_cycle = AddSection( |
395 stats_list, "Transient Counters (last cycle of last completed session)"); | 393 stats_list, "Transient Counters (last cycle of last completed session)"); |
396 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 394 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
397 section_that_cycle->Reserve(3); | 395 section_that_cycle->GetList().reserve(3); |
398 IntSyncStat updates_downloaded(section_that_cycle, "Updates Downloaded"); | 396 IntSyncStat updates_downloaded(section_that_cycle, "Updates Downloaded"); |
399 IntSyncStat committed_count(section_that_cycle, "Committed Count"); | 397 IntSyncStat committed_count(section_that_cycle, "Committed Count"); |
400 IntSyncStat entries(section_that_cycle, "Entries"); | 398 IntSyncStat entries(section_that_cycle, "Entries"); |
401 | 399 |
402 base::ListValue* section_nudge_info = | 400 base::Value* section_nudge_info = |
403 AddSection(stats_list, "Nudge Source Counters"); | 401 AddSection(stats_list, "Nudge Source Counters"); |
404 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 402 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
405 section_nudge_info->Reserve(3); | 403 section_nudge_info->GetList().reserve(3); |
406 IntSyncStat nudge_source_notification(section_nudge_info, | 404 IntSyncStat nudge_source_notification(section_nudge_info, |
407 "Server Invalidations"); | 405 "Server Invalidations"); |
408 IntSyncStat nudge_source_local(section_nudge_info, "Local Changes"); | 406 IntSyncStat nudge_source_local(section_nudge_info, "Local Changes"); |
409 IntSyncStat nudge_source_local_refresh(section_nudge_info, "Local Refreshes"); | 407 IntSyncStat nudge_source_local_refresh(section_nudge_info, "Local Refreshes"); |
410 | 408 |
411 // This list of sections belongs in the 'details' field of the returned | 409 // This list of sections belongs in the 'details' field of the returned |
412 // message. | 410 // message. |
413 about_info->Set(kDetailsKey, stats_list); | 411 about_info->Set(kDetailsKey, stats_list); |
414 | 412 |
415 // Populate all the fields we declared above. | 413 // Populate all the fields we declared above. |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 const bool actionable_error_detected = | 541 const bool actionable_error_detected = |
544 full_status.sync_protocol_error.error_type != UNKNOWN_ERROR && | 542 full_status.sync_protocol_error.error_type != UNKNOWN_ERROR && |
545 full_status.sync_protocol_error.error_type != SYNC_SUCCESS; | 543 full_status.sync_protocol_error.error_type != SYNC_SUCCESS; |
546 | 544 |
547 about_info->SetBoolean("actionable_error_detected", | 545 about_info->SetBoolean("actionable_error_detected", |
548 actionable_error_detected); | 546 actionable_error_detected); |
549 | 547 |
550 // NOTE: We won't bother showing any of the following values unless | 548 // NOTE: We won't bother showing any of the following values unless |
551 // actionable_error_detected is set. | 549 // actionable_error_detected is set. |
552 | 550 |
553 base::ListValue* actionable_error = new base::ListValue(); | 551 base::Value* actionable_error = new base::Value(base::Value::Type::LIST); |
554 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. | 552 // TODO(crbug.com/702230): Remove the usages of raw pointers in this file. |
555 actionable_error->Reserve(4); | 553 actionable_error->GetList().reserve(4); |
556 about_info->Set("actionable_error", actionable_error); | 554 about_info->Set("actionable_error", actionable_error); |
557 | 555 |
558 StringSyncStat error_type(actionable_error, "Error Type"); | 556 StringSyncStat error_type(actionable_error, "Error Type"); |
559 StringSyncStat action(actionable_error, "Action"); | 557 StringSyncStat action(actionable_error, "Action"); |
560 StringSyncStat url(actionable_error, "URL"); | 558 StringSyncStat url(actionable_error, "URL"); |
561 StringSyncStat description(actionable_error, "Error Description"); | 559 StringSyncStat description(actionable_error, "Error Description"); |
562 | 560 |
563 if (actionable_error_detected) { | 561 if (actionable_error_detected) { |
564 error_type.SetValue( | 562 error_type.SetValue( |
565 GetSyncErrorTypeString(full_status.sync_protocol_error.error_type)); | 563 GetSyncErrorTypeString(full_status.sync_protocol_error.error_type)); |
(...skipping 18 matching lines...) Expand all Loading... |
584 } | 582 } |
585 | 583 |
586 about_info->Set("type_status", service->GetTypeStatusMap()); | 584 about_info->Set("type_status", service->GetTypeStatusMap()); |
587 | 585 |
588 return about_info; | 586 return about_info; |
589 } | 587 } |
590 | 588 |
591 } // namespace sync_ui_util | 589 } // namespace sync_ui_util |
592 | 590 |
593 } // namespace syncer | 591 } // namespace syncer |
OLD | NEW |