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

Side by Side Diff: chrome/browser/media_galleries/fileapi/media_scanner.h

Issue 149363004: Media Galleries: Initial media scanner implementation. (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
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_FILEAPI_MEDIA_SCANNER_H_
vandebo (ex-Chrome) 2014/01/29 18:41:45 I wouldn't put this in fileapi - it's not really p
Lei Zhang 2014/01/30 00:29:50 Done.
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_SCANNER_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 // MediaScanner scans local hard drives and look for folders that contain
19 // media files.
20 class MediaScanner {
vandebo (ex-Chrome) 2014/01/29 18:41:45 MediaDirectoryFinder ?
Lei Zhang 2014/01/30 00:29:50 Done.
21 public:
22 typedef std::map<base::FilePath, MediaGalleryScanResult> MediaScannerResults;
23 typedef base::Callback<void(bool /*success*/,
24 const MediaScannerResults& /*results*/)>
25 MediaScannerResultsCallback;
26 typedef base::Callback<MediaGalleryScanFileType(const base::FilePath&)>
vandebo (ex-Chrome) 2014/01/29 18:41:45 private ?
Lei Zhang 2014/01/30 00:10:49 Used in (anonymous)::DoScanOnBlockingPool()
27 FilterCallback;
28
29 // Set up a scan with a given set of |roots| as starting points.
30 // The elements of |roots| should not overlap and should be absolute.
31 // Unless the scan gets cancelled, it will call |callback| when the scan
32 // finishes.
33 MediaScanner(const std::vector<base::FilePath>& roots,
34 const MediaScannerResultsCallback& callback);
35 ~MediaScanner();
36
37
38 // Start the scan.
39 void StartScan();
40
41 // Cancel the scan. The MediaScanner should be deleted afterwards.
vandebo (ex-Chrome) 2014/01/29 18:41:45 afterwards -> after the callback is called?
Lei Zhang 2014/01/30 00:10:49 CancelScan() does not return until the callback fi
42 void CancelScan();
43
44 private:
45 void DoScan();
46 void GotScanResults(const base::FilePath& path,
47 const std::vector<base::FilePath>* new_folders,
vandebo (ex-Chrome) 2014/01/29 18:41:45 nit: arg order, keep path and scan_result together
Lei Zhang 2014/01/30 00:10:49 I don't see why it even matters, but sure.
48 const MediaGalleryScanResult* scan_result);
49
50 const MediaScannerResultsCallback callback_;
51 MediaScannerResults results_;
52
53 std::stack<base::FilePath> folders_to_scan_;
54 bool started_scan_;
55
56 base::SequencedWorkerPool::SequenceToken token_;
57
58 FilterCallback filter_callback_;
59
60 base::WeakPtrFactory<MediaScanner> weak_factory_;
61
62 DISALLOW_COPY_AND_ASSIGN(MediaScanner);
63 };
64
65 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_SCANNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698