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

Side by Side Diff: components/wallpaper/wallpaper_manager_base.cc

Issue 1004933003: favor DCHECK_CURRENTLY_ON for better logs in components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « components/storage_monitor/volume_mount_watcher_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/wallpaper/wallpaper_manager_base.h" 5 #include "components/wallpaper/wallpaper_manager_base.h"
6 6
7 #include <numeric> 7 #include <numeric>
8 #include <vector> 8 #include <vector>
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 for (CustomWallpaperMap::iterator it = wallpaper_cache_.begin(); 337 for (CustomWallpaperMap::iterator it = wallpaper_cache_.begin();
338 it != wallpaper_cache_.end(); ++it) { 338 it != wallpaper_cache_.end(); ++it) {
339 if (logged_in_users_names.find(it->first) != logged_in_users_names.end()) { 339 if (logged_in_users_names.find(it->first) != logged_in_users_names.end()) {
340 logged_in_users_cache.insert(*it); 340 logged_in_users_cache.insert(*it);
341 } 341 }
342 } 342 }
343 wallpaper_cache_ = logged_in_users_cache; 343 wallpaper_cache_ = logged_in_users_cache;
344 } 344 }
345 345
346 bool WallpaperManagerBase::GetLoggedInUserWallpaperInfo(WallpaperInfo* info) { 346 bool WallpaperManagerBase::GetLoggedInUserWallpaperInfo(WallpaperInfo* info) {
347 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 347 DCHECK_CURRENTLY_ON(BrowserThread::UI);
348 348
349 if (user_manager::UserManager::Get()->IsLoggedInAsStub()) { 349 if (user_manager::UserManager::Get()->IsLoggedInAsStub()) {
350 info->location = current_user_wallpaper_info_.location = ""; 350 info->location = current_user_wallpaper_info_.location = "";
351 info->layout = current_user_wallpaper_info_.layout = 351 info->layout = current_user_wallpaper_info_.layout =
352 WALLPAPER_LAYOUT_CENTER_CROPPED; 352 WALLPAPER_LAYOUT_CENTER_CROPPED;
353 info->type = current_user_wallpaper_info_.type = 353 info->type = current_user_wallpaper_info_.type =
354 user_manager::User::DEFAULT; 354 user_manager::User::DEFAULT;
355 info->date = current_user_wallpaper_info_.date = 355 info->date = current_user_wallpaper_info_.date =
356 base::Time::Now().LocalMidnight(); 356 base::Time::Now().LocalMidnight();
357 return true; 357 return true;
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 676
677 void WallpaperManagerBase::NotifyAnimationFinished() { 677 void WallpaperManagerBase::NotifyAnimationFinished() {
678 FOR_EACH_OBSERVER(Observer, observers_, 678 FOR_EACH_OBSERVER(Observer, observers_,
679 OnWallpaperAnimationFinished(last_selected_user_)); 679 OnWallpaperAnimationFinished(last_selected_user_));
680 } 680 }
681 681
682 // WallpaperManager, protected: ----------------------------------------------- 682 // WallpaperManager, protected: -----------------------------------------------
683 683
684 bool WallpaperManagerBase::GetWallpaperFromCache(const std::string& user_id, 684 bool WallpaperManagerBase::GetWallpaperFromCache(const std::string& user_id,
685 gfx::ImageSkia* image) { 685 gfx::ImageSkia* image) {
686 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 686 DCHECK_CURRENTLY_ON(BrowserThread::UI);
687 CustomWallpaperMap::const_iterator it = wallpaper_cache_.find(user_id); 687 CustomWallpaperMap::const_iterator it = wallpaper_cache_.find(user_id);
688 if (it != wallpaper_cache_.end() && !(*it).second.second.isNull()) { 688 if (it != wallpaper_cache_.end() && !(*it).second.second.isNull()) {
689 *image = (*it).second.second; 689 *image = (*it).second.second;
690 return true; 690 return true;
691 } 691 }
692 return false; 692 return false;
693 } 693 }
694 694
695 bool WallpaperManagerBase::GetPathFromCache(const std::string& user_id, 695 bool WallpaperManagerBase::GetPathFromCache(const std::string& user_id,
696 base::FilePath* path) { 696 base::FilePath* path) {
697 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 697 DCHECK_CURRENTLY_ON(BrowserThread::UI);
698 CustomWallpaperMap::const_iterator it = wallpaper_cache_.find(user_id); 698 CustomWallpaperMap::const_iterator it = wallpaper_cache_.find(user_id);
699 if (it != wallpaper_cache_.end()) { 699 if (it != wallpaper_cache_.end()) {
700 *path = (*it).second.first; 700 *path = (*it).second.first;
701 return true; 701 return true;
702 } 702 }
703 return false; 703 return false;
704 } 704 }
705 705
706 int WallpaperManagerBase::loaded_wallpapers_for_test() const { 706 int WallpaperManagerBase::loaded_wallpapers_for_test() const {
707 return loaded_wallpapers_for_test_; 707 return loaded_wallpapers_for_test_;
708 } 708 }
709 709
710 void WallpaperManagerBase::CacheUsersWallpapers() { 710 void WallpaperManagerBase::CacheUsersWallpapers() {
711 // TODO(dpolukhin): crbug.com/408734. 711 // TODO(dpolukhin): crbug.com/408734.
712 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 712 DCHECK_CURRENTLY_ON(BrowserThread::UI);
713 user_manager::UserList users = user_manager::UserManager::Get()->GetUsers(); 713 user_manager::UserList users = user_manager::UserManager::Get()->GetUsers();
714 714
715 if (!users.empty()) { 715 if (!users.empty()) {
716 user_manager::UserList::const_iterator it = users.begin(); 716 user_manager::UserList::const_iterator it = users.begin();
717 // Skip the wallpaper of first user in the list. It should have been cached. 717 // Skip the wallpaper of first user in the list. It should have been cached.
718 it++; 718 it++;
719 for (int cached = 0; it != users.end() && cached < kMaxWallpapersToCache; 719 for (int cached = 0; it != users.end() && cached < kMaxWallpapersToCache;
720 ++it, ++cached) { 720 ++it, ++cached) {
721 std::string user_id = (*it)->email(); 721 std::string user_id = (*it)->email();
722 CacheUserWallpaper(user_id); 722 CacheUserWallpaper(user_id);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 else if (interval > base::TimeDelta::FromMilliseconds(0)) 936 else if (interval > base::TimeDelta::FromMilliseconds(0))
937 delay -= interval; 937 delay -= interval;
938 } 938 }
939 return delay; 939 return delay;
940 } 940 }
941 941
942 void WallpaperManagerBase::OnCustomizedDefaultWallpaperDecoded( 942 void WallpaperManagerBase::OnCustomizedDefaultWallpaperDecoded(
943 const GURL& wallpaper_url, 943 const GURL& wallpaper_url,
944 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files, 944 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files,
945 const user_manager::UserImage& wallpaper) { 945 const user_manager::UserImage& wallpaper) {
946 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 946 DCHECK_CURRENTLY_ON(BrowserThread::UI);
947 947
948 // If decoded wallpaper is empty, we have probably failed to decode the file. 948 // If decoded wallpaper is empty, we have probably failed to decode the file.
949 if (wallpaper.image().isNull()) { 949 if (wallpaper.image().isNull()) {
950 LOG(WARNING) << "Failed to decode customized wallpaper."; 950 LOG(WARNING) << "Failed to decode customized wallpaper.";
951 return; 951 return;
952 } 952 }
953 953
954 wallpaper.image().EnsureRepsForSupportedScales(); 954 wallpaper.image().EnsureRepsForSupportedScales();
955 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.image().DeepCopy()); 955 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.image().DeepCopy());
956 956
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 void WallpaperManagerBase::CreateSolidDefaultWallpaper() { 1055 void WallpaperManagerBase::CreateSolidDefaultWallpaper() {
1056 loaded_wallpapers_for_test_++; 1056 loaded_wallpapers_for_test_++;
1057 SkBitmap bitmap; 1057 SkBitmap bitmap;
1058 bitmap.allocN32Pixels(1, 1); 1058 bitmap.allocN32Pixels(1, 1);
1059 bitmap.eraseColor(kDefaultWallpaperColor); 1059 bitmap.eraseColor(kDefaultWallpaperColor);
1060 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); 1060 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
1061 default_wallpaper_image_.reset(new user_manager::UserImage(image)); 1061 default_wallpaper_image_.reset(new user_manager::UserImage(image));
1062 } 1062 }
1063 1063
1064 } // namespace wallpaper 1064 } // namespace wallpaper
OLDNEW
« no previous file with comments | « components/storage_monitor/volume_mount_watcher_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698