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

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

Issue 149363004: Media Galleries: Initial media scanner implementation. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: move, rename 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
Property Changes:
Added: svn:eol-style
+ LF
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 <stack>
10 #include <vector>
11
12 #include "base/callback.h"
13 #include "base/files/file_path.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/threading/sequenced_worker_pool.h"
16 #include "chrome/browser/media_galleries/media_scan_types.h"
17
18 // MediaFolderFinder scans local hard drives and look for folders that contain
19 // media files.
20 class MediaFolderFinder {
21 public:
22 typedef std::map<base::FilePath, MediaGalleryScanResult>
23 MediaFolderFinderResults;
24 typedef base::Callback<void(bool /*success*/,
25 const MediaFolderFinderResults& /*results*/)>
26 MediaFolderFinderResultsCallback;
27 typedef base::Callback<MediaGalleryScanFileType(const base::FilePath&)>
28 FilterCallback;
29
30 // Set up a scan with a given set of |roots| as starting points.
31 // The elements of |roots| should not overlap and should be absolute.
32 // |callback| will get called when the scan finishes, or if this object gets
vandebo (ex-Chrome) 2014/01/30 01:03:11 nit: .. finishes. If the object is deleted before
Lei Zhang 2014/01/30 01:35:41 Done.
33 // deleted before the scan finishes.
34 MediaFolderFinder(const std::vector<base::FilePath>& roots,
35 const MediaFolderFinderResultsCallback& callback);
36 ~MediaFolderFinder();
37
38 // Start the scan.
39 void StartScan();
40
41 private:
42 enum ScanState {
43 SCAN_STATE_NOT_STARTED,
44 SCAN_STATE_STARTED,
45 SCAN_STATE_FINISHED,
46 };
47
48 // Scan a folder from |folders_to_scan_|.
49 void ScanFolder();
50
51 // Callback that returns the |scan_result| for |path| and the |new_folders|
52 // to scan in future calls to ScanFolder().
53 void GotScanResults(const base::FilePath& path,
54 const MediaGalleryScanResult* scan_result,
55 const std::vector<base::FilePath>* new_folders);
56
57 const MediaFolderFinderResultsCallback results_callback_;
58 MediaFolderFinderResults results_;
59
60 std::stack<base::FilePath> folders_to_scan_;
61 ScanState scan_state_;
62
63 // Token to make sure all calls with |filter_callback_| are on the same
64 // sequence.
65 base::SequencedWorkerPool::SequenceToken token_;
66
67 // Callback used to filter through files and make sure they are media files.
68 FilterCallback filter_callback_;
69
70 base::WeakPtrFactory<MediaFolderFinder> weak_factory_;
71
72 DISALLOW_COPY_AND_ASSIGN(MediaFolderFinder);
73 };
74
75 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FOLDER_FINDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698