| 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 EXTENSIONS_BROWSER_API_FILE_HANDLERS_DIRECTORY_UTIL_H_ | |
| 6 #define EXTENSIONS_BROWSER_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 namespace content { | |
| 18 class BrowserContext; | |
| 19 } | |
| 20 | |
| 21 namespace base { | |
| 22 class FilePath; | |
| 23 } // namespace base | |
| 24 | |
| 25 namespace extensions { | |
| 26 namespace app_file_handler_util { | |
| 27 | |
| 28 class IsDirectoryCollector { | |
| 29 public: | |
| 30 typedef base::Callback<void(std::unique_ptr<std::set<base::FilePath>>)> | |
| 31 CompletionCallback; | |
| 32 | |
| 33 explicit IsDirectoryCollector(content::BrowserContext* context); | |
| 34 virtual ~IsDirectoryCollector(); | |
| 35 | |
| 36 // For the given paths obtains a set with which of them are directories. | |
| 37 // The collector does not support virtual files if OS != CHROMEOS. | |
| 38 void CollectForEntriesPaths(const std::vector<base::FilePath>& paths, | |
| 39 const CompletionCallback& callback); | |
| 40 | |
| 41 private: | |
| 42 void OnIsDirectoryCollected(size_t index, bool directory); | |
| 43 | |
| 44 content::BrowserContext* context_; | |
| 45 std::vector<base::FilePath> paths_; | |
| 46 std::unique_ptr<std::set<base::FilePath>> result_; | |
| 47 size_t left_; | |
| 48 CompletionCallback callback_; | |
| 49 base::WeakPtrFactory<IsDirectoryCollector> weak_ptr_factory_; | |
| 50 | |
| 51 DISALLOW_COPY_AND_ASSIGN(IsDirectoryCollector); | |
| 52 }; | |
| 53 | |
| 54 } // namespace app_file_handler_util | |
| 55 } // namespace extensions | |
| 56 | |
| 57 #endif // EXTENSIONS_BROWSER_API_FILE_HANDLERS_DIRECTORY_UTIL_H_ | |
| OLD | NEW |