Chromium Code Reviews| 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 Getupdates", | |
| 413 full_status.empty_getupdates); | |
| 414 sync_ui_util::AddIntSyncDetail(details, | |
| 415 "Nonempty Getupdates", | |
| 416 full_status.nonempty_getupdates); | |
| 417 | |
| 418 const browser_sync::sessions::SyncSessionSnapshot* snapshot = | |
| 419 service->GetLastSessionSnapshot(); | |
| 420 | |
| 421 // |snapshot| could be null if sync is not yet completed. | |
| 422 if (snapshot) { | |
| 423 sync_ui_util::AddIntSyncDetail(details, "Download Count(This Session)", | |
| 424 snapshot->syncer_status.num_updates_downloaded_total); | |
| 425 sync_ui_util::AddIntSyncDetail(details, "Commit Count(This Session)", | |
| 426 snapshot->syncer_status.num_successful_commits); | |
| 427 sync_ui_util::AddStringSyncDetails(details, "Last Sync Source", | |
| 428 browser_sync::GetUpdatesSourceString( | |
| 429 snapshot->source.updates_source)); | |
| 430 | |
| 431 // Print the count of entries from snapshot. Warning: This might be | |
| 432 // slightly out of date if there are client side changes that are yet | |
| 433 // unsynced However if we query the latest count here we will | |
| 434 // have to hold the transaction which means we cannot display this page | |
| 435 // when syncing. | |
|
lipalani1
2011/05/13 00:43:54
ACtually holding a transaction is not necessary. M
lipalani1
2011/05/13 01:06:43
Done.
| |
| 436 sync_ui_util::AddIntSyncDetail(details, "Entries" , | |
| 437 snapshot->num_entries); | |
| 438 sync_ui_util::AddBoolSyncDetail(details, "Throttled", | |
| 439 snapshot->syncer_status.throttled); | |
| 440 } | |
| 401 | 441 |
| 402 if (service->unrecoverable_error_detected()) { | 442 if (service->unrecoverable_error_detected()) { |
| 403 strings->Set("unrecoverable_error_detected", new FundamentalValue(true)); | 443 strings->Set("unrecoverable_error_detected", new FundamentalValue(true)); |
| 404 strings->SetString("unrecoverable_error_message", | 444 strings->SetString("unrecoverable_error_message", |
| 405 service->unrecoverable_error_message()); | 445 service->unrecoverable_error_message()); |
| 406 tracked_objects::Location loc(service->unrecoverable_error_location()); | 446 tracked_objects::Location loc(service->unrecoverable_error_location()); |
| 407 std::string location_str; | 447 std::string location_str; |
| 408 loc.Write(true, true, &location_str); | 448 loc.Write(true, true, &location_str); |
| 409 strings->SetString("unrecoverable_error_location", location_str); | 449 strings->SetString("unrecoverable_error_location", location_str); |
| 410 } else if (!service->sync_initialized()) { | 450 } else if (!service->sync_initialized()) { |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 441 | 481 |
| 442 DictionaryValue* val = new DictionaryValue; | 482 DictionaryValue* val = new DictionaryValue; |
| 443 val->SetString("stat_name", "Autofill Migration Time"); | 483 val->SetString("stat_name", "Autofill Migration Time"); |
| 444 val->SetString("stat_value", ConstructTime(info.autofill_migration_time)); | 484 val->SetString("stat_value", ConstructTime(info.autofill_migration_time)); |
| 445 details->Append(val); | 485 details->Append(val); |
| 446 } | 486 } |
| 447 } | 487 } |
| 448 } | 488 } |
| 449 | 489 |
| 450 } // namespace sync_ui_util | 490 } // namespace sync_ui_util |
| OLD | NEW |