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

Side by Side Diff: chrome/browser/chromeos/drive/fileapi/async_file_util.cc

Issue 145973016: Support cross-profile copy between Chrome OS Google Drive folders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix. Created 6 years, 10 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/drive/fileapi/async_file_util.h" 5 #include "chrome/browser/chromeos/drive/fileapi/async_file_util.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/platform_file.h" 10 #include "base/platform_file.h"
11 #include "base/threading/sequenced_worker_pool.h" 11 #include "base/threading/sequenced_worker_pool.h"
12 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
12 #include "chrome/browser/chromeos/drive/file_system_util.h" 13 #include "chrome/browser/chromeos/drive/file_system_util.h"
13 #include "chrome/browser/chromeos/drive/fileapi/fileapi_worker.h" 14 #include "chrome/browser/chromeos/drive/fileapi/fileapi_worker.h"
14 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
15 #include "google_apis/drive/task_util.h" 16 #include "google_apis/drive/task_util.h"
16 #include "webkit/browser/fileapi/file_system_operation_context.h" 17 #include "webkit/browser/fileapi/file_system_operation_context.h"
17 #include "webkit/browser/fileapi/file_system_url.h" 18 #include "webkit/browser/fileapi/file_system_url.h"
18 #include "webkit/common/blob/shareable_file_reference.h" 19 #include "webkit/common/blob/shareable_file_reference.h"
19 20
20 using content::BrowserThread; 21 using content::BrowserThread;
21 22
(...skipping 17 matching lines...) Expand all
39 file_system_getter, function, 40 file_system_getter, function,
40 on_error_callback.is_null() ? 41 on_error_callback.is_null() ?
41 base::Closure() : 42 base::Closure() :
42 base::Bind(&google_apis::RunTaskOnThread, 43 base::Bind(&google_apis::RunTaskOnThread,
43 base::MessageLoopProxy::current(), 44 base::MessageLoopProxy::current(),
44 on_error_callback))); 45 on_error_callback)));
45 } 46 }
46 47
47 // Runs CreateOrOpenFile callback based on the given |error| and |file|. 48 // Runs CreateOrOpenFile callback based on the given |error| and |file|.
48 void RunCreateOrOpenFileCallback( 49 void RunCreateOrOpenFileCallback(
49 const AsyncFileUtil::FileSystemGetter& file_system_getter, 50 const fileapi_internal::FileSystemGetter& file_system_getter,
50 const base::FilePath& file_path, 51 const base::FilePath& file_path,
51 const AsyncFileUtil::CreateOrOpenCallback& callback, 52 const AsyncFileUtil::CreateOrOpenCallback& callback,
52 base::File::Error error, 53 base::File::Error error,
53 base::PlatformFile file, 54 base::PlatformFile file,
54 const base::Closure& close_callback_on_ui_thread) { 55 const base::Closure& close_callback_on_ui_thread) {
55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
56 57
57 // It is necessary to make a closure, which runs on file closing here. 58 // It is necessary to make a closure, which runs on file closing here.
58 // It will be provided as a FileSystem::OpenFileCallback's argument later. 59 // It will be provided as a FileSystem::OpenFileCallback's argument later.
59 // (crbug.com/259184). 60 // (crbug.com/259184).
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 scoped_refptr<webkit_blob::ShareableFileReference> file_reference = 108 scoped_refptr<webkit_blob::ShareableFileReference> file_reference =
108 webkit_blob::ShareableFileReference::GetOrCreate(webkit_blob::ScopedFile( 109 webkit_blob::ShareableFileReference::GetOrCreate(webkit_blob::ScopedFile(
109 local_path, 110 local_path,
110 scope_out_policy, 111 scope_out_policy,
111 BrowserThread::GetBlockingPool())); 112 BrowserThread::GetBlockingPool()));
112 callback.Run(error, file_info, local_path, file_reference); 113 callback.Run(error, file_info, local_path, file_reference);
113 } 114 }
114 115
115 } // namespace 116 } // namespace
116 117
117 AsyncFileUtil::AsyncFileUtil(const FileSystemGetter& file_system_getter) 118 AsyncFileUtil::AsyncFileUtil() {
118 : file_system_getter_(file_system_getter) {
119 } 119 }
120 120
121 AsyncFileUtil::~AsyncFileUtil() { 121 AsyncFileUtil::~AsyncFileUtil() {
122 } 122 }
123 123
124 void AsyncFileUtil::CreateOrOpen( 124 void AsyncFileUtil::CreateOrOpen(
125 scoped_ptr<fileapi::FileSystemOperationContext> context, 125 scoped_ptr<fileapi::FileSystemOperationContext> context,
126 const fileapi::FileSystemURL& url, 126 const fileapi::FileSystemURL& url,
127 int file_flags, 127 int file_flags,
128 const CreateOrOpenCallback& callback) { 128 const CreateOrOpenCallback& callback) {
129 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 129 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
130 130
131 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 131 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
132 if (file_path.empty()) { 132 if (file_path.empty()) {
133 base::PlatformFile platform_file = base::kInvalidPlatformFileValue; 133 base::PlatformFile platform_file = base::kInvalidPlatformFileValue;
134 callback.Run(base::File::FILE_ERROR_NOT_FOUND, 134 callback.Run(base::File::FILE_ERROR_NOT_FOUND,
135 base::PassPlatformFile(&platform_file), 135 base::PassPlatformFile(&platform_file),
136 base::Closure()); 136 base::Closure());
137 return; 137 return;
138 } 138 }
139 139
140 const fileapi_internal::FileSystemGetter getter =
141 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url);
140 PostFileSystemCallback( 142 PostFileSystemCallback(
141 file_system_getter_, 143 getter,
142 base::Bind(&fileapi_internal::OpenFile, 144 base::Bind(&fileapi_internal::OpenFile,
143 file_path, file_flags, 145 file_path, file_flags,
144 google_apis::CreateRelayCallback( 146 google_apis::CreateRelayCallback(
145 base::Bind(&RunCreateOrOpenFileCallback, 147 base::Bind(&RunCreateOrOpenFileCallback,
146 file_system_getter_, file_path, callback))), 148 getter, file_path, callback))),
147 base::Bind(&RunCreateOrOpenFileCallbackOnError, 149 base::Bind(&RunCreateOrOpenFileCallbackOnError,
148 callback, base::File::FILE_ERROR_FAILED)); 150 callback, base::File::FILE_ERROR_FAILED));
149 } 151 }
150 152
151 void AsyncFileUtil::EnsureFileExists( 153 void AsyncFileUtil::EnsureFileExists(
152 scoped_ptr<fileapi::FileSystemOperationContext> context, 154 scoped_ptr<fileapi::FileSystemOperationContext> context,
153 const fileapi::FileSystemURL& url, 155 const fileapi::FileSystemURL& url,
154 const EnsureFileExistsCallback& callback) { 156 const EnsureFileExistsCallback& callback) {
155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
156 158
157 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 159 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
158 if (file_path.empty()) { 160 if (file_path.empty()) {
159 callback.Run(base::File::FILE_ERROR_NOT_FOUND, false); 161 callback.Run(base::File::FILE_ERROR_NOT_FOUND, false);
160 return; 162 return;
161 } 163 }
162 164
163 PostFileSystemCallback( 165 PostFileSystemCallback(
164 file_system_getter_, 166 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
165 base::Bind(&fileapi_internal::CreateFile, 167 base::Bind(&fileapi_internal::CreateFile,
166 file_path, true /* is_exlusive */, 168 file_path, true /* is_exlusive */,
167 google_apis::CreateRelayCallback( 169 google_apis::CreateRelayCallback(
168 base::Bind(&RunEnsureFileExistsCallback, callback))), 170 base::Bind(&RunEnsureFileExistsCallback, callback))),
169 base::Bind(callback, base::File::FILE_ERROR_FAILED, false)); 171 base::Bind(callback, base::File::FILE_ERROR_FAILED, false));
170 } 172 }
171 173
172 void AsyncFileUtil::CreateDirectory( 174 void AsyncFileUtil::CreateDirectory(
173 scoped_ptr<fileapi::FileSystemOperationContext> context, 175 scoped_ptr<fileapi::FileSystemOperationContext> context,
174 const fileapi::FileSystemURL& url, 176 const fileapi::FileSystemURL& url,
175 bool exclusive, 177 bool exclusive,
176 bool recursive, 178 bool recursive,
177 const StatusCallback& callback) { 179 const StatusCallback& callback) {
178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
179 181
180 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 182 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
181 if (file_path.empty()) { 183 if (file_path.empty()) {
182 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 184 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
183 return; 185 return;
184 } 186 }
185 187
186 PostFileSystemCallback( 188 PostFileSystemCallback(
187 file_system_getter_, 189 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
188 base::Bind(&fileapi_internal::CreateDirectory, 190 base::Bind(&fileapi_internal::CreateDirectory,
189 file_path, exclusive, recursive, 191 file_path, exclusive, recursive,
190 google_apis::CreateRelayCallback(callback)), 192 google_apis::CreateRelayCallback(callback)),
191 base::Bind(callback, base::File::FILE_ERROR_FAILED)); 193 base::Bind(callback, base::File::FILE_ERROR_FAILED));
192 } 194 }
193 195
194 void AsyncFileUtil::GetFileInfo( 196 void AsyncFileUtil::GetFileInfo(
195 scoped_ptr<fileapi::FileSystemOperationContext> context, 197 scoped_ptr<fileapi::FileSystemOperationContext> context,
196 const fileapi::FileSystemURL& url, 198 const fileapi::FileSystemURL& url,
197 const GetFileInfoCallback& callback) { 199 const GetFileInfoCallback& callback) {
198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 200 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
199 201
200 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 202 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
201 if (file_path.empty()) { 203 if (file_path.empty()) {
202 callback.Run(base::File::FILE_ERROR_NOT_FOUND, base::File::Info()); 204 callback.Run(base::File::FILE_ERROR_NOT_FOUND, base::File::Info());
203 return; 205 return;
204 } 206 }
205 207
206 PostFileSystemCallback( 208 PostFileSystemCallback(
207 file_system_getter_, 209 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
208 base::Bind(&fileapi_internal::GetFileInfo, 210 base::Bind(&fileapi_internal::GetFileInfo,
209 file_path, google_apis::CreateRelayCallback(callback)), 211 file_path, google_apis::CreateRelayCallback(callback)),
210 base::Bind(callback, base::File::FILE_ERROR_FAILED, 212 base::Bind(callback, base::File::FILE_ERROR_FAILED,
211 base::File::Info())); 213 base::File::Info()));
212 } 214 }
213 215
214 void AsyncFileUtil::ReadDirectory( 216 void AsyncFileUtil::ReadDirectory(
215 scoped_ptr<fileapi::FileSystemOperationContext> context, 217 scoped_ptr<fileapi::FileSystemOperationContext> context,
216 const fileapi::FileSystemURL& url, 218 const fileapi::FileSystemURL& url,
217 const ReadDirectoryCallback& callback) { 219 const ReadDirectoryCallback& callback) {
218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 220 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
219 221
220 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 222 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
221 if (file_path.empty()) { 223 if (file_path.empty()) {
222 callback.Run(base::File::FILE_ERROR_NOT_FOUND, EntryList(), false); 224 callback.Run(base::File::FILE_ERROR_NOT_FOUND, EntryList(), false);
223 return; 225 return;
224 } 226 }
225 227
226 PostFileSystemCallback( 228 PostFileSystemCallback(
227 file_system_getter_, 229 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
228 base::Bind(&fileapi_internal::ReadDirectory, 230 base::Bind(&fileapi_internal::ReadDirectory,
229 file_path, google_apis::CreateRelayCallback(callback)), 231 file_path, google_apis::CreateRelayCallback(callback)),
230 base::Bind(callback, base::File::FILE_ERROR_FAILED, 232 base::Bind(callback, base::File::FILE_ERROR_FAILED,
231 EntryList(), false)); 233 EntryList(), false));
232 } 234 }
233 235
234 void AsyncFileUtil::Touch( 236 void AsyncFileUtil::Touch(
235 scoped_ptr<fileapi::FileSystemOperationContext> context, 237 scoped_ptr<fileapi::FileSystemOperationContext> context,
236 const fileapi::FileSystemURL& url, 238 const fileapi::FileSystemURL& url,
237 const base::Time& last_access_time, 239 const base::Time& last_access_time,
238 const base::Time& last_modified_time, 240 const base::Time& last_modified_time,
239 const StatusCallback& callback) { 241 const StatusCallback& callback) {
240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 242 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
241 243
242 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 244 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
243 if (file_path.empty()) { 245 if (file_path.empty()) {
244 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 246 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
245 return; 247 return;
246 } 248 }
247 249
248 PostFileSystemCallback( 250 PostFileSystemCallback(
249 file_system_getter_, 251 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
250 base::Bind(&fileapi_internal::TouchFile, 252 base::Bind(&fileapi_internal::TouchFile,
251 file_path, last_access_time, last_modified_time, 253 file_path, last_access_time, last_modified_time,
252 google_apis::CreateRelayCallback(callback)), 254 google_apis::CreateRelayCallback(callback)),
253 base::Bind(callback, base::File::FILE_ERROR_FAILED)); 255 base::Bind(callback, base::File::FILE_ERROR_FAILED));
254 } 256 }
255 257
256 void AsyncFileUtil::Truncate( 258 void AsyncFileUtil::Truncate(
257 scoped_ptr<fileapi::FileSystemOperationContext> context, 259 scoped_ptr<fileapi::FileSystemOperationContext> context,
258 const fileapi::FileSystemURL& url, 260 const fileapi::FileSystemURL& url,
259 int64 length, 261 int64 length,
260 const StatusCallback& callback) { 262 const StatusCallback& callback) {
261 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 263 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
262 264
263 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 265 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
264 if (file_path.empty()) { 266 if (file_path.empty()) {
265 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 267 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
266 return; 268 return;
267 } 269 }
268 270
269 PostFileSystemCallback( 271 PostFileSystemCallback(
270 file_system_getter_, 272 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
271 base::Bind(&fileapi_internal::Truncate, 273 base::Bind(&fileapi_internal::Truncate,
272 file_path, length, google_apis::CreateRelayCallback(callback)), 274 file_path, length, google_apis::CreateRelayCallback(callback)),
273 base::Bind(callback, base::File::FILE_ERROR_FAILED)); 275 base::Bind(callback, base::File::FILE_ERROR_FAILED));
274 } 276 }
275 277
276 void AsyncFileUtil::CopyFileLocal( 278 void AsyncFileUtil::CopyFileLocal(
277 scoped_ptr<fileapi::FileSystemOperationContext> context, 279 scoped_ptr<fileapi::FileSystemOperationContext> context,
278 const fileapi::FileSystemURL& src_url, 280 const fileapi::FileSystemURL& src_url,
279 const fileapi::FileSystemURL& dest_url, 281 const fileapi::FileSystemURL& dest_url,
280 CopyOrMoveOption option, 282 CopyOrMoveOption option,
281 const CopyFileProgressCallback& progress_callback, 283 const CopyFileProgressCallback& progress_callback,
282 const StatusCallback& callback) { 284 const StatusCallback& callback) {
283 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 285 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
284 286
285 base::FilePath src_path = util::ExtractDrivePathFromFileSystemUrl(src_url); 287 base::FilePath src_path = util::ExtractDrivePathFromFileSystemUrl(src_url);
286 base::FilePath dest_path = util::ExtractDrivePathFromFileSystemUrl(dest_url); 288 base::FilePath dest_path = util::ExtractDrivePathFromFileSystemUrl(dest_url);
287 if (src_path.empty() || dest_path.empty()) { 289 if (src_path.empty() || dest_path.empty()) {
288 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 290 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
289 return; 291 return;
290 } 292 }
291 293
294 // TODO(kinaba): crbug.com/339794.
295 // Assumption here is that |src_url| and |dest_url| are always from the same
296 // profile. This indeed holds as long as we mount different profiles onto
297 // different mount point. Hence, using GetFileSystemFromUrl(dest_url) is safe.
298 // This will change after we introduce cross-profile sharing etc., and we
299 // need to deal with files from different profiles here.
292 PostFileSystemCallback( 300 PostFileSystemCallback(
293 file_system_getter_, 301 base::Bind(&fileapi_internal::GetFileSystemFromUrl, dest_url),
294 base::Bind( 302 base::Bind(
295 &fileapi_internal::Copy, 303 &fileapi_internal::Copy,
296 src_path, dest_path, 304 src_path, dest_path,
297 option == fileapi::FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED, 305 option == fileapi::FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED,
298 google_apis::CreateRelayCallback(callback)), 306 google_apis::CreateRelayCallback(callback)),
299 base::Bind(callback, base::File::FILE_ERROR_FAILED)); 307 base::Bind(callback, base::File::FILE_ERROR_FAILED));
300 } 308 }
301 309
302 void AsyncFileUtil::MoveFileLocal( 310 void AsyncFileUtil::MoveFileLocal(
303 scoped_ptr<fileapi::FileSystemOperationContext> context, 311 scoped_ptr<fileapi::FileSystemOperationContext> context,
304 const fileapi::FileSystemURL& src_url, 312 const fileapi::FileSystemURL& src_url,
305 const fileapi::FileSystemURL& dest_url, 313 const fileapi::FileSystemURL& dest_url,
306 CopyOrMoveOption option, 314 CopyOrMoveOption option,
307 const StatusCallback& callback) { 315 const StatusCallback& callback) {
308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 316 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
309 317
310 base::FilePath src_path = util::ExtractDrivePathFromFileSystemUrl(src_url); 318 base::FilePath src_path = util::ExtractDrivePathFromFileSystemUrl(src_url);
311 base::FilePath dest_path = util::ExtractDrivePathFromFileSystemUrl(dest_url); 319 base::FilePath dest_path = util::ExtractDrivePathFromFileSystemUrl(dest_url);
312 if (src_path.empty() || dest_path.empty()) { 320 if (src_path.empty() || dest_path.empty()) {
313 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 321 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
314 return; 322 return;
315 } 323 }
316 324
325 // TODO(kinaba): see the comment in CopyFileLocal(). |src_url| and |dest_url|
326 // always return the same FileSystem by GetFileSystemFromUrl, but we need to
327 // change it in order to support cross-profile file sharing etc.
317 PostFileSystemCallback( 328 PostFileSystemCallback(
318 file_system_getter_, 329 base::Bind(&fileapi_internal::GetFileSystemFromUrl, dest_url),
319 base::Bind( 330 base::Bind(
320 &fileapi_internal::Move, 331 &fileapi_internal::Move,
321 src_path, dest_path, 332 src_path, dest_path,
322 option == fileapi::FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED, 333 option == fileapi::FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED,
323 google_apis::CreateRelayCallback(callback)), 334 google_apis::CreateRelayCallback(callback)),
324 base::Bind(callback, base::File::FILE_ERROR_FAILED)); 335 base::Bind(callback, base::File::FILE_ERROR_FAILED));
325 } 336 }
326 337
327 void AsyncFileUtil::CopyInForeignFile( 338 void AsyncFileUtil::CopyInForeignFile(
328 scoped_ptr<fileapi::FileSystemOperationContext> context, 339 scoped_ptr<fileapi::FileSystemOperationContext> context,
329 const base::FilePath& src_file_path, 340 const base::FilePath& src_file_path,
330 const fileapi::FileSystemURL& dest_url, 341 const fileapi::FileSystemURL& dest_url,
331 const StatusCallback& callback) { 342 const StatusCallback& callback) {
332 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 343 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
333 344
334 base::FilePath dest_path = util::ExtractDrivePathFromFileSystemUrl(dest_url); 345 base::FilePath dest_path = util::ExtractDrivePathFromFileSystemUrl(dest_url);
335 if (dest_path.empty()) { 346 if (dest_path.empty()) {
336 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 347 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
337 return; 348 return;
338 } 349 }
339 350
340 PostFileSystemCallback( 351 PostFileSystemCallback(
341 file_system_getter_, 352 base::Bind(&fileapi_internal::GetFileSystemFromUrl, dest_url),
342 base::Bind(&fileapi_internal::CopyInForeignFile, 353 base::Bind(&fileapi_internal::CopyInForeignFile,
343 src_file_path, dest_path, 354 src_file_path, dest_path,
344 google_apis::CreateRelayCallback(callback)), 355 google_apis::CreateRelayCallback(callback)),
345 base::Bind(callback, base::File::FILE_ERROR_FAILED)); 356 base::Bind(callback, base::File::FILE_ERROR_FAILED));
346 } 357 }
347 358
348 void AsyncFileUtil::DeleteFile( 359 void AsyncFileUtil::DeleteFile(
349 scoped_ptr<fileapi::FileSystemOperationContext> context, 360 scoped_ptr<fileapi::FileSystemOperationContext> context,
350 const fileapi::FileSystemURL& url, 361 const fileapi::FileSystemURL& url,
351 const StatusCallback& callback) { 362 const StatusCallback& callback) {
352 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 363 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
353 364
354 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 365 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
355 if (file_path.empty()) { 366 if (file_path.empty()) {
356 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 367 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
357 return; 368 return;
358 } 369 }
359 370
360 PostFileSystemCallback( 371 PostFileSystemCallback(
361 file_system_getter_, 372 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
362 base::Bind(&fileapi_internal::Remove, 373 base::Bind(&fileapi_internal::Remove,
363 file_path, false /* not recursive */, 374 file_path, false /* not recursive */,
364 google_apis::CreateRelayCallback(callback)), 375 google_apis::CreateRelayCallback(callback)),
365 base::Bind(callback, base::File::FILE_ERROR_FAILED)); 376 base::Bind(callback, base::File::FILE_ERROR_FAILED));
366 } 377 }
367 378
368 void AsyncFileUtil::DeleteDirectory( 379 void AsyncFileUtil::DeleteDirectory(
369 scoped_ptr<fileapi::FileSystemOperationContext> context, 380 scoped_ptr<fileapi::FileSystemOperationContext> context,
370 const fileapi::FileSystemURL& url, 381 const fileapi::FileSystemURL& url,
371 const StatusCallback& callback) { 382 const StatusCallback& callback) {
372 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 383 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
373 384
374 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 385 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
375 if (file_path.empty()) { 386 if (file_path.empty()) {
376 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 387 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
377 return; 388 return;
378 } 389 }
379 390
380 PostFileSystemCallback( 391 PostFileSystemCallback(
381 file_system_getter_, 392 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
382 base::Bind(&fileapi_internal::Remove, 393 base::Bind(&fileapi_internal::Remove,
383 file_path, false /* not recursive */, 394 file_path, false /* not recursive */,
384 google_apis::CreateRelayCallback(callback)), 395 google_apis::CreateRelayCallback(callback)),
385 base::Bind(callback, base::File::FILE_ERROR_FAILED)); 396 base::Bind(callback, base::File::FILE_ERROR_FAILED));
386 } 397 }
387 398
388 void AsyncFileUtil::DeleteRecursively( 399 void AsyncFileUtil::DeleteRecursively(
389 scoped_ptr<fileapi::FileSystemOperationContext> context, 400 scoped_ptr<fileapi::FileSystemOperationContext> context,
390 const fileapi::FileSystemURL& url, 401 const fileapi::FileSystemURL& url,
391 const StatusCallback& callback) { 402 const StatusCallback& callback) {
392 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 403 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
393 404
394 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 405 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
395 if (file_path.empty()) { 406 if (file_path.empty()) {
396 callback.Run(base::File::FILE_ERROR_NOT_FOUND); 407 callback.Run(base::File::FILE_ERROR_NOT_FOUND);
397 return; 408 return;
398 } 409 }
399 410
400 PostFileSystemCallback( 411 PostFileSystemCallback(
401 file_system_getter_, 412 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
402 base::Bind(&fileapi_internal::Remove, 413 base::Bind(&fileapi_internal::Remove,
403 file_path, true /* recursive */, 414 file_path, true /* recursive */,
404 google_apis::CreateRelayCallback(callback)), 415 google_apis::CreateRelayCallback(callback)),
405 base::Bind(callback, base::File::FILE_ERROR_FAILED)); 416 base::Bind(callback, base::File::FILE_ERROR_FAILED));
406 } 417 }
407 418
408 void AsyncFileUtil::CreateSnapshotFile( 419 void AsyncFileUtil::CreateSnapshotFile(
409 scoped_ptr<fileapi::FileSystemOperationContext> context, 420 scoped_ptr<fileapi::FileSystemOperationContext> context,
410 const fileapi::FileSystemURL& url, 421 const fileapi::FileSystemURL& url,
411 const CreateSnapshotFileCallback& callback) { 422 const CreateSnapshotFileCallback& callback) {
412 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 423 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
413 424
414 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); 425 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
415 if (file_path.empty()) { 426 if (file_path.empty()) {
416 callback.Run(base::File::FILE_ERROR_NOT_FOUND, 427 callback.Run(base::File::FILE_ERROR_NOT_FOUND,
417 base::File::Info(), 428 base::File::Info(),
418 base::FilePath(), 429 base::FilePath(),
419 scoped_refptr<webkit_blob::ShareableFileReference>()); 430 scoped_refptr<webkit_blob::ShareableFileReference>());
420 return; 431 return;
421 } 432 }
422 433
423 PostFileSystemCallback( 434 PostFileSystemCallback(
424 file_system_getter_, 435 base::Bind(&fileapi_internal::GetFileSystemFromUrl, url),
425 base::Bind(&fileapi_internal::CreateSnapshotFile, 436 base::Bind(&fileapi_internal::CreateSnapshotFile,
426 file_path, 437 file_path,
427 google_apis::CreateRelayCallback( 438 google_apis::CreateRelayCallback(
428 base::Bind(&RunCreateSnapshotFileCallback, callback))), 439 base::Bind(&RunCreateSnapshotFileCallback, callback))),
429 base::Bind(callback, 440 base::Bind(callback,
430 base::File::FILE_ERROR_FAILED, 441 base::File::FILE_ERROR_FAILED,
431 base::File::Info(), 442 base::File::Info(),
432 base::FilePath(), 443 base::FilePath(),
433 scoped_refptr<webkit_blob::ShareableFileReference>())); 444 scoped_refptr<webkit_blob::ShareableFileReference>()));
434 } 445 }
435 446
436 } // namespace internal 447 } // namespace internal
437 } // namespace drive 448 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698