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

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

Issue 1695563002: Media Galleries Partial Deprecation: Remove scan functionality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FOLDER_FINDER_H_
6 #define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FOLDER_FINDER_H_
7
8 #include <map>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "base/files/file_path.h"
13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h"
16 #include "base/sequenced_task_runner.h"
17 #include "chrome/browser/media_galleries/media_scan_types.h"
18
19 // MediaFolderFinder scans local hard drives and look for folders that contain
20 // media files.
21 class MediaFolderFinder {
22 public:
23 // Key: path to a folder
24 // Value: scan results for that folder, non-recursive.
25 typedef std::map<base::FilePath, MediaGalleryScanResult>
26 MediaFolderFinderResults;
27
28 // |results| never contains entries for |graylisted_folders_| or parent
29 // directories of |graylisted_folders_|.
30 typedef base::Callback<void(bool /*success*/,
31 const MediaFolderFinderResults& /*results*/)>
32 MediaFolderFinderResultsCallback;
33
34 // |callback| will get called when the scan finishes. If the object is deleted
35 // before it finishes, the scan will stop and |callback| will get called with
36 // success = false.
37 // MediaFolderFinder has a default set of per-platform paths to scan.
38 // Override in tests with SetRootsForTesting().
39 explicit MediaFolderFinder(const MediaFolderFinderResultsCallback& callback);
40 virtual ~MediaFolderFinder();
41
42 // Start the scan.
43 virtual void StartScan();
44
45 const std::vector<base::FilePath>& graylisted_folders() const;
46
47 private:
48 friend class MediaFolderFinderTest;
49 friend class MediaGalleriesPlatformAppBrowserTest;
50
51 class Worker;
52 struct WorkerReply {
53 WorkerReply();
54 WorkerReply(const WorkerReply& other);
55 ~WorkerReply();
56
57 MediaGalleryScanResult scan_result;
58 std::vector<base::FilePath> new_folders;
59 };
60
61 enum ScanState {
62 SCAN_STATE_NOT_STARTED,
63 SCAN_STATE_STARTED,
64 SCAN_STATE_FINISHED,
65 };
66
67 void SetRootsForTesting(const std::vector<base::FilePath>& roots);
68
69 void OnInitialized(const std::vector<base::FilePath>& roots);
70
71 // Scan a folder from |folders_to_scan_|.
72 void ScanFolder();
73
74 // Callback that handles the |reply| from |worker_| for a scanned |path|.
75 void GotScanResults(const base::FilePath& path, const WorkerReply& reply);
76
77 const MediaFolderFinderResultsCallback results_callback_;
78 MediaFolderFinderResults results_;
79
80 std::vector<base::FilePath> graylisted_folders_;
81 std::vector<base::FilePath> folders_to_scan_;
82 ScanState scan_state_;
83
84 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
85
86 // Owned by MediaFolderFinder, but lives on |worker_task_runner_|.
87 Worker* worker_;
88
89 // Set of roots to scan for testing.
90 bool has_roots_for_testing_;
91 std::vector<base::FilePath> roots_for_testing_;
92
93 base::WeakPtrFactory<MediaFolderFinder> weak_factory_;
94
95 DISALLOW_COPY_AND_ASSIGN(MediaFolderFinder);
96 };
97
98 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FOLDER_FINDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/media_galleries/media_file_system_registry.cc ('k') | chrome/browser/media_galleries/media_folder_finder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698