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_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_ROOT_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_ROOT_H_ |
6 #define CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_ROOT_H_ | 6 #define CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_ROOT_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
| 10 #include <vector> |
9 | 11 |
10 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/optional.h" |
| 16 #include "components/arc/common/file_system.mojom.h" |
12 #include "storage/browser/fileapi/async_file_util.h" | 17 #include "storage/browser/fileapi/async_file_util.h" |
13 | 18 |
14 namespace arc { | 19 namespace arc { |
15 | 20 |
| 21 class ArcDocumentsProviderDocument; |
| 22 |
16 // Represents a file system root in Android Documents Provider. | 23 // Represents a file system root in Android Documents Provider. |
17 // | 24 // |
18 // All methods must be called on the IO thread. | 25 // All methods must be called on the IO thread. |
19 class ArcDocumentsProviderRoot { | 26 class ArcDocumentsProviderRoot { |
20 public: | 27 public: |
21 using GetFileInfoCallback = storage::AsyncFileUtil::GetFileInfoCallback; | 28 using GetFileInfoCallback = storage::AsyncFileUtil::GetFileInfoCallback; |
22 using ReadDirectoryCallback = storage::AsyncFileUtil::ReadDirectoryCallback; | 29 using ReadDirectoryCallback = storage::AsyncFileUtil::ReadDirectoryCallback; |
23 | 30 |
24 ArcDocumentsProviderRoot(const std::string& authority, | 31 ArcDocumentsProviderRoot(const std::string& authority, |
25 const std::string& root_document_id); | 32 const std::string& root_document_id); |
26 ~ArcDocumentsProviderRoot(); | 33 ~ArcDocumentsProviderRoot(); |
27 | 34 |
28 // Queries information of a file just like AsyncFileUtil.GetFileInfo(). | 35 // Queries information of a file just like AsyncFileUtil.GetFileInfo(). |
29 void GetFileInfo(const base::FilePath& path, | 36 void GetFileInfo(const base::FilePath& path, |
30 const GetFileInfoCallback& callback); | 37 const GetFileInfoCallback& callback); |
31 | 38 |
32 // Queries a list of files under a directory just like | 39 // Queries a list of files under a directory just like |
33 // AsyncFileUtil.ReadDirectory(). | 40 // AsyncFileUtil.ReadDirectory(). |
34 void ReadDirectory(const base::FilePath& path, | 41 void ReadDirectory(const base::FilePath& path, |
35 const ReadDirectoryCallback& callback); | 42 const ReadDirectoryCallback& callback); |
36 | 43 |
37 private: | 44 private: |
| 45 void GetFileInfoAfterCacheUpdate(const base::FilePath& path, |
| 46 const GetFileInfoCallback& callback); |
| 47 void GetFileInfoWithDocument(const GetFileInfoCallback& callback, |
| 48 mojom::DocumentPtr document); |
| 49 |
| 50 void ReadDirectoryAfterCacheUpdate(const base::FilePath& path, |
| 51 const ReadDirectoryCallback& callback); |
| 52 void ReadDirectoryWithChildDocuments( |
| 53 const base::FilePath& path, |
| 54 const ReadDirectoryCallback& callback, |
| 55 base::Optional<std::vector<mojom::DocumentPtr>> children); |
| 56 |
| 57 void UpdateDirectoryCacheUpTo(const base::FilePath& path, |
| 58 const base::Closure& callback); |
| 59 void UpdateDirectoryCacheIter(const base::FilePath& parent_directory_path, |
| 60 const base::FilePath& remaining_path, |
| 61 const base::Closure& callback); |
| 62 void UpdateDirectoryCacheIterWithChildDocuments( |
| 63 const base::FilePath& parent_directory_path, |
| 64 const base::FilePath& remaining_path, |
| 65 const base::Closure& callback, |
| 66 base::Optional<std::vector<mojom::DocumentPtr>> children); |
| 67 |
| 68 const std::string authority_; |
| 69 const std::unique_ptr<ArcDocumentsProviderDocument> root_directory_; |
| 70 base::WeakPtrFactory<ArcDocumentsProviderRoot> weak_ptr_factory_; |
| 71 |
38 DISALLOW_COPY_AND_ASSIGN(ArcDocumentsProviderRoot); | 72 DISALLOW_COPY_AND_ASSIGN(ArcDocumentsProviderRoot); |
39 }; | 73 }; |
40 | 74 |
41 } // namespace arc | 75 } // namespace arc |
42 | 76 |
43 #endif // CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_ROOT_H_ | 77 #endif // CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_ROOT_H_ |
OLD | NEW |