Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/chromeos/login/user_image_manager_impl.h" | 5 #include "chrome/browser/chromeos/login/user_image_manager_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 637 DCHECK_EQ(downloader, profile_image_downloader.get()); | 637 DCHECK_EQ(downloader, profile_image_downloader.get()); |
| 638 | 638 |
| 639 UserManager* user_manager = UserManager::Get(); | 639 UserManager* user_manager = UserManager::Get(); |
| 640 const User* user = user_manager->GetLoggedInUser(); | 640 const User* user = user_manager->GetLoggedInUser(); |
| 641 | 641 |
| 642 if (!downloader->GetProfileFullName().empty()) { | 642 if (!downloader->GetProfileFullName().empty()) { |
| 643 user_manager->SaveUserDisplayName( | 643 user_manager->SaveUserDisplayName( |
| 644 user->email(), downloader->GetProfileFullName()); | 644 user->email(), downloader->GetProfileFullName()); |
| 645 } | 645 } |
| 646 | 646 |
| 647 ProfileManager::GetDefaultProfile()-> | |
| 648 SetGPlusProfileLocale(downloader->GetProfileLocale()); | |
|
Nikita (slow)
2013/08/26 09:26:13
nit: SetGPlusProfileLocale - this method needs to
Alexander Alekseev
2013/09/06 19:52:08
Done.
| |
| 649 | |
| 647 bool requested_image = downloading_profile_image_; | 650 bool requested_image = downloading_profile_image_; |
| 648 downloading_profile_image_ = false; | 651 downloading_profile_image_ = false; |
| 649 if (!requested_image) | 652 if (!requested_image) |
| 650 return; | 653 return; |
| 651 | 654 |
| 652 ProfileDownloadResult result = kDownloadFailure; | 655 ProfileDownloadResult result = kDownloadFailure; |
| 653 switch (downloader->GetProfilePictureStatus()) { | 656 switch (downloader->GetProfilePictureStatus()) { |
| 654 case ProfileDownloader::PICTURE_SUCCESS: | 657 case ProfileDownloader::PICTURE_SUCCESS: |
| 655 result = kDownloadSuccess; | 658 result = kDownloadSuccess; |
| 656 break; | 659 break; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 716 profile_image_downloader_.reset(); | 719 profile_image_downloader_.reset(); |
| 717 | 720 |
| 718 UMA_HISTOGRAM_ENUMERATION("UserImage.ProfileDownloadResult", | 721 UMA_HISTOGRAM_ENUMERATION("UserImage.ProfileDownloadResult", |
| 719 kDownloadFailure, kDownloadResultsCount); | 722 kDownloadFailure, kDownloadResultsCount); |
| 720 | 723 |
| 721 DCHECK(!profile_image_load_start_time_.is_null()); | 724 DCHECK(!profile_image_load_start_time_.is_null()); |
| 722 base::TimeDelta delta = base::Time::Now() - profile_image_load_start_time_; | 725 base::TimeDelta delta = base::Time::Now() - profile_image_load_start_time_; |
| 723 AddProfileImageTimeHistogram(kDownloadFailure, profile_image_download_reason_, | 726 AddProfileImageTimeHistogram(kDownloadFailure, profile_image_download_reason_, |
| 724 delta); | 727 delta); |
| 725 | 728 |
| 729 ProfileManager::GetDefaultProfile()-> | |
| 730 SetGPlusProfileLocale(downloader->GetProfileLocale()); | |
|
Nikita (slow)
2013/08/26 09:26:13
Should this really be called in failure case?
Alexander Alekseev
2013/09/06 19:52:08
Yes. I've commented it in the new patch set.
| |
| 731 | |
| 726 // Retry download after some time if a network error has occured. | 732 // Retry download after some time if a network error has occured. |
| 727 if (reason == ProfileDownloaderDelegate::NETWORK_ERROR) { | 733 if (reason == ProfileDownloaderDelegate::NETWORK_ERROR) { |
| 728 BrowserThread::PostDelayedTask( | 734 BrowserThread::PostDelayedTask( |
| 729 BrowserThread::UI, | 735 BrowserThread::UI, |
| 730 FROM_HERE, | 736 FROM_HERE, |
| 731 base::Bind(&UserImageManagerImpl::DownloadProfileDataRetry, | 737 base::Bind(&UserImageManagerImpl::DownloadProfileDataRetry, |
| 732 base::Unretained(this), | 738 base::Unretained(this), |
| 733 downloading_profile_image_), | 739 downloading_profile_image_), |
| 734 base::TimeDelta::FromSeconds(kProfileDataDownloadRetryIntervalSec)); | 740 base::TimeDelta::FromSeconds(kProfileDataDownloadRetryIntervalSec)); |
| 735 } | 741 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 774 if (prefs_images_update->GetDictionaryWithoutPathExpansion( | 780 if (prefs_images_update->GetDictionaryWithoutPathExpansion( |
| 775 username, &image_properties)) { | 781 username, &image_properties)) { |
| 776 std::string image_path; | 782 std::string image_path; |
| 777 image_properties->GetString(kImagePathNodeName, &image_path); | 783 image_properties->GetString(kImagePathNodeName, &image_path); |
| 778 prefs_images_update->RemoveWithoutPathExpansion(username, NULL); | 784 prefs_images_update->RemoveWithoutPathExpansion(username, NULL); |
| 779 DeleteImageFile(image_path); | 785 DeleteImageFile(image_path); |
| 780 } | 786 } |
| 781 } | 787 } |
| 782 | 788 |
| 783 } // namespace chromeos | 789 } // namespace chromeos |
| OLD | NEW |