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

Side by Side Diff: chrome/browser/media_galleries/media_folder_finder.h

Issue 173853007: Media Galleries: Prune uninteresting folders when scanning. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
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 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FOLDER_FINDER_H_ 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FOLDER_FINDER_H_
6 #define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FOLDER_FINDER_H_ 6 #define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FOLDER_FINDER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/sequenced_task_runner.h" 15 #include "base/sequenced_task_runner.h"
16 #include "chrome/browser/media_galleries/media_scan_types.h" 16 #include "chrome/browser/media_galleries/media_scan_types.h"
17 17
18 // MediaFolderFinder scans local hard drives and look for folders that contain 18 // MediaFolderFinder scans local hard drives and look for folders that contain
19 // media files. 19 // media files.
20 class MediaFolderFinder { 20 class MediaFolderFinder {
21 public: 21 public:
22 // Key: path to a folder
23 // Value: scan results for that folder, non-recursive.
22 typedef std::map<base::FilePath, MediaGalleryScanResult> 24 typedef std::map<base::FilePath, MediaGalleryScanResult>
23 MediaFolderFinderResults; 25 MediaFolderFinderResults;
24 typedef base::Callback<void(bool /*success*/, 26
25 const MediaFolderFinderResults& /*results*/)> 27 // |results| never contains entries for |sensitive_locations| or parent
28 // directories of |sensitive_locations|.
29 typedef base::Callback<
30 void(bool /*success*/,
31 const MediaFolderFinderResults& /*results*/,
32 const std::vector<base::FilePath>& /*sensitive_locations*/)>
vandebo (ex-Chrome) 2014/02/20 23:00:23 No reason to make this part of the result callback
Lei Zhang 2014/02/25 01:24:25 Done.
26 MediaFolderFinderResultsCallback; 33 MediaFolderFinderResultsCallback;
27 34
28 // |callback| will get called when the scan finishes. If the object is deleted 35 // |callback| will get called when the scan finishes. If the object is deleted
29 // before it finishes, the scan will stop and |callback| will get called with 36 // before it finishes, the scan will stop and |callback| will get called with
30 // success = false. 37 // success = false.
31 // MediaFolderFinder has a default set of per-platform paths to scan. 38 // MediaFolderFinder has a default set of per-platform paths to scan.
32 // Override in tests with SetRootsForTesting(). 39 // Override in tests with SetRootsForTesting().
33 explicit MediaFolderFinder(const MediaFolderFinderResultsCallback& callback); 40 explicit MediaFolderFinder(const MediaFolderFinderResultsCallback& callback);
34 virtual ~MediaFolderFinder(); 41 virtual ~MediaFolderFinder();
35 42
(...skipping 24 matching lines...) Expand all
60 67
61 // Scan a folder from |folders_to_scan_|. 68 // Scan a folder from |folders_to_scan_|.
62 void ScanFolder(); 69 void ScanFolder();
63 70
64 // Callback that handles the |reply| from |worker_| for a scanned |path|. 71 // Callback that handles the |reply| from |worker_| for a scanned |path|.
65 void GotScanResults(const base::FilePath& path, const WorkerReply& reply); 72 void GotScanResults(const base::FilePath& path, const WorkerReply& reply);
66 73
67 const MediaFolderFinderResultsCallback results_callback_; 74 const MediaFolderFinderResultsCallback results_callback_;
68 MediaFolderFinderResults results_; 75 MediaFolderFinderResults results_;
69 76
77 std::vector<base::FilePath> graylisted_folders_;
70 std::vector<base::FilePath> folders_to_scan_; 78 std::vector<base::FilePath> folders_to_scan_;
71 ScanState scan_state_; 79 ScanState scan_state_;
72 80
73 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_; 81 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
74 82
75 // Owned by MediaFolderFinder, but lives on |worker_task_runner_|. 83 // Owned by MediaFolderFinder, but lives on |worker_task_runner_|.
76 Worker* worker_; 84 Worker* worker_;
77 85
78 // Set of roots to scan for testing. 86 // Set of roots to scan for testing.
79 bool has_roots_for_testing_; 87 bool has_roots_for_testing_;
80 std::vector<base::FilePath> roots_for_testing_; 88 std::vector<base::FilePath> roots_for_testing_;
81 89
82 base::WeakPtrFactory<MediaFolderFinder> weak_factory_; 90 base::WeakPtrFactory<MediaFolderFinder> weak_factory_;
83 91
84 DISALLOW_COPY_AND_ASSIGN(MediaFolderFinder); 92 DISALLOW_COPY_AND_ASSIGN(MediaFolderFinder);
85 }; 93 };
86 94
87 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FOLDER_FINDER_H_ 95 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FOLDER_FINDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698