OLD | NEW |
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" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/lazy_instance.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
15 #include "base/path_service.h" | 16 #include "base/path_service.h" |
16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
18 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
19 #include "base/sys_info.h" | 20 #include "base/sys_info.h" |
20 #include "base/threading/worker_pool.h" | 21 #include "base/threading/worker_pool.h" |
21 #include "base/time/time.h" | 22 #include "base/time/time.h" |
22 #include "base/values.h" | 23 #include "base/values.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // Default wallpaper load delay, milliseconds. | 57 // Default wallpaper load delay, milliseconds. |
57 const unsigned kLoadDefaultDelayMs = 200; | 58 const unsigned kLoadDefaultDelayMs = 200; |
58 | 59 |
59 // Maximum wallpaper load delay, milliseconds. | 60 // Maximum wallpaper load delay, milliseconds. |
60 const unsigned kLoadMaxDelayMs = 2000; | 61 const unsigned kLoadMaxDelayMs = 2000; |
61 | 62 |
62 // When no wallpaper image is specified, the screen is filled with a solid | 63 // When no wallpaper image is specified, the screen is filled with a solid |
63 // color. | 64 // color. |
64 const SkColor kDefaultWallpaperColor = SK_ColorGRAY; | 65 const SkColor kDefaultWallpaperColor = SK_ColorGRAY; |
65 | 66 |
| 67 #if DCHECK_IS_ON() |
| 68 base::LazyInstance<base::SequenceChecker>::Leaky g_wallpaper_sequence_checker = |
| 69 LAZY_INSTANCE_INITIALIZER; |
| 70 #endif |
| 71 |
66 // The path ids for directories. | 72 // The path ids for directories. |
67 int dir_user_data_path_id = -1; // chrome::DIR_USER_DATA | 73 int dir_user_data_path_id = -1; // chrome::DIR_USER_DATA |
68 int dir_chromeos_wallpapers_path_id = -1; // chrome::DIR_CHROMEOS_WALLPAPERS | 74 int dir_chromeos_wallpapers_path_id = -1; // chrome::DIR_CHROMEOS_WALLPAPERS |
69 int dir_chromeos_custom_wallpapers_path_id = | 75 int dir_chromeos_custom_wallpapers_path_id = |
70 -1; // chrome::DIR_CHROMEOS_CUSTOM_WALLPAPERS | 76 -1; // chrome::DIR_CHROMEOS_CUSTOM_WALLPAPERS |
71 | 77 |
72 bool MoveCustomWallpaperDirectory(const char* sub_dir, | 78 bool MoveCustomWallpaperDirectory(const char* sub_dir, |
73 const std::string& from_name, | 79 const std::string& from_name, |
74 const std::string& to_name) { | 80 const std::string& to_name) { |
75 base::FilePath base_path = | 81 base::FilePath base_path = |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 const base::Time& in_date) | 157 const base::Time& in_date) |
152 : location(in_location), | 158 : location(in_location), |
153 layout(in_layout), | 159 layout(in_layout), |
154 type(in_type), | 160 type(in_type), |
155 date(in_date) { | 161 date(in_date) { |
156 } | 162 } |
157 | 163 |
158 WallpaperInfo::~WallpaperInfo() { | 164 WallpaperInfo::~WallpaperInfo() { |
159 } | 165 } |
160 | 166 |
| 167 void AssertCalledOnWallpaperSequence() { |
| 168 #if DCHECK_IS_ON() |
| 169 DCHECK(g_wallpaper_sequence_checker.Get().CalledOnValidSequence()); |
| 170 #endif |
| 171 } |
| 172 |
161 const char kWallpaperSequenceTokenName[] = "wallpaper-sequence"; | 173 const char kWallpaperSequenceTokenName[] = "wallpaper-sequence"; |
162 | 174 |
163 const char kSmallWallpaperSuffix[] = "_small"; | 175 const char kSmallWallpaperSuffix[] = "_small"; |
164 const char kLargeWallpaperSuffix[] = "_large"; | 176 const char kLargeWallpaperSuffix[] = "_large"; |
165 | 177 |
166 const char kSmallWallpaperSubDir[] = "small"; | 178 const char kSmallWallpaperSubDir[] = "small"; |
167 const char kLargeWallpaperSubDir[] = "large"; | 179 const char kLargeWallpaperSubDir[] = "large"; |
168 const char kOriginalWallpaperSubDir[] = "original"; | 180 const char kOriginalWallpaperSubDir[] = "original"; |
169 const char kThumbnailWallpaperSubDir[] = "thumb"; | 181 const char kThumbnailWallpaperSubDir[] = "thumb"; |
170 | 182 |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 void WallpaperManagerBase::CreateSolidDefaultWallpaper() { | 1020 void WallpaperManagerBase::CreateSolidDefaultWallpaper() { |
1009 loaded_wallpapers_for_test_++; | 1021 loaded_wallpapers_for_test_++; |
1010 SkBitmap bitmap; | 1022 SkBitmap bitmap; |
1011 bitmap.allocN32Pixels(1, 1); | 1023 bitmap.allocN32Pixels(1, 1); |
1012 bitmap.eraseColor(kDefaultWallpaperColor); | 1024 bitmap.eraseColor(kDefaultWallpaperColor); |
1013 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 1025 const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
1014 default_wallpaper_image_.reset(new user_manager::UserImage(image)); | 1026 default_wallpaper_image_.reset(new user_manager::UserImage(image)); |
1015 } | 1027 } |
1016 | 1028 |
1017 } // namespace wallpaper | 1029 } // namespace wallpaper |
OLD | NEW |