OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/sync_ui_util.h" | 5 #include "chrome/browser/sync/sync_ui_util.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/i18n/number_formatting.h" | 8 #include "base/i18n/number_formatting.h" |
9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/sync/profile_sync_service.h" | 13 #include "chrome/browser/sync/profile_sync_service.h" |
14 #include "chrome/browser/sync/protocol/proto_enum_conversions.h" | |
15 #include "chrome/browser/sync/sessions/session_state.h" | |
14 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
16 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/common/net/gaia/google_service_auth_error.h" | 19 #include "chrome/common/net/gaia/google_service_auth_error.h" |
18 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
19 #include "grit/browser_resources.h" | 21 #include "grit/browser_resources.h" |
20 #include "grit/chromium_strings.h" | 22 #include "grit/chromium_strings.h" |
21 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
22 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
23 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 | 281 |
280 void AddBoolSyncDetail(ListValue* details, | 282 void AddBoolSyncDetail(ListValue* details, |
281 const std::string& stat_name, | 283 const std::string& stat_name, |
282 bool stat_value) { | 284 bool stat_value) { |
283 DictionaryValue* val = new DictionaryValue; | 285 DictionaryValue* val = new DictionaryValue; |
284 val->SetString("stat_name", stat_name); | 286 val->SetString("stat_name", stat_name); |
285 val->SetBoolean("stat_value", stat_value); | 287 val->SetBoolean("stat_value", stat_value); |
286 details->Append(val); | 288 details->Append(val); |
287 } | 289 } |
288 | 290 |
291 void AddStringSyncDetails(ListValue* details, const std::string& stat_name, | |
292 const std::string& stat_value) { | |
293 DictionaryValue* val = new DictionaryValue; | |
294 val->SetString("stat_name", stat_name); | |
295 val->SetString("stat_value", stat_value); | |
296 details->Append(val); | |
297 } | |
298 | |
289 void AddIntSyncDetail(ListValue* details, const std::string& stat_name, | 299 void AddIntSyncDetail(ListValue* details, const std::string& stat_name, |
290 int64 stat_value) { | 300 int64 stat_value) { |
291 DictionaryValue* val = new DictionaryValue; | 301 DictionaryValue* val = new DictionaryValue; |
292 val->SetString("stat_name", stat_name); | 302 val->SetString("stat_name", stat_name); |
293 val->SetString("stat_value", base::FormatNumber(stat_value)); | 303 val->SetString("stat_value", base::FormatNumber(stat_value)); |
294 details->Append(val); | 304 details->Append(val); |
295 } | 305 } |
296 | 306 |
297 string16 ConstructTime(int64 time_in_int) { | 307 string16 ConstructTime(int64 time_in_int) { |
298 base::Time time = base::Time::FromInternalValue(time_in_int); | 308 base::Time time = base::Time::FromInternalValue(time_in_int); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
391 full_status.updates_received); | 401 full_status.updates_received); |
392 sync_ui_util::AddIntSyncDetail(details, | 402 sync_ui_util::AddIntSyncDetail(details, |
393 "Updates Downloaded (Tombstones)", | 403 "Updates Downloaded (Tombstones)", |
394 full_status.tombstone_updates_received); | 404 full_status.tombstone_updates_received); |
395 sync_ui_util::AddBoolSyncDetail(details, | 405 sync_ui_util::AddBoolSyncDetail(details, |
396 "Disk Full", | 406 "Disk Full", |
397 full_status.disk_full); | 407 full_status.disk_full); |
398 sync_ui_util::AddIntSyncDetail(details, | 408 sync_ui_util::AddIntSyncDetail(details, |
399 "Max Consecutive Errors", | 409 "Max Consecutive Errors", |
400 full_status.max_consecutive_errors); | 410 full_status.max_consecutive_errors); |
411 sync_ui_util::AddIntSyncDetail(details, | |
412 "Empty Get Updates", | |
akalin
2011/05/18 01:06:34
Get Updates -> GetUpdates
| |
413 full_status.empty_get_updates); | |
414 sync_ui_util::AddIntSyncDetail(details, | |
415 "Nonempty Get Updates", | |
akalin
2011/05/18 01:06:34
Get Updates -> GetUpdates
| |
416 full_status.nonempty_get_updates); | |
417 sync_ui_util::AddIntSyncDetail(details, | |
418 "Useless Syncs", | |
akalin
2011/05/18 01:06:34
Syncs -> Sync Cycles
| |
419 full_status.useless_sync_cycles); | |
420 sync_ui_util::AddIntSyncDetail(details, | |
421 "Useful Syncs", | |
akalin
2011/05/18 01:06:34
Syncs -> Sync Cycles
| |
422 full_status.useful_sync_cycles); | |
423 | |
424 const browser_sync::sessions::SyncSessionSnapshot* snapshot = | |
425 service->GetLastSessionSnapshot(); | |
426 | |
427 // |snapshot| could be null if sync is not yet completed. | |
428 if (snapshot) { | |
429 sync_ui_util::AddIntSyncDetail(details, "Download Count (This Session)", | |
akalin
2011/05/18 01:06:34
Proper indentation is:
sync_ui_util::AddIntSyncDe
| |
430 snapshot->syncer_status.num_updates_downloaded_total); | |
431 sync_ui_util::AddIntSyncDetail(details, "Commit Count (This Session)", | |
432 snapshot->syncer_status.num_successful_commits); | |
433 sync_ui_util::AddStringSyncDetails(details, "Last Sync Source", | |
434 browser_sync::GetUpdatesSourceString( | |
435 snapshot->source.updates_source)); | |
436 | |
437 // Print the count of entries from snapshot. Warning: This might be | |
438 // slightly out of date if there are client side changes that are yet | |
439 // unsynced However if we query the latest count here we will | |
440 // have to hold the transaction which means we cannot display this page | |
441 // when syncing. | |
442 sync_ui_util::AddIntSyncDetail(details, "Entries" , | |
443 snapshot->num_entries); | |
444 sync_ui_util::AddBoolSyncDetail(details, "Throttled", | |
445 snapshot->is_silenced); | |
446 } | |
401 | 447 |
402 if (service->unrecoverable_error_detected()) { | 448 if (service->unrecoverable_error_detected()) { |
403 strings->Set("unrecoverable_error_detected", new FundamentalValue(true)); | 449 strings->Set("unrecoverable_error_detected", new FundamentalValue(true)); |
404 strings->SetString("unrecoverable_error_message", | 450 strings->SetString("unrecoverable_error_message", |
405 service->unrecoverable_error_message()); | 451 service->unrecoverable_error_message()); |
406 tracked_objects::Location loc(service->unrecoverable_error_location()); | 452 tracked_objects::Location loc(service->unrecoverable_error_location()); |
407 std::string location_str; | 453 std::string location_str; |
408 loc.Write(true, true, &location_str); | 454 loc.Write(true, true, &location_str); |
409 strings->SetString("unrecoverable_error_location", location_str); | 455 strings->SetString("unrecoverable_error_location", location_str); |
410 } else if (!service->sync_initialized()) { | 456 } else if (!service->sync_initialized()) { |
(...skipping 30 matching lines...) Expand all Loading... | |
441 | 487 |
442 DictionaryValue* val = new DictionaryValue; | 488 DictionaryValue* val = new DictionaryValue; |
443 val->SetString("stat_name", "Autofill Migration Time"); | 489 val->SetString("stat_name", "Autofill Migration Time"); |
444 val->SetString("stat_value", ConstructTime(info.autofill_migration_time)); | 490 val->SetString("stat_value", ConstructTime(info.autofill_migration_time)); |
445 details->Append(val); | 491 details->Append(val); |
446 } | 492 } |
447 } | 493 } |
448 } | 494 } |
449 | 495 |
450 } // namespace sync_ui_util | 496 } // namespace sync_ui_util |
OLD | NEW |