Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: chrome/browser/ui/webui/signin/user_manager_screen_handler.cc

Issue 1579433002: Make profile statistics tasks inspectable by tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make ProfileStatisticsAggregator tasks trackable Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/webui/signin/user_manager_screen_handler.h" 5 #include "chrome/browser/ui/webui/signin/user_manager_screen_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 return; 590 return;
591 591
592 if (!chrome::FindAnyBrowser(profile, true, desktop_type_)) { 592 if (!chrome::FindAnyBrowser(profile, true, desktop_type_)) {
593 // If no windows are open for that profile, the statistics in 593 // If no windows are open for that profile, the statistics in
594 // ProfileInfoCache are up to date. The statistics in ProfileInfoCache are 594 // ProfileInfoCache are up to date. The statistics in ProfileInfoCache are
595 // returned because the copy in user_pod_row.js may be outdated. However, if 595 // returned because the copy in user_pod_row.js may be outdated. However, if
596 // some statistics are missing in ProfileInfoCache (i.e. |item.success| is 596 // some statistics are missing in ProfileInfoCache (i.e. |item.success| is
597 // false), then the actual statistics are queried instead. 597 // false), then the actual statistics are queried instead.
598 base::DictionaryValue return_value; 598 base::DictionaryValue return_value;
599 profiles::ProfileCategoryStats stats = 599 profiles::ProfileCategoryStats stats =
600 profiles::GetProfileStatisticsFromCache(profile_path); 600 ProfileStatistics::GetProfileStatisticsFromCache(profile_path);
601 bool stats_success = true; 601 bool stats_success = true;
602 for (const auto& item : stats) { 602 for (const auto& item : stats) {
603 scoped_ptr<base::DictionaryValue> stat(new base::DictionaryValue); 603 scoped_ptr<base::DictionaryValue> stat(new base::DictionaryValue);
604 stat->SetIntegerWithoutPathExpansion("count", item.count); 604 stat->SetIntegerWithoutPathExpansion("count", item.count);
605 stat->SetBooleanWithoutPathExpansion("success", item.success); 605 stat->SetBooleanWithoutPathExpansion("success", item.success);
606 return_value.SetWithoutPathExpansion(item.category, std::move(stat)); 606 return_value.SetWithoutPathExpansion(item.category, std::move(stat));
607 stats_success &= item.success; 607 stats_success &= item.success;
608 } 608 }
609 if (stats_success) { 609 if (stats_success) {
610 web_ui()->CallJavascriptFunction("updateRemoveWarningDialog", 610 web_ui()->CallJavascriptFunction("updateRemoveWarningDialog",
611 base::StringValue(profile_path.value()), 611 base::StringValue(profile_path.value()),
612 return_value); 612 return_value);
613 return; 613 return;
614 } 614 }
615 } 615 }
616 616
617 profiles::GatherProfileStatistics( 617 ProfileStatistics::GatherProfileStatistics(
618 profile, 618 profile,
619 base::Bind( 619 base::Bind(
620 &UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback, 620 &UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback,
621 weak_ptr_factory_.GetWeakPtr(), profile_path), 621 weak_ptr_factory_.GetWeakPtr(), profile_path));
622 &tracker_);
623 } 622 }
624 623
625 void UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback( 624 void UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback(
626 base::FilePath profile_path, 625 base::FilePath profile_path,
627 profiles::ProfileCategoryStats result) { 626 profiles::ProfileCategoryStats result) {
628 // Copy result into return_value. 627 // Copy result into return_value.
629 base::DictionaryValue return_value; 628 base::DictionaryValue return_value;
630 for (const auto& item : result) { 629 for (const auto& item : result) {
631 scoped_ptr<base::DictionaryValue> stat(new base::DictionaryValue); 630 scoped_ptr<base::DictionaryValue> stat(new base::DictionaryValue);
632 stat->SetIntegerWithoutPathExpansion("count", item.count); 631 stat->SetIntegerWithoutPathExpansion("count", item.count);
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 profile_value->SetBoolean( 901 profile_value->SetBoolean(
903 kKeyHasLocalCreds, 902 kKeyHasLocalCreds,
904 !info_cache->GetLocalAuthCredentialsOfProfileAtIndex(i).empty()); 903 !info_cache->GetLocalAuthCredentialsOfProfileAtIndex(i).empty());
905 profile_value->SetBoolean(kKeyIsOwner, false); 904 profile_value->SetBoolean(kKeyIsOwner, false);
906 profile_value->SetBoolean(kKeyCanRemove, can_remove); 905 profile_value->SetBoolean(kKeyCanRemove, can_remove);
907 profile_value->SetBoolean(kKeyIsDesktop, true); 906 profile_value->SetBoolean(kKeyIsDesktop, true);
908 profile_value->SetString( 907 profile_value->SetString(
909 kKeyAvatarUrl, GetAvatarImageAtIndex(i, info_cache)); 908 kKeyAvatarUrl, GetAvatarImageAtIndex(i, info_cache));
910 909
911 profiles::ProfileCategoryStats stats = 910 profiles::ProfileCategoryStats stats =
912 profiles::GetProfileStatisticsFromCache(profile_path); 911 ProfileStatistics::GetProfileStatisticsFromCache(profile_path);
913 scoped_ptr<base::DictionaryValue> stats_dict(new base::DictionaryValue); 912 scoped_ptr<base::DictionaryValue> stats_dict(new base::DictionaryValue);
914 for (const auto& item : stats) { 913 for (const auto& item : stats) {
915 scoped_ptr<base::DictionaryValue> stat(new base::DictionaryValue); 914 scoped_ptr<base::DictionaryValue> stat(new base::DictionaryValue);
916 stat->SetIntegerWithoutPathExpansion("count", item.count); 915 stat->SetIntegerWithoutPathExpansion("count", item.count);
917 stat->SetBooleanWithoutPathExpansion("success", item.success); 916 stat->SetBooleanWithoutPathExpansion("success", item.success);
918 stats_dict->SetWithoutPathExpansion(item.category, std::move(stat)); 917 stats_dict->SetWithoutPathExpansion(item.category, std::move(stat));
919 } 918 }
920 profile_value->SetWithoutPathExpansion(kKeyStatistics, 919 profile_value->SetWithoutPathExpansion(kKeyStatistics,
921 std::move(stats_dict)); 920 std::move(stats_dict));
922 921
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 Profile* profile, Profile::CreateStatus profile_create_status) { 1015 Profile* profile, Profile::CreateStatus profile_create_status) {
1017 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_); 1016 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_);
1018 if (browser && browser->window()) { 1017 if (browser && browser->window()) {
1019 OnBrowserWindowReady(browser); 1018 OnBrowserWindowReady(browser);
1020 } else { 1019 } else {
1021 registrar_.Add(this, 1020 registrar_.Add(this,
1022 chrome::NOTIFICATION_BROWSER_WINDOW_READY, 1021 chrome::NOTIFICATION_BROWSER_WINDOW_READY,
1023 content::NotificationService::AllSources()); 1022 content::NotificationService::AllSources());
1024 } 1023 }
1025 } 1024 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698