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 "chrome/browser/media_galleries/media_scan_manager.h" | 5 #include "chrome/browser/media_galleries/media_scan_manager.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // Updating prefs while iterating them will invalidate the pointer, so | 153 // Updating prefs while iterating them will invalidate the pointer, so |
154 // calculate the changes first and then apply them. | 154 // calculate the changes first and then apply them. |
155 std::map<MediaGalleryPrefId, MediaGalleryScanResult> to_update; | 155 std::map<MediaGalleryPrefId, MediaGalleryScanResult> to_update; |
156 for (MediaGalleriesPrefInfoMap::const_iterator it = known_galleries.begin(); | 156 for (MediaGalleriesPrefInfoMap::const_iterator it = known_galleries.begin(); |
157 it != known_galleries.end(); | 157 it != known_galleries.end(); |
158 ++it) { | 158 ++it) { |
159 const MediaGalleryPrefInfo& gallery = it->second; | 159 const MediaGalleryPrefInfo& gallery = it->second; |
160 if (!gallery.IsBlackListedType()) { | 160 if (!gallery.IsBlackListedType()) { |
161 MediaGalleryScanResult file_counts = | 161 MediaGalleryScanResult file_counts = |
162 SumFilesUnderPath(gallery.AbsolutePath(), child_folders); | 162 SumFilesUnderPath(gallery.AbsolutePath(), child_folders); |
163 if (!IsEmptyScanResult(file_counts) && !gallery.IsBlackListedType()) { | 163 if (gallery.audio_count != file_counts.audio_count || |
| 164 gallery.image_count != file_counts.image_count || |
| 165 gallery.video_count != file_counts.video_count) { |
164 to_update[it->first] = file_counts; | 166 to_update[it->first] = file_counts; |
165 } | 167 } |
166 } | 168 } |
167 } | 169 } |
168 | 170 |
169 for (std::map<MediaGalleryPrefId, | 171 for (std::map<MediaGalleryPrefId, |
170 MediaGalleryScanResult>::const_iterator it = to_update.begin(); | 172 MediaGalleryScanResult>::const_iterator it = to_update.begin(); |
171 it != to_update.end(); | 173 it != to_update.end(); |
172 ++it) { | 174 ++it) { |
173 const MediaGalleryPrefInfo& gallery = | 175 const MediaGalleryPrefInfo& gallery = |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 gallery_count, | 489 gallery_count, |
488 file_counts); | 490 file_counts); |
489 } | 491 } |
490 } | 492 } |
491 scanning_extensions->clear(); | 493 scanning_extensions->clear(); |
492 preferences->SetLastScanCompletionTime(base::Time::Now()); | 494 preferences->SetLastScanCompletionTime(base::Time::Now()); |
493 } | 495 } |
494 registrar_.RemoveAll(); | 496 registrar_.RemoveAll(); |
495 folder_finder_.reset(); | 497 folder_finder_.reset(); |
496 } | 498 } |
OLD | NEW |