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

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

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

Powered by Google App Engine
This is Rietveld 408576698