OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_EXTENSIONS_API_FILE_HANDLERS_DIRECTORY_UTIL_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_FILE_HANDLERS_DIRECTORY_UTIL_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <set> |
| 10 #include <string> |
| 11 #include <vector> |
| 12 |
| 13 #include "base/callback.h" |
| 14 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" |
| 16 |
| 17 class Profile; |
| 18 |
| 19 namespace base { |
| 20 class FilePath; |
| 21 } // namespace base |
| 22 |
| 23 namespace extensions { |
| 24 namespace app_file_handler_util { |
| 25 |
| 26 class IsDirectoryCollector { |
| 27 public: |
| 28 typedef base::Callback<void(std::unique_ptr<std::set<base::FilePath>>)> |
| 29 CompletionCallback; |
| 30 |
| 31 explicit IsDirectoryCollector(Profile* profile); |
| 32 virtual ~IsDirectoryCollector(); |
| 33 |
| 34 // For the given paths obtains a set with which of them are directories. |
| 35 // The collector does not support virtual files if OS != CHROMEOS. |
| 36 void CollectForEntriesPaths(const std::vector<base::FilePath>& paths, |
| 37 const CompletionCallback& callback); |
| 38 |
| 39 private: |
| 40 void OnIsDirectoryCollected(size_t index, bool directory); |
| 41 |
| 42 Profile* profile_; |
| 43 std::vector<base::FilePath> paths_; |
| 44 std::unique_ptr<std::set<base::FilePath>> result_; |
| 45 size_t left_; |
| 46 CompletionCallback callback_; |
| 47 base::WeakPtrFactory<IsDirectoryCollector> weak_ptr_factory_; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(IsDirectoryCollector); |
| 50 }; |
| 51 |
| 52 } // namespace app_file_handler_util |
| 53 } // namespace extensions |
| 54 |
| 55 #endif // CHROME_BROWSER_EXTENSIONS_API_FILE_HANDLERS_DIRECTORY_UTIL_H_ |
OLD | NEW |