Chromium Code Reviews| Index: chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.h |
| diff --git a/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.h b/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.h |
| index 41135c9e0c255c8eef3c49e1278c1ad11362bc45..086e510b34013a0b35b3b582d1be83209154a8c6 100644 |
| --- a/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.h |
| +++ b/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.h |
| @@ -5,10 +5,16 @@ |
| #ifndef CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_ROOT_H_ |
| #define CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_ROOT_H_ |
| +#include <map> |
| #include <string> |
| +#include <vector> |
| +#include "base/callback.h" |
|
hashimoto
2016/12/20 04:55:07
nit: Can't be replaced with callback_forward.h?
Shuhei Takahashi
2016/12/20 06:08:24
Done.
|
| #include "base/files/file_path.h" |
| #include "base/macros.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/optional.h" |
| +#include "components/arc/common/file_system.mojom.h" |
| #include "storage/browser/fileapi/async_file_util.h" |
| namespace arc { |
| @@ -16,6 +22,8 @@ namespace arc { |
| // Represents a file system root in Android Documents Provider. |
| // |
| // All methods must be called on the IO thread. |
| +// If this object is deleted while there are in-flight operations, callbacks |
| +// for those operations will be never called. |
| class ArcDocumentsProviderRoot { |
| public: |
| using GetFileInfoCallback = storage::AsyncFileUtil::GetFileInfoCallback; |
| @@ -35,6 +43,55 @@ class ArcDocumentsProviderRoot { |
| const ReadDirectoryCallback& callback); |
| private: |
| + // Thin representation of a document in documents provider. |
| + struct ThinDocument { |
| + std::string document_id; |
| + bool is_directory; |
| + }; |
| + |
| + // Mapping from a file name to a ThinDocument. |
| + using NameMapping = std::map<base::FilePath::StringType, ThinDocument>; |
|
hashimoto
2016/12/20 04:55:07
nit: "NameMapping" sounds like a mapping from name
Shuhei Takahashi
2016/12/20 06:08:24
Done.
|
| + |
| + using ResolveToDocumentIdCallback = |
| + base::Callback<void(const std::string& document_id)>; |
| + using ReadDirectoryInternalCallback = |
| + base::Callback<void(NameMapping mapping)>; |
| + |
| + void GetFileInfoWithDocumentId(const GetFileInfoCallback& callback, |
| + const std::string& document_id); |
| + void GetFileInfoWithDocument(const GetFileInfoCallback& callback, |
| + mojom::DocumentPtr document); |
| + |
| + void ReadDirectoryWithDocumentId(const ReadDirectoryCallback& callback, |
| + const std::string& document_id); |
| + void ReadDirectoryWithNameMapping(const ReadDirectoryCallback& callback, |
| + NameMapping mapping); |
| + |
| + // Resolves |path| to a document ID. Failures are indicated by an empty |
| + // document ID. |
| + void ResolveToDocumentId(const base::FilePath& path, |
| + const ResolveToDocumentIdCallback& callback); |
| + void ResolveToDocumentIdRecursively( |
| + const std::string& document_id, |
| + const std::vector<base::FilePath::StringType>& components, |
| + const ResolveToDocumentIdCallback& callback); |
| + void ResolveToDocumentIdRecursivelyWithNameMapping( |
| + const std::vector<base::FilePath::StringType>& components, |
| + const ResolveToDocumentIdCallback& callback, |
| + NameMapping mapping); |
| + |
| + // Enumerates child documents of a directory specified by |document_id|. |
| + // The result is returned as a NameMapping. |
| + void ReadDirectoryInternal(const std::string& document_id, |
| + const ReadDirectoryInternalCallback& callback); |
| + void ReadDirectoryInternalWithChildDocuments( |
| + const ReadDirectoryInternalCallback& callback, |
| + base::Optional<std::vector<mojom::DocumentPtr>> maybe_children); |
| + |
| + const std::string authority_; |
| + const std::string root_document_id_; |
| + base::WeakPtrFactory<ArcDocumentsProviderRoot> weak_ptr_factory_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(ArcDocumentsProviderRoot); |
| }; |