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_folder_finder.h" | 5 #include "chrome/browser/media_galleries/media_folder_finder.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <algorithm> | 10 #include <algorithm> |
8 #include <set> | 11 #include <set> |
9 | 12 |
10 #include "base/files/file_enumerator.h" | 13 #include "base/files/file_enumerator.h" |
11 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 15 #include "base/macros.h" |
12 #include "base/path_service.h" | 16 #include "base/path_service.h" |
13 #include "base/sequence_checker.h" | 17 #include "base/sequence_checker.h" |
14 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
15 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
16 #include "base/task_runner_util.h" | 20 #include "base/task_runner_util.h" |
17 #include "base/threading/sequenced_worker_pool.h" | 21 #include "base/threading/sequenced_worker_pool.h" |
| 22 #include "build/build_config.h" |
18 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 23 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
19 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" | 24 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" |
20 #include "chrome/common/chrome_paths.h" | 25 #include "chrome/common/chrome_paths.h" |
21 #include "components/storage_monitor/storage_monitor.h" | 26 #include "components/storage_monitor/storage_monitor.h" |
22 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
23 | 28 |
24 #if defined(OS_CHROMEOS) | 29 #if defined(OS_CHROMEOS) |
25 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
26 #include "chromeos/dbus/cros_disks_client.h" | 31 #include "chromeos/dbus/cros_disks_client.h" |
27 #endif | 32 #endif |
28 | 33 |
29 using storage_monitor::StorageInfo; | 34 using storage_monitor::StorageInfo; |
30 using storage_monitor::StorageMonitor; | 35 using storage_monitor::StorageMonitor; |
31 | 36 |
32 typedef base::Callback<void(const std::vector<base::FilePath>& /*roots*/)> | 37 typedef base::Callback<void(const std::vector<base::FilePath>& /*roots*/)> |
33 DefaultScanRootsCallback; | 38 DefaultScanRootsCallback; |
34 using content::BrowserThread; | 39 using content::BrowserThread; |
35 | 40 |
36 namespace { | 41 namespace { |
37 | 42 |
38 const int64 kMinimumImageSize = 200 * 1024; // 200 KB | 43 const int64_t kMinimumImageSize = 200 * 1024; // 200 KB |
39 const int64 kMinimumAudioSize = 500 * 1024; // 500 KB | 44 const int64_t kMinimumAudioSize = 500 * 1024; // 500 KB |
40 const int64 kMinimumVideoSize = 1024 * 1024; // 1 MB | 45 const int64_t kMinimumVideoSize = 1024 * 1024; // 1 MB |
41 | 46 |
42 const int kPrunedPaths[] = { | 47 const int kPrunedPaths[] = { |
43 #if defined(OS_WIN) | 48 #if defined(OS_WIN) |
44 base::DIR_IE_INTERNET_CACHE, | 49 base::DIR_IE_INTERNET_CACHE, |
45 base::DIR_PROGRAM_FILES, | 50 base::DIR_PROGRAM_FILES, |
46 base::DIR_PROGRAM_FILESX86, | 51 base::DIR_PROGRAM_FILESX86, |
47 base::DIR_WINDOWS, | 52 base::DIR_WINDOWS, |
48 #endif | 53 #endif |
49 #if defined(OS_MACOSX) && !defined(OS_IOS) | 54 #if defined(OS_MACOSX) && !defined(OS_IOS) |
50 chrome::DIR_USER_APPLICATIONS, | 55 chrome::DIR_USER_APPLICATIONS, |
(...skipping 17 matching lines...) Expand all Loading... |
68 void CountScanResult(MediaGalleryScanFileType type, | 73 void CountScanResult(MediaGalleryScanFileType type, |
69 MediaGalleryScanResult* scan_result) { | 74 MediaGalleryScanResult* scan_result) { |
70 if (type & MEDIA_GALLERY_SCAN_FILE_TYPE_IMAGE) | 75 if (type & MEDIA_GALLERY_SCAN_FILE_TYPE_IMAGE) |
71 scan_result->image_count += 1; | 76 scan_result->image_count += 1; |
72 if (type & MEDIA_GALLERY_SCAN_FILE_TYPE_AUDIO) | 77 if (type & MEDIA_GALLERY_SCAN_FILE_TYPE_AUDIO) |
73 scan_result->audio_count += 1; | 78 scan_result->audio_count += 1; |
74 if (type & MEDIA_GALLERY_SCAN_FILE_TYPE_VIDEO) | 79 if (type & MEDIA_GALLERY_SCAN_FILE_TYPE_VIDEO) |
75 scan_result->video_count += 1; | 80 scan_result->video_count += 1; |
76 } | 81 } |
77 | 82 |
78 bool FileMeetsSizeRequirement(MediaGalleryScanFileType type, int64 size) { | 83 bool FileMeetsSizeRequirement(MediaGalleryScanFileType type, int64_t size) { |
79 if (type & MEDIA_GALLERY_SCAN_FILE_TYPE_IMAGE) | 84 if (type & MEDIA_GALLERY_SCAN_FILE_TYPE_IMAGE) |
80 if (size >= kMinimumImageSize) | 85 if (size >= kMinimumImageSize) |
81 return true; | 86 return true; |
82 if (type & MEDIA_GALLERY_SCAN_FILE_TYPE_AUDIO) | 87 if (type & MEDIA_GALLERY_SCAN_FILE_TYPE_AUDIO) |
83 if (size >= kMinimumAudioSize) | 88 if (size >= kMinimumAudioSize) |
84 return true; | 89 return true; |
85 if (type & MEDIA_GALLERY_SCAN_FILE_TYPE_VIDEO) | 90 if (type & MEDIA_GALLERY_SCAN_FILE_TYPE_VIDEO) |
86 if (size >= kMinimumVideoSize) | 91 if (size >= kMinimumVideoSize) |
87 return true; | 92 return true; |
88 return false; | 93 return false; |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 443 |
439 if (!IsEmptyScanResult(reply.scan_result)) | 444 if (!IsEmptyScanResult(reply.scan_result)) |
440 results_[path] = reply.scan_result; | 445 results_[path] = reply.scan_result; |
441 | 446 |
442 // Push new folders to the |folders_to_scan_| in reverse order. | 447 // Push new folders to the |folders_to_scan_| in reverse order. |
443 std::copy(reply.new_folders.rbegin(), reply.new_folders.rend(), | 448 std::copy(reply.new_folders.rbegin(), reply.new_folders.rend(), |
444 std::back_inserter(folders_to_scan_)); | 449 std::back_inserter(folders_to_scan_)); |
445 | 450 |
446 ScanFolder(); | 451 ScanFolder(); |
447 } | 452 } |
OLD | NEW |