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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_DOCUMENT_H_
6 #define CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_DOCUMENT_H_
7
8 #include <map>
9 #include <memory>
10 #include <string>
11 #include <vector>
12
13 #include "base/files/file_path.h"
14 #include "base/macros.h"
15 #include "components/arc/common/file_system.mojom.h"
16
17 namespace arc {
18
19 // ArcDocumentsProviderDocument represents a document in DocumentsProvider.
20 //
21 // Since Android DocumentProvider is more permissive about display names
22 // (e.g. duplicated file names in the same directory are allowed), we need
23 // to expose some files to Chrome with rewritten file names. This object
24 // will remember the mapping from rewritten file names to its child documents.
25 //
26 // 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.
27 // thread.
28 class ArcDocumentsProviderDocument {
29 public:
30 // A mapping from rewritten file names to documents.
31 using ChildMap = std::map<base::FilePath::StringType,
32 std::unique_ptr<ArcDocumentsProviderDocument>>;
33
34 ArcDocumentsProviderDocument(const std::string& document_id,
35 bool is_directory);
36 ~ArcDocumentsProviderDocument();
37
38 static ArcDocumentsProviderDocument* CreateFromDocument(
39 const mojom::Document& document);
40
41 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.
42 bool is_directory() { return is_directory_; }
43
44 // Must not be called unless is_directory() == true.
45 const ChildMap& children() { return *children_; }
46
47 // Recursively looks up a descendant document with a relative path.
48 // If a document with the specific relative path is not found, nullptr is
49 // returned.
50 ArcDocumentsProviderDocument* Lookup(const base::FilePath& path);
51
52 // Updates the child mapping with info retrieved from Android.
53 void UpdateWithChildDocuments(
54 const std::vector<mojom::DocumentPtr>& children);
55
56 private:
57 // Computes a file name for a document.
58 static base::FilePath::StringType GetFileNameForDocument(
59 const mojom::DocumentPtr& document);
60
61 const std::string document_id_;
62 const bool is_directory_;
63 // This will be non-null only when this entry is for a directory.
64 const std::unique_ptr<ChildMap> children_;
65
66 DISALLOW_COPY_AND_ASSIGN(ArcDocumentsProviderDocument);
67 };
68
69 } // namespace arc
70
71 #endif // CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_DOCUMENT_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698