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/chromeos/login/user_manager.h" | 5 #include "chrome/browser/chromeos/login/user_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 enum ProfileDownloadResult { | 91 enum ProfileDownloadResult { |
92 kDownloadSuccessChanged, | 92 kDownloadSuccessChanged, |
93 kDownloadSuccess, | 93 kDownloadSuccess, |
94 kDownloadFailure, | 94 kDownloadFailure, |
95 kDownloadDefault, | 95 kDownloadDefault, |
96 | 96 |
97 // Must be the last, convenient count. | 97 // Must be the last, convenient count. |
98 kDownloadResultsCount | 98 kDownloadResultsCount |
99 }; | 99 }; |
100 | 100 |
| 101 // Time histogram name for the default profile image download. |
| 102 const char kProfileDownloadDefaultTime[] = |
| 103 "UserImage.ProfileDownloadDefaultTime"; |
| 104 // Time histogram name for a failed profile image download. |
| 105 const char kProfileDownloadFailureTime[] = |
| 106 "UserImage.ProfileDownloadFailureTime"; |
| 107 // Time histogram name for a successful profile image download. |
| 108 const char ProfileDownloadSuccessTime[] = |
| 109 "UserImage.ProfileDownloadSuccessTime"; |
| 110 |
101 // Used to handle the asynchronous response of deleting a cryptohome directory. | 111 // Used to handle the asynchronous response of deleting a cryptohome directory. |
102 class RemoveAttempt : public CryptohomeLibrary::Delegate { | 112 class RemoveAttempt : public CryptohomeLibrary::Delegate { |
103 public: | 113 public: |
104 // Creates new remove attempt for the given user. Note, |delegate| can | 114 // Creates new remove attempt for the given user. Note, |delegate| can |
105 // be NULL. | 115 // be NULL. |
106 RemoveAttempt(const std::string& user_email, | 116 RemoveAttempt(const std::string& user_email, |
107 chromeos::RemoveUserDelegate* delegate) | 117 chromeos::RemoveUserDelegate* delegate) |
108 : user_email_(user_email), | 118 : user_email_(user_email), |
109 delegate_(delegate), | 119 delegate_(delegate), |
110 weak_factory_(this) { | 120 weak_factory_(this) { |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 if (profile_image_downloader_.get()) { | 476 if (profile_image_downloader_.get()) { |
467 // Another download is already in progress | 477 // Another download is already in progress |
468 return; | 478 return; |
469 } | 479 } |
470 | 480 |
471 if (logged_in_user().email().empty()) { | 481 if (logged_in_user().email().empty()) { |
472 // This is a guest login so there's no profile image to download. | 482 // This is a guest login so there's no profile image to download. |
473 return; | 483 return; |
474 } | 484 } |
475 | 485 |
| 486 profile_image_load_start_time_ = base::Time::Now(); |
476 profile_image_downloader_.reset(new ProfileDownloader(this)); | 487 profile_image_downloader_.reset(new ProfileDownloader(this)); |
477 profile_image_downloader_->Start(); | 488 profile_image_downloader_->Start(); |
478 profile_image_load_start_time_ = base::Time::Now(); | |
479 } | 489 } |
480 | 490 |
481 void UserManager::Observe(int type, | 491 void UserManager::Observe(int type, |
482 const content::NotificationSource& source, | 492 const content::NotificationSource& source, |
483 const content::NotificationDetails& details) { | 493 const content::NotificationDetails& details) { |
484 if (type == chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED) { | 494 if (type == chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED) { |
485 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 495 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
486 base::Bind(&UserManager::CheckOwnership, | 496 base::Bind(&UserManager::CheckOwnership, |
487 base::Unretained(this))); | 497 base::Unretained(this))); |
488 } | 498 } |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 return login::kUserImageSize; | 822 return login::kUserImageSize; |
813 } | 823 } |
814 | 824 |
815 Profile* UserManager::GetBrowserProfile() { | 825 Profile* UserManager::GetBrowserProfile() { |
816 return ProfileManager::GetDefaultProfile(); | 826 return ProfileManager::GetDefaultProfile(); |
817 } | 827 } |
818 | 828 |
819 void UserManager::OnDownloadComplete(ProfileDownloader* downloader, | 829 void UserManager::OnDownloadComplete(ProfileDownloader* downloader, |
820 bool success) { | 830 bool success) { |
821 ProfileDownloadResult result; | 831 ProfileDownloadResult result; |
822 if (!success) | 832 std::string time_histogram_name; |
| 833 if (!success) { |
823 result = kDownloadFailure; | 834 result = kDownloadFailure; |
824 else if (downloader->GetProfilePicture().isNull()) | 835 time_histogram_name = kProfileDownloadFailureTime; |
| 836 } else if (downloader->GetProfilePicture().isNull()) { |
825 result = kDownloadDefault; | 837 result = kDownloadDefault; |
826 else | 838 time_histogram_name = kProfileDownloadDefaultTime; |
| 839 } else { |
827 result = kDownloadSuccess; | 840 result = kDownloadSuccess; |
| 841 time_histogram_name = ProfileDownloadSuccessTime; |
| 842 } |
| 843 |
828 UMA_HISTOGRAM_ENUMERATION("UserImage.ProfileDownloadResult", | 844 UMA_HISTOGRAM_ENUMERATION("UserImage.ProfileDownloadResult", |
829 result, kDownloadResultsCount); | 845 result, kDownloadResultsCount); |
830 | 846 |
| 847 DCHECK(!profile_image_load_start_time_.is_null()); |
| 848 base::TimeDelta delta = base::Time::Now() - profile_image_load_start_time_; |
| 849 VLOG(1) << "Profile image download time: " << delta.InSecondsF(); |
| 850 UMA_HISTOGRAM_TIMES(time_histogram_name, delta); |
| 851 |
831 if (result == kDownloadSuccess) { | 852 if (result == kDownloadSuccess) { |
832 // Check if this image is not the same as already downloaded. | 853 // Check if this image is not the same as already downloaded. |
833 std::string new_image_data_url = | 854 std::string new_image_data_url = |
834 web_ui_util::GetImageDataUrl(downloader->GetProfilePicture()); | 855 web_ui_util::GetImageDataUrl(downloader->GetProfilePicture()); |
835 if (!downloaded_profile_image_data_url_.empty() && | 856 if (!downloaded_profile_image_data_url_.empty() && |
836 new_image_data_url == downloaded_profile_image_data_url_) | 857 new_image_data_url == downloaded_profile_image_data_url_) |
837 return; | 858 return; |
838 | 859 |
839 downloaded_profile_image_data_url_ = new_image_data_url; | 860 downloaded_profile_image_data_url_ = new_image_data_url; |
840 downloaded_profile_image_ = downloader->GetProfilePicture(); | 861 downloaded_profile_image_ = downloader->GetProfilePicture(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 | 893 |
873 User* UserManager::CreateUser(const std::string& email) const { | 894 User* UserManager::CreateUser(const std::string& email) const { |
874 User* user = new User(email); | 895 User* user = new User(email); |
875 user->set_oauth_token_status(GetUserOAuthStatus(email)); | 896 user->set_oauth_token_status(GetUserOAuthStatus(email)); |
876 // Used to determine whether user's display name is unique. | 897 // Used to determine whether user's display name is unique. |
877 ++display_name_count_[user->GetDisplayName()]; | 898 ++display_name_count_[user->GetDisplayName()]; |
878 return user; | 899 return user; |
879 } | 900 } |
880 | 901 |
881 } // namespace chromeos | 902 } // namespace chromeos |
OLD | NEW |