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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/fileapi/provider_async_file_util.cc

Issue 298003006: [fsp] Fix error codes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 6 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/file_system_provider/fileapi/provider_async_fi le_util.h" 5 #include "chrome/browser/chromeos/file_system_provider/fileapi/provider_async_fi le_util.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 11 matching lines...) Expand all
22 namespace internal { 22 namespace internal {
23 namespace { 23 namespace {
24 24
25 // Executes GetFileInfo on the UI thread. 25 // Executes GetFileInfo on the UI thread.
26 void GetFileInfoOnUIThread( 26 void GetFileInfoOnUIThread(
27 scoped_ptr<fileapi::FileSystemOperationContext> context, 27 scoped_ptr<fileapi::FileSystemOperationContext> context,
28 const fileapi::FileSystemURL& url, 28 const fileapi::FileSystemURL& url,
29 const fileapi::AsyncFileUtil::GetFileInfoCallback& callback) { 29 const fileapi::AsyncFileUtil::GetFileInfoCallback& callback) {
30 util::FileSystemURLParser parser(url); 30 util::FileSystemURLParser parser(url);
31 if (!parser.Parse()) { 31 if (!parser.Parse()) {
32 callback.Run(base::File::FILE_ERROR_NOT_FOUND, base::File::Info()); 32 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, base::File::Info());
33 return; 33 return;
34 } 34 }
35 35
36 parser.file_system()->GetMetadata(parser.file_path(), callback); 36 parser.file_system()->GetMetadata(parser.file_path(), callback);
37 } 37 }
38 38
39 // Routes the response of GetFileInfo back to the IO thread. 39 // Routes the response of GetFileInfo back to the IO thread.
40 void OnGetFileInfo(const fileapi::AsyncFileUtil::GetFileInfoCallback& callback, 40 void OnGetFileInfo(const fileapi::AsyncFileUtil::GetFileInfoCallback& callback,
41 base::File::Error result, 41 base::File::Error result,
42 const base::File::Info& file_info) { 42 const base::File::Info& file_info) {
43 BrowserThread::PostTask( 43 BrowserThread::PostTask(
44 BrowserThread::IO, FROM_HERE, base::Bind(callback, result, file_info)); 44 BrowserThread::IO, FROM_HERE, base::Bind(callback, result, file_info));
45 } 45 }
46 46
47 // Executes ReadDirectory on the UI thread. 47 // Executes ReadDirectory on the UI thread.
48 void ReadDirectoryOnUIThread( 48 void ReadDirectoryOnUIThread(
49 scoped_ptr<fileapi::FileSystemOperationContext> context, 49 scoped_ptr<fileapi::FileSystemOperationContext> context,
50 const fileapi::FileSystemURL& url, 50 const fileapi::FileSystemURL& url,
51 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) { 51 const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) {
52 util::FileSystemURLParser parser(url); 52 util::FileSystemURLParser parser(url);
53 if (!parser.Parse()) { 53 if (!parser.Parse()) {
54 callback.Run(base::File::FILE_ERROR_NOT_FOUND, 54 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION,
55 fileapi::AsyncFileUtil::EntryList(), 55 fileapi::AsyncFileUtil::EntryList(),
56 false /* has_more */); 56 false /* has_more */);
57 return; 57 return;
58 } 58 }
59 59
60 parser.file_system()->ReadDirectory(parser.file_path(), callback); 60 parser.file_system()->ReadDirectory(parser.file_path(), callback);
61 } 61 }
62 62
63 // Routes the response of ReadDirectory back to the IO thread. 63 // Routes the response of ReadDirectory back to the IO thread.
64 void OnReadDirectory( 64 void OnReadDirectory(
(...skipping 15 matching lines...) Expand all
80 void ProviderAsyncFileUtil::CreateOrOpen( 80 void ProviderAsyncFileUtil::CreateOrOpen(
81 scoped_ptr<fileapi::FileSystemOperationContext> context, 81 scoped_ptr<fileapi::FileSystemOperationContext> context,
82 const fileapi::FileSystemURL& url, 82 const fileapi::FileSystemURL& url,
83 int file_flags, 83 int file_flags,
84 const CreateOrOpenCallback& callback) { 84 const CreateOrOpenCallback& callback) {
85 DCHECK_CURRENTLY_ON(BrowserThread::IO); 85 DCHECK_CURRENTLY_ON(BrowserThread::IO);
86 if ((file_flags & base::File::FLAG_CREATE) || 86 if ((file_flags & base::File::FLAG_CREATE) ||
87 (file_flags & base::File::FLAG_OPEN_ALWAYS) || 87 (file_flags & base::File::FLAG_OPEN_ALWAYS) ||
88 (file_flags & base::File::FLAG_CREATE_ALWAYS) || 88 (file_flags & base::File::FLAG_CREATE_ALWAYS) ||
89 (file_flags & base::File::FLAG_OPEN_TRUNCATED)) { 89 (file_flags & base::File::FLAG_OPEN_TRUNCATED)) {
90 callback.Run(base::File(base::File::FILE_ERROR_SECURITY), base::Closure()); 90 callback.Run(base::File(base::File::FILE_ERROR_ACCESS_DENIED),
91 base::Closure());
91 return; 92 return;
92 } 93 }
93 94
94 NOTIMPLEMENTED(); 95 NOTIMPLEMENTED();
95 callback.Run(base::File(base::File::FILE_ERROR_NOT_FOUND), base::Closure()); 96 callback.Run(base::File(base::File::FILE_ERROR_INVALID_OPERATION),
97 base::Closure());
96 } 98 }
97 99
98 void ProviderAsyncFileUtil::EnsureFileExists( 100 void ProviderAsyncFileUtil::EnsureFileExists(
99 scoped_ptr<fileapi::FileSystemOperationContext> context, 101 scoped_ptr<fileapi::FileSystemOperationContext> context,
100 const fileapi::FileSystemURL& url, 102 const fileapi::FileSystemURL& url,
101 const EnsureFileExistsCallback& callback) { 103 const EnsureFileExistsCallback& callback) {
102 DCHECK_CURRENTLY_ON(BrowserThread::IO); 104 DCHECK_CURRENTLY_ON(BrowserThread::IO);
103 callback.Run(base::File::FILE_ERROR_SECURITY, false /* created */); 105 callback.Run(base::File::FILE_ERROR_ACCESS_DENIED, false /* created */);
104 } 106 }
105 107
106 void ProviderAsyncFileUtil::CreateDirectory( 108 void ProviderAsyncFileUtil::CreateDirectory(
107 scoped_ptr<fileapi::FileSystemOperationContext> context, 109 scoped_ptr<fileapi::FileSystemOperationContext> context,
108 const fileapi::FileSystemURL& url, 110 const fileapi::FileSystemURL& url,
109 bool exclusive, 111 bool exclusive,
110 bool recursive, 112 bool recursive,
111 const StatusCallback& callback) { 113 const StatusCallback& callback) {
112 DCHECK_CURRENTLY_ON(BrowserThread::IO); 114 DCHECK_CURRENTLY_ON(BrowserThread::IO);
113 callback.Run(base::File::FILE_ERROR_SECURITY); 115 callback.Run(base::File::FILE_ERROR_ACCESS_DENIED);
114 } 116 }
115 117
116 void ProviderAsyncFileUtil::GetFileInfo( 118 void ProviderAsyncFileUtil::GetFileInfo(
117 scoped_ptr<fileapi::FileSystemOperationContext> context, 119 scoped_ptr<fileapi::FileSystemOperationContext> context,
118 const fileapi::FileSystemURL& url, 120 const fileapi::FileSystemURL& url,
119 const GetFileInfoCallback& callback) { 121 const GetFileInfoCallback& callback) {
120 DCHECK_CURRENTLY_ON(BrowserThread::IO); 122 DCHECK_CURRENTLY_ON(BrowserThread::IO);
121 BrowserThread::PostTask(BrowserThread::UI, 123 BrowserThread::PostTask(BrowserThread::UI,
122 FROM_HERE, 124 FROM_HERE,
123 base::Bind(&GetFileInfoOnUIThread, 125 base::Bind(&GetFileInfoOnUIThread,
(...skipping 15 matching lines...) Expand all
139 base::Bind(&OnReadDirectory, callback))); 141 base::Bind(&OnReadDirectory, callback)));
140 } 142 }
141 143
142 void ProviderAsyncFileUtil::Touch( 144 void ProviderAsyncFileUtil::Touch(
143 scoped_ptr<fileapi::FileSystemOperationContext> context, 145 scoped_ptr<fileapi::FileSystemOperationContext> context,
144 const fileapi::FileSystemURL& url, 146 const fileapi::FileSystemURL& url,
145 const base::Time& last_access_time, 147 const base::Time& last_access_time,
146 const base::Time& last_modified_time, 148 const base::Time& last_modified_time,
147 const StatusCallback& callback) { 149 const StatusCallback& callback) {
148 DCHECK_CURRENTLY_ON(BrowserThread::IO); 150 DCHECK_CURRENTLY_ON(BrowserThread::IO);
149 callback.Run(base::File::FILE_ERROR_SECURITY); 151 callback.Run(base::File::FILE_ERROR_ACCESS_DENIED);
150 } 152 }
151 153
152 void ProviderAsyncFileUtil::Truncate( 154 void ProviderAsyncFileUtil::Truncate(
153 scoped_ptr<fileapi::FileSystemOperationContext> context, 155 scoped_ptr<fileapi::FileSystemOperationContext> context,
154 const fileapi::FileSystemURL& url, 156 const fileapi::FileSystemURL& url,
155 int64 length, 157 int64 length,
156 const StatusCallback& callback) { 158 const StatusCallback& callback) {
157 DCHECK_CURRENTLY_ON(BrowserThread::IO); 159 DCHECK_CURRENTLY_ON(BrowserThread::IO);
158 callback.Run(base::File::FILE_ERROR_SECURITY); 160 callback.Run(base::File::FILE_ERROR_ACCESS_DENIED);
159 } 161 }
160 162
161 void ProviderAsyncFileUtil::CopyFileLocal( 163 void ProviderAsyncFileUtil::CopyFileLocal(
162 scoped_ptr<fileapi::FileSystemOperationContext> context, 164 scoped_ptr<fileapi::FileSystemOperationContext> context,
163 const fileapi::FileSystemURL& src_url, 165 const fileapi::FileSystemURL& src_url,
164 const fileapi::FileSystemURL& dest_url, 166 const fileapi::FileSystemURL& dest_url,
165 CopyOrMoveOption option, 167 CopyOrMoveOption option,
166 const CopyFileProgressCallback& progress_callback, 168 const CopyFileProgressCallback& progress_callback,
167 const StatusCallback& callback) { 169 const StatusCallback& callback) {
168 DCHECK_CURRENTLY_ON(BrowserThread::IO); 170 DCHECK_CURRENTLY_ON(BrowserThread::IO);
169 callback.Run(base::File::FILE_ERROR_SECURITY); 171 callback.Run(base::File::FILE_ERROR_ACCESS_DENIED);
170 } 172 }
171 173
172 void ProviderAsyncFileUtil::MoveFileLocal( 174 void ProviderAsyncFileUtil::MoveFileLocal(
173 scoped_ptr<fileapi::FileSystemOperationContext> context, 175 scoped_ptr<fileapi::FileSystemOperationContext> context,
174 const fileapi::FileSystemURL& src_url, 176 const fileapi::FileSystemURL& src_url,
175 const fileapi::FileSystemURL& dest_url, 177 const fileapi::FileSystemURL& dest_url,
176 CopyOrMoveOption option, 178 CopyOrMoveOption option,
177 const StatusCallback& callback) { 179 const StatusCallback& callback) {
178 DCHECK_CURRENTLY_ON(BrowserThread::IO); 180 DCHECK_CURRENTLY_ON(BrowserThread::IO);
179 callback.Run(base::File::FILE_ERROR_SECURITY); 181 callback.Run(base::File::FILE_ERROR_ACCESS_DENIED);
180 } 182 }
181 183
182 void ProviderAsyncFileUtil::CopyInForeignFile( 184 void ProviderAsyncFileUtil::CopyInForeignFile(
183 scoped_ptr<fileapi::FileSystemOperationContext> context, 185 scoped_ptr<fileapi::FileSystemOperationContext> context,
184 const base::FilePath& src_file_path, 186 const base::FilePath& src_file_path,
185 const fileapi::FileSystemURL& dest_url, 187 const fileapi::FileSystemURL& dest_url,
186 const StatusCallback& callback) { 188 const StatusCallback& callback) {
187 DCHECK_CURRENTLY_ON(BrowserThread::IO); 189 DCHECK_CURRENTLY_ON(BrowserThread::IO);
188 callback.Run(base::File::FILE_ERROR_SECURITY); 190 callback.Run(base::File::FILE_ERROR_ACCESS_DENIED);
189 } 191 }
190 192
191 void ProviderAsyncFileUtil::DeleteFile( 193 void ProviderAsyncFileUtil::DeleteFile(
192 scoped_ptr<fileapi::FileSystemOperationContext> context, 194 scoped_ptr<fileapi::FileSystemOperationContext> context,
193 const fileapi::FileSystemURL& url, 195 const fileapi::FileSystemURL& url,
194 const StatusCallback& callback) { 196 const StatusCallback& callback) {
195 DCHECK_CURRENTLY_ON(BrowserThread::IO); 197 DCHECK_CURRENTLY_ON(BrowserThread::IO);
196 callback.Run(base::File::FILE_ERROR_SECURITY); 198 callback.Run(base::File::FILE_ERROR_ACCESS_DENIED);
197 } 199 }
198 200
199 void ProviderAsyncFileUtil::DeleteDirectory( 201 void ProviderAsyncFileUtil::DeleteDirectory(
200 scoped_ptr<fileapi::FileSystemOperationContext> context, 202 scoped_ptr<fileapi::FileSystemOperationContext> context,
201 const fileapi::FileSystemURL& url, 203 const fileapi::FileSystemURL& url,
202 const StatusCallback& callback) { 204 const StatusCallback& callback) {
203 DCHECK_CURRENTLY_ON(BrowserThread::IO); 205 DCHECK_CURRENTLY_ON(BrowserThread::IO);
204 callback.Run(base::File::FILE_ERROR_SECURITY); 206 callback.Run(base::File::FILE_ERROR_ACCESS_DENIED);
205 } 207 }
206 208
207 void ProviderAsyncFileUtil::DeleteRecursively( 209 void ProviderAsyncFileUtil::DeleteRecursively(
208 scoped_ptr<fileapi::FileSystemOperationContext> context, 210 scoped_ptr<fileapi::FileSystemOperationContext> context,
209 const fileapi::FileSystemURL& url, 211 const fileapi::FileSystemURL& url,
210 const StatusCallback& callback) { 212 const StatusCallback& callback) {
211 DCHECK_CURRENTLY_ON(BrowserThread::IO); 213 DCHECK_CURRENTLY_ON(BrowserThread::IO);
212 callback.Run(base::File::FILE_ERROR_SECURITY); 214 callback.Run(base::File::FILE_ERROR_ACCESS_DENIED);
213 } 215 }
214 216
215 void ProviderAsyncFileUtil::CreateSnapshotFile( 217 void ProviderAsyncFileUtil::CreateSnapshotFile(
216 scoped_ptr<fileapi::FileSystemOperationContext> context, 218 scoped_ptr<fileapi::FileSystemOperationContext> context,
217 const fileapi::FileSystemURL& url, 219 const fileapi::FileSystemURL& url,
218 const CreateSnapshotFileCallback& callback) { 220 const CreateSnapshotFileCallback& callback) {
219 DCHECK_CURRENTLY_ON(BrowserThread::IO); 221 DCHECK_CURRENTLY_ON(BrowserThread::IO);
220 NOTIMPLEMENTED(); 222 NOTIMPLEMENTED();
221 callback.Run(base::File::FILE_ERROR_NOT_FOUND, 223 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION,
222 base::File::Info(), 224 base::File::Info(),
223 base::FilePath(), 225 base::FilePath(),
224 scoped_refptr<webkit_blob::ShareableFileReference>()); 226 scoped_refptr<webkit_blob::ShareableFileReference>());
225 } 227 }
226 228
227 } // namespace internal 229 } // namespace internal
228 } // namespace file_system_provider 230 } // namespace file_system_provider
229 } // namespace chromeos 231 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698