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

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

Issue 2574173002: mediaview: Implement ArcDocumentsProviderRoot. (Closed)
Patch Set: 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_document.h
diff --git a/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_document.h b/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_document.h
new file mode 100644
index 0000000000000000000000000000000000000000..bb718daf0991e2f4122306115ec5257bb547b3e6
--- /dev/null
+++ b/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_document.h
@@ -0,0 +1,71 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_DOCUMENT_H_
+#define CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_DOCUMENT_H_
+
+#include <map>
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "base/files/file_path.h"
+#include "base/macros.h"
+#include "components/arc/common/file_system.mojom.h"
+
+namespace arc {
+
+// ArcDocumentsProviderDocument represents a document in DocumentsProvider.
+//
+// Since Android DocumentProvider is more permissive about display names
+// (e.g. duplicated file names in the same directory are allowed), we need
+// to expose some files to Chrome with rewritten file names. This object
+// will remember the mapping from rewritten file names to its child documents.
+//
+// WARNING: This class is thread-unsafe. Must be accessed only from a single
Luis Héctor Chávez 2016/12/15 02:40:31 Can you add one of these? https://cs.chromium.org/
Shuhei Takahashi 2016/12/15 06:50:57 Sure.
+// thread.
+class ArcDocumentsProviderDocument {
+ public:
+ // A mapping from rewritten file names to documents.
+ using ChildMap = std::map<base::FilePath::StringType,
+ std::unique_ptr<ArcDocumentsProviderDocument>>;
+
+ ArcDocumentsProviderDocument(const std::string& document_id,
+ bool is_directory);
+ ~ArcDocumentsProviderDocument();
+
+ static ArcDocumentsProviderDocument* CreateFromDocument(
+ const mojom::Document& document);
+
+ const std::string& document_id() { return document_id_; }
Luis Héctor Chávez 2016/12/15 02:40:31 You can make all of the inlined accessors const:
Shuhei Takahashi 2016/12/15 06:50:57 Done.
+ bool is_directory() { return is_directory_; }
+
+ // Must not be called unless is_directory() == true.
+ const ChildMap& children() { return *children_; }
+
+ // Recursively looks up a descendant document with a relative path.
+ // If a document with the specific relative path is not found, nullptr is
+ // returned.
+ ArcDocumentsProviderDocument* Lookup(const base::FilePath& path);
+
+ // Updates the child mapping with info retrieved from Android.
+ void UpdateWithChildDocuments(
+ const std::vector<mojom::DocumentPtr>& children);
+
+ private:
+ // Computes a file name for a document.
+ static base::FilePath::StringType GetFileNameForDocument(
+ const mojom::DocumentPtr& document);
+
+ const std::string document_id_;
+ const bool is_directory_;
+ // This will be non-null only when this entry is for a directory.
+ const std::unique_ptr<ChildMap> children_;
+
+ DISALLOW_COPY_AND_ASSIGN(ArcDocumentsProviderDocument);
+};
+
+} // namespace arc
+
+#endif // CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_DOCUMENT_H_

Powered by Google App Engine
This is Rietveld 408576698