| 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 <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/optional.h" | 15 #include "base/optional.h" |
| 16 #include "components/arc/common/file_system.mojom.h" | 16 #include "components/arc/common/file_system.mojom.h" |
| 17 #include "storage/browser/fileapi/async_file_util.h" | 17 #include "storage/browser/fileapi/async_file_util.h" |
| 18 | 18 |
| 19 class GURL; |
| 20 |
| 19 namespace arc { | 21 namespace arc { |
| 20 | 22 |
| 21 class ArcDocumentsProviderDocument; | 23 class ArcDocumentsProviderDocument; |
| 22 | 24 |
| 23 // Represents a file system root in Android Documents Provider. | 25 // Represents a file system root in Android Documents Provider. |
| 24 // | 26 // |
| 25 // All methods must be called on the IO thread. | 27 // All methods must be called on the IO thread. |
| 26 // If this object is deleted while there are in-flight operations, callbacks | 28 // If this object is deleted while there are in-flight operations, callbacks |
| 27 // for those operations will be never called. | 29 // for those operations will be never called. |
| 28 class ArcDocumentsProviderRoot { | 30 class ArcDocumentsProviderRoot { |
| 29 public: | 31 public: |
| 30 using GetFileInfoCallback = storage::AsyncFileUtil::GetFileInfoCallback; | 32 using GetFileInfoCallback = storage::AsyncFileUtil::GetFileInfoCallback; |
| 31 using ReadDirectoryCallback = storage::AsyncFileUtil::ReadDirectoryCallback; | 33 using ReadDirectoryCallback = storage::AsyncFileUtil::ReadDirectoryCallback; |
| 34 using ResolveToContentUrlCallback = |
| 35 base::Callback<void(const GURL& content_url)>; |
| 32 | 36 |
| 33 ArcDocumentsProviderRoot(const std::string& authority, | 37 ArcDocumentsProviderRoot(const std::string& authority, |
| 34 const std::string& root_document_id); | 38 const std::string& root_document_id); |
| 35 ~ArcDocumentsProviderRoot(); | 39 ~ArcDocumentsProviderRoot(); |
| 36 | 40 |
| 37 // Queries information of a file just like AsyncFileUtil.GetFileInfo(). | 41 // Queries information of a file just like AsyncFileUtil.GetFileInfo(). |
| 38 void GetFileInfo(const base::FilePath& path, | 42 void GetFileInfo(const base::FilePath& path, |
| 39 const GetFileInfoCallback& callback); | 43 const GetFileInfoCallback& callback); |
| 40 | 44 |
| 41 // Queries a list of files under a directory just like | 45 // Queries a list of files under a directory just like |
| 42 // AsyncFileUtil.ReadDirectory(). | 46 // AsyncFileUtil.ReadDirectory(). |
| 43 void ReadDirectory(const base::FilePath& path, | 47 void ReadDirectory(const base::FilePath& path, |
| 44 const ReadDirectoryCallback& callback); | 48 const ReadDirectoryCallback& callback); |
| 45 | 49 |
| 50 // Resolves a file path into a content:// URL pointing to the file |
| 51 // on DocumentsProvider. Returns URL that can be passed to |
| 52 // ArcContentFileSystemFileSystemReader to read the content. |
| 53 void ResolveToContentUrl(const base::FilePath& path, |
| 54 const ResolveToContentUrlCallback& callback); |
| 55 |
| 46 private: | 56 private: |
| 47 void GetFileInfoAfterCacheUpdate(const base::FilePath& path, | 57 void GetFileInfoAfterCacheUpdate(const base::FilePath& path, |
| 48 const GetFileInfoCallback& callback); | 58 const GetFileInfoCallback& callback); |
| 49 void GetFileInfoWithDocument(const GetFileInfoCallback& callback, | 59 void GetFileInfoWithDocument(const GetFileInfoCallback& callback, |
| 50 mojom::DocumentPtr document); | 60 mojom::DocumentPtr document); |
| 51 | 61 |
| 52 void ReadDirectoryAfterCacheUpdate(const base::FilePath& path, | 62 void ReadDirectoryAfterCacheUpdate(const base::FilePath& path, |
| 53 const ReadDirectoryCallback& callback); | 63 const ReadDirectoryCallback& callback); |
| 54 void ReadDirectoryWithChildDocuments( | 64 void ReadDirectoryWithChildDocuments( |
| 55 const base::FilePath& path, | 65 const base::FilePath& path, |
| 56 const ReadDirectoryCallback& callback, | 66 const ReadDirectoryCallback& callback, |
| 57 base::Optional<std::vector<mojom::DocumentPtr>> children); | 67 base::Optional<std::vector<mojom::DocumentPtr>> children); |
| 58 | 68 |
| 69 void ResolveToContentUrlAfterCacheUpdate( |
| 70 const base::FilePath& path, |
| 71 const ResolveToContentUrlCallback& callback); |
| 72 |
| 59 void UpdateDirectoryCacheUpTo(const base::FilePath& path, | 73 void UpdateDirectoryCacheUpTo(const base::FilePath& path, |
| 60 const base::Closure& callback); | 74 const base::Closure& callback); |
| 61 void UpdateDirectoryCacheIter(const base::FilePath& parent_directory_path, | 75 void UpdateDirectoryCacheIter(const base::FilePath& parent_directory_path, |
| 62 const base::FilePath& remaining_path, | 76 const base::FilePath& remaining_path, |
| 63 const base::Closure& callback); | 77 const base::Closure& callback); |
| 64 void UpdateDirectoryCacheIterWithChildDocuments( | 78 void UpdateDirectoryCacheIterWithChildDocuments( |
| 65 const base::FilePath& parent_directory_path, | 79 const base::FilePath& parent_directory_path, |
| 66 const base::FilePath& remaining_path, | 80 const base::FilePath& remaining_path, |
| 67 const base::Closure& callback, | 81 const base::Closure& callback, |
| 68 base::Optional<std::vector<mojom::DocumentPtr>> children); | 82 base::Optional<std::vector<mojom::DocumentPtr>> children); |
| 69 | 83 |
| 70 const std::string authority_; | 84 const std::string authority_; |
| 71 const std::unique_ptr<ArcDocumentsProviderDocument> root_directory_; | 85 const std::unique_ptr<ArcDocumentsProviderDocument> root_directory_; |
| 72 base::WeakPtrFactory<ArcDocumentsProviderRoot> weak_ptr_factory_; | 86 base::WeakPtrFactory<ArcDocumentsProviderRoot> weak_ptr_factory_; |
| 73 | 87 |
| 74 DISALLOW_COPY_AND_ASSIGN(ArcDocumentsProviderRoot); | 88 DISALLOW_COPY_AND_ASSIGN(ArcDocumentsProviderRoot); |
| 75 }; | 89 }; |
| 76 | 90 |
| 77 } // namespace arc | 91 } // namespace arc |
| 78 | 92 |
| 79 #endif // CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_ROOT_H_ | 93 #endif // CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_ROOT_H_ |
| OLD | NEW |