Chromium Code Reviews| Index: chrome/browser/media_galleries/fileapi/media_scanner.h |
| =================================================================== |
| --- chrome/browser/media_galleries/fileapi/media_scanner.h (revision 0) |
| +++ chrome/browser/media_galleries/fileapi/media_scanner.h (revision 0) |
| @@ -0,0 +1,65 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#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.
|
| +#define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_SCANNER_H_ |
| + |
| +#include <map> |
| +#include <stack> |
| +#include <vector> |
| + |
| +#include "base/callback.h" |
| +#include "base/files/file_path.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/threading/sequenced_worker_pool.h" |
| +#include "chrome/browser/media_galleries/media_scan_types.h" |
| + |
| +// MediaScanner scans local hard drives and look for folders that contain |
| +// media files. |
| +class MediaScanner { |
|
vandebo (ex-Chrome)
2014/01/29 18:41:45
MediaDirectoryFinder ?
Lei Zhang
2014/01/30 00:29:50
Done.
|
| + public: |
| + typedef std::map<base::FilePath, MediaGalleryScanResult> MediaScannerResults; |
| + typedef base::Callback<void(bool /*success*/, |
| + const MediaScannerResults& /*results*/)> |
| + MediaScannerResultsCallback; |
| + 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()
|
| + FilterCallback; |
| + |
| + // Set up a scan with a given set of |roots| as starting points. |
| + // The elements of |roots| should not overlap and should be absolute. |
| + // Unless the scan gets cancelled, it will call |callback| when the scan |
| + // finishes. |
| + MediaScanner(const std::vector<base::FilePath>& roots, |
| + const MediaScannerResultsCallback& callback); |
| + ~MediaScanner(); |
| + |
| + |
| + // Start the scan. |
| + void StartScan(); |
| + |
| + // 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
|
| + void CancelScan(); |
| + |
| + private: |
| + void DoScan(); |
| + void GotScanResults(const base::FilePath& path, |
| + 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.
|
| + const MediaGalleryScanResult* scan_result); |
| + |
| + const MediaScannerResultsCallback callback_; |
| + MediaScannerResults results_; |
| + |
| + std::stack<base::FilePath> folders_to_scan_; |
| + bool started_scan_; |
| + |
| + base::SequencedWorkerPool::SequenceToken token_; |
| + |
| + FilterCallback filter_callback_; |
| + |
| + base::WeakPtrFactory<MediaScanner> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MediaScanner); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_SCANNER_H_ |
| Property changes on: chrome/browser/media_galleries/fileapi/media_scanner.h |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| + LF |