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