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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 284 |
283 void AddBoolSyncDetail(ListValue* details, | 285 void AddBoolSyncDetail(ListValue* details, |
284 const std::string& stat_name, | 286 const std::string& stat_name, |
285 bool stat_value) { | 287 bool stat_value) { |
286 DictionaryValue* val = new DictionaryValue; | 288 DictionaryValue* val = new DictionaryValue; |
287 val->SetString("stat_name", stat_name); | 289 val->SetString("stat_name", stat_name); |
288 val->SetBoolean("stat_value", stat_value); | 290 val->SetBoolean("stat_value", stat_value); |
289 details->Append(val); | 291 details->Append(val); |
290 } | 292 } |
291 | 293 |
| 294 void AddStringSyncDetails(ListValue* details, const std::string& stat_name, |
| 295 const std::string& stat_value) { |
| 296 DictionaryValue* val = new DictionaryValue; |
| 297 val->SetString("stat_name", stat_name); |
| 298 val->SetString("stat_value", stat_value); |
| 299 details->Append(val); |
| 300 } |
| 301 |
292 void AddIntSyncDetail(ListValue* details, const std::string& stat_name, | 302 void AddIntSyncDetail(ListValue* details, const std::string& stat_name, |
293 int64 stat_value) { | 303 int64 stat_value) { |
294 DictionaryValue* val = new DictionaryValue; | 304 DictionaryValue* val = new DictionaryValue; |
295 val->SetString("stat_name", stat_name); | 305 val->SetString("stat_name", stat_name); |
296 val->SetString("stat_value", base::FormatNumber(stat_value)); | 306 val->SetString("stat_value", base::FormatNumber(stat_value)); |
297 details->Append(val); | 307 details->Append(val); |
298 } | 308 } |
299 | 309 |
300 string16 ConstructTime(int64 time_in_int) { | 310 string16 ConstructTime(int64 time_in_int) { |
301 base::Time time = base::Time::FromInternalValue(time_in_int); | 311 base::Time time = base::Time::FromInternalValue(time_in_int); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 full_status.updates_received); | 406 full_status.updates_received); |
397 sync_ui_util::AddIntSyncDetail(details, | 407 sync_ui_util::AddIntSyncDetail(details, |
398 "Updates Downloaded (Tombstones)", | 408 "Updates Downloaded (Tombstones)", |
399 full_status.tombstone_updates_received); | 409 full_status.tombstone_updates_received); |
400 sync_ui_util::AddBoolSyncDetail(details, | 410 sync_ui_util::AddBoolSyncDetail(details, |
401 "Disk Full", | 411 "Disk Full", |
402 full_status.disk_full); | 412 full_status.disk_full); |
403 sync_ui_util::AddIntSyncDetail(details, | 413 sync_ui_util::AddIntSyncDetail(details, |
404 "Max Consecutive Errors", | 414 "Max Consecutive Errors", |
405 full_status.max_consecutive_errors); | 415 full_status.max_consecutive_errors); |
| 416 sync_ui_util::AddIntSyncDetail(details, |
| 417 "Empty GetUpdates", |
| 418 full_status.empty_get_updates); |
| 419 sync_ui_util::AddIntSyncDetail(details, |
| 420 "Nonempty GetUpdates", |
| 421 full_status.nonempty_get_updates); |
| 422 sync_ui_util::AddIntSyncDetail(details, |
| 423 "Useless Sync Cycles", |
| 424 full_status.useless_sync_cycles); |
| 425 sync_ui_util::AddIntSyncDetail(details, |
| 426 "Useful Sync Cycles", |
| 427 full_status.useful_sync_cycles); |
| 428 |
| 429 const browser_sync::sessions::SyncSessionSnapshot* snapshot = |
| 430 service->GetLastSessionSnapshot(); |
| 431 |
| 432 // |snapshot| could be null if sync is not yet completed. |
| 433 if (snapshot) { |
| 434 sync_ui_util::AddIntSyncDetail(details, "Download Count (This Session)", |
| 435 snapshot->syncer_status.num_updates_downloaded_total); |
| 436 sync_ui_util::AddIntSyncDetail(details, "Commit Count (This Session)", |
| 437 snapshot->syncer_status.num_successful_commits); |
| 438 sync_ui_util::AddStringSyncDetails(details, "Last Sync Source", |
| 439 browser_sync::GetUpdatesSourceString( |
| 440 snapshot->source.updates_source)); |
| 441 |
| 442 // Print the count of entries from snapshot. Warning: This might be |
| 443 // slightly out of date if there are client side changes that are yet |
| 444 // unsynced However if we query the latest count here we will |
| 445 // have to hold the transaction which means we cannot display this page |
| 446 // when syncing. |
| 447 sync_ui_util::AddIntSyncDetail(details, "Entries" , |
| 448 snapshot->num_entries); |
| 449 sync_ui_util::AddBoolSyncDetail(details, "Throttled", |
| 450 snapshot->is_silenced); |
| 451 } |
406 | 452 |
407 if (service->unrecoverable_error_detected()) { | 453 if (service->unrecoverable_error_detected()) { |
408 strings->Set("unrecoverable_error_detected", new FundamentalValue(true)); | 454 strings->Set("unrecoverable_error_detected", new FundamentalValue(true)); |
409 tracked_objects::Location loc(service->unrecoverable_error_location()); | 455 tracked_objects::Location loc(service->unrecoverable_error_location()); |
410 std::string location_str; | 456 std::string location_str; |
411 loc.Write(true, true, &location_str); | 457 loc.Write(true, true, &location_str); |
412 std::string unrecoverable_error_message = | 458 std::string unrecoverable_error_message = |
413 "Unrecoverable error detected at " + location_str + | 459 "Unrecoverable error detected at " + location_str + |
414 ": " + service->unrecoverable_error_message(); | 460 ": " + service->unrecoverable_error_message(); |
415 strings->SetString("unrecoverable_error_message", | 461 strings->SetString("unrecoverable_error_message", |
(...skipping 30 matching lines...) Expand all Loading... |
446 | 492 |
447 DictionaryValue* val = new DictionaryValue; | 493 DictionaryValue* val = new DictionaryValue; |
448 val->SetString("stat_name", "Autofill Migration Time"); | 494 val->SetString("stat_name", "Autofill Migration Time"); |
449 val->SetString("stat_value", ConstructTime(info.autofill_migration_time)); | 495 val->SetString("stat_value", ConstructTime(info.autofill_migration_time)); |
450 details->Append(val); | 496 details->Append(val); |
451 } | 497 } |
452 } | 498 } |
453 } | 499 } |
454 | 500 |
455 } // namespace sync_ui_util | 501 } // namespace sync_ui_util |
OLD | NEW |