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

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, 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
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();
55
56 MediaGalleryScanResult scan_result;
57 std::vector<base::FilePath> new_folders;
58 };
59
60 enum ScanState {
61 SCAN_STATE_NOT_STARTED,
62 SCAN_STATE_STARTED,
63 SCAN_STATE_FINISHED,
64 };
65
66 void SetRootsForTesting(const std::vector<base::FilePath>& roots);
67
68 void OnInitialized(const std::vector<base::FilePath>& roots);
69
70 // Scan a folder from |folders_to_scan_|.
71 void ScanFolder();
72
73 // Callback that handles the |reply| from |worker_| for a scanned |path|.
74 void GotScanResults(const base::FilePath& path, const WorkerReply& reply);
75
76 const MediaFolderFinderResultsCallback results_callback_;
77 MediaFolderFinderResults results_;
78
79 std::vector<base::FilePath> graylisted_folders_;
80 std::vector<base::FilePath> folders_to_scan_;
81 ScanState scan_state_;
82
83 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
84
85 // Owned by MediaFolderFinder, but lives on |worker_task_runner_|.
86 Worker* worker_;
87
88 // Set of roots to scan for testing.
89 bool has_roots_for_testing_;
90 std::vector<base::FilePath> roots_for_testing_;
91
92 base::WeakPtrFactory<MediaFolderFinder> weak_factory_;
93
94 DISALLOW_COPY_AND_ASSIGN(MediaFolderFinder);
95 };
96
97 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FOLDER_FINDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698