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

Side by Side Diff: chrome/browser/chromeos/arc/fileapi/arc_documents_provider_async_file_util.cc

Issue 2572683004: mediaview: Introduce ArcDocumentsProviderRoot. (Closed)
Patch Set: Constructors are called on the UI thread. 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
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 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_async_file_ util.h" 5 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_async_file_ util.h"
6 6
7 #include "base/callback.h" 7 #include <utility>
8
8 #include "base/files/file.h" 9 #include "base/files/file.h"
9 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.h"
13 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root_map.h"
14 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h"
11 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
12 #include "storage/browser/blob/shareable_file_reference.h" 16 #include "storage/browser/blob/shareable_file_reference.h"
17 #include "storage/browser/fileapi/file_system_operation_context.h"
18 #include "storage/browser/fileapi/file_system_url.h"
13 19
14 using content::BrowserThread; 20 using content::BrowserThread;
15 21
16 namespace arc { 22 namespace arc {
17 23
18 ArcDocumentsProviderAsyncFileUtil::ArcDocumentsProviderAsyncFileUtil() = 24 ArcDocumentsProviderAsyncFileUtil::ArcDocumentsProviderAsyncFileUtil(
19 default; 25 ArcDocumentsProviderRootMap* roots)
26 : roots_(roots) {}
20 27
21 ArcDocumentsProviderAsyncFileUtil::~ArcDocumentsProviderAsyncFileUtil() = 28 ArcDocumentsProviderAsyncFileUtil::~ArcDocumentsProviderAsyncFileUtil() =
22 default; 29 default;
23 30
24 void ArcDocumentsProviderAsyncFileUtil::CreateOrOpen( 31 void ArcDocumentsProviderAsyncFileUtil::CreateOrOpen(
25 std::unique_ptr<storage::FileSystemOperationContext> context, 32 std::unique_ptr<storage::FileSystemOperationContext> context,
26 const storage::FileSystemURL& url, 33 const storage::FileSystemURL& url,
27 int file_flags, 34 int file_flags,
28 const CreateOrOpenCallback& callback) { 35 const CreateOrOpenCallback& callback) {
29 DCHECK_CURRENTLY_ON(BrowserThread::IO); 36 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 22 matching lines...) Expand all
52 NOTREACHED(); // Read-only file system. 59 NOTREACHED(); // Read-only file system.
53 callback.Run(base::File::FILE_ERROR_ACCESS_DENIED); 60 callback.Run(base::File::FILE_ERROR_ACCESS_DENIED);
54 } 61 }
55 62
56 void ArcDocumentsProviderAsyncFileUtil::GetFileInfo( 63 void ArcDocumentsProviderAsyncFileUtil::GetFileInfo(
57 std::unique_ptr<storage::FileSystemOperationContext> context, 64 std::unique_ptr<storage::FileSystemOperationContext> context,
58 const storage::FileSystemURL& url, 65 const storage::FileSystemURL& url,
59 int fields, 66 int fields,
60 const GetFileInfoCallback& callback) { 67 const GetFileInfoCallback& callback) {
61 DCHECK_CURRENTLY_ON(BrowserThread::IO); 68 DCHECK_CURRENTLY_ON(BrowserThread::IO);
62 NOTIMPLEMENTED(); // TODO(crbug.com/671511): Implement this function. 69 DCHECK_EQ(storage::kFileSystemTypeArcDocumentsProvider, url.type());
63 callback.Run(base::File::FILE_ERROR_NOT_FOUND, base::File::Info()); 70
71 base::FilePath path;
72 ArcDocumentsProviderRoot* root = roots_->ParseAndLookup(url, &path);
73 if (!root) {
74 callback.Run(base::File::FILE_ERROR_NOT_FOUND, base::File::Info());
75 return;
76 }
77
78 root->GetFileInfo(path, callback);
64 } 79 }
65 80
66 void ArcDocumentsProviderAsyncFileUtil::ReadDirectory( 81 void ArcDocumentsProviderAsyncFileUtil::ReadDirectory(
67 std::unique_ptr<storage::FileSystemOperationContext> context, 82 std::unique_ptr<storage::FileSystemOperationContext> context,
68 const storage::FileSystemURL& url, 83 const storage::FileSystemURL& url,
69 const ReadDirectoryCallback& callback) { 84 const ReadDirectoryCallback& callback) {
70 DCHECK_CURRENTLY_ON(BrowserThread::IO); 85 DCHECK_CURRENTLY_ON(BrowserThread::IO);
71 NOTIMPLEMENTED(); // TODO(crbug.com/671511): Implement this function. 86 DCHECK_EQ(storage::kFileSystemTypeArcDocumentsProvider, url.type());
72 callback.Run(base::File::FILE_ERROR_NOT_FOUND, EntryList(), 87
73 false /* has_more */); 88 base::FilePath path;
89 ArcDocumentsProviderRoot* root = roots_->ParseAndLookup(url, &path);
90 if (!root) {
91 callback.Run(base::File::FILE_ERROR_NOT_FOUND, EntryList(), false);
92 return;
93 }
94
95 root->ReadDirectory(path, callback);
74 } 96 }
75 97
76 void ArcDocumentsProviderAsyncFileUtil::Touch( 98 void ArcDocumentsProviderAsyncFileUtil::Touch(
77 std::unique_ptr<storage::FileSystemOperationContext> context, 99 std::unique_ptr<storage::FileSystemOperationContext> context,
78 const storage::FileSystemURL& url, 100 const storage::FileSystemURL& url,
79 const base::Time& last_access_time, 101 const base::Time& last_access_time,
80 const base::Time& last_modified_time, 102 const base::Time& last_modified_time,
81 const StatusCallback& callback) { 103 const StatusCallback& callback) {
82 DCHECK_CURRENTLY_ON(BrowserThread::IO); 104 DCHECK_CURRENTLY_ON(BrowserThread::IO);
83 NOTREACHED(); // Read-only file system. 105 NOTREACHED(); // Read-only file system.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 const storage::FileSystemURL& url, 181 const storage::FileSystemURL& url,
160 const CreateSnapshotFileCallback& callback) { 182 const CreateSnapshotFileCallback& callback) {
161 DCHECK_CURRENTLY_ON(BrowserThread::IO); 183 DCHECK_CURRENTLY_ON(BrowserThread::IO);
162 NOTIMPLEMENTED(); // TODO(crbug.com/671511): Implement this function. 184 NOTIMPLEMENTED(); // TODO(crbug.com/671511): Implement this function.
163 callback.Run(base::File::FILE_ERROR_FAILED, base::File::Info(), 185 callback.Run(base::File::FILE_ERROR_FAILED, base::File::Info(),
164 base::FilePath(), 186 base::FilePath(),
165 scoped_refptr<storage::ShareableFileReference>()); 187 scoped_refptr<storage::ShareableFileReference>());
166 } 188 }
167 189
168 } // namespace arc 190 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698