Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Unified Diff: chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.h

Issue 2574173002: mediaview: Implement ArcDocumentsProviderRoot. (Closed)
Patch Set: Missing diffs in PS10... Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..de30a7477b8665dd5d702df176c4a7637bb812dd 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_forward.h"
#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,60 @@ 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 NameToThinDocumentMap =
+ std::map<base::FilePath::StringType, ThinDocument>;
+
+ using ResolveToDocumentIdCallback =
+ base::Callback<void(const std::string& document_id)>;
+ using ReadDirectoryInternalCallback =
+ base::Callback<void(base::File::Error error,
+ NameToThinDocumentMap 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 ReadDirectoryWithNameToThinDocumentMap(
+ const ReadDirectoryCallback& callback,
+ base::File::Error error,
+ NameToThinDocumentMap 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 ResolveToDocumentIdRecursivelyWithNameToThinDocumentMap(
+ const std::vector<base::FilePath::StringType>& components,
+ const ResolveToDocumentIdCallback& callback,
+ base::File::Error error,
+ NameToThinDocumentMap mapping);
+
+ // Enumerates child documents of a directory specified by |document_id|.
+ // The result is returned as a NameToThinDocumentMap.
+ 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);
};

Powered by Google App Engine
This is Rietveld 408576698