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

Side by Side Diff: chrome/browser/chromeos/drive/file_system_proxy.cc

Issue 14755002: drive: Drop "Drive" from FakeDriveFileSystem and MockDriveFileSystem (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: some more cleanup Created 7 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/file_system_proxy.h" 5 #include "chrome/browser/chromeos/drive/file_system_proxy.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 if (!ValidateUrl(file_url, &file_path)) { 186 if (!ValidateUrl(file_url, &file_path)) {
187 MessageLoopProxy::current()->PostTask( 187 MessageLoopProxy::current()->PostTask(
188 FROM_HERE, 188 FROM_HERE,
189 base::Bind(callback, 189 base::Bind(callback,
190 base::PLATFORM_FILE_ERROR_NOT_FOUND, 190 base::PLATFORM_FILE_ERROR_NOT_FOUND,
191 base::PlatformFileInfo(), 191 base::PlatformFileInfo(),
192 base::FilePath())); 192 base::FilePath()));
193 return; 193 return;
194 } 194 }
195 195
196 CallDriveFileSystemMethodOnUIThread( 196 CallFileSystemMethodOnUIThread(
197 base::Bind(&DriveFileSystemInterface::GetEntryInfoByPath, 197 base::Bind(&DriveFileSystemInterface::GetEntryInfoByPath,
198 base::Unretained(file_system_), 198 base::Unretained(file_system_),
199 file_path, 199 file_path,
200 google_apis::CreateRelayCallback( 200 google_apis::CreateRelayCallback(
201 base::Bind(&FileSystemProxy::OnGetMetadata, 201 base::Bind(&FileSystemProxy::OnGetMetadata,
202 this, 202 this,
203 file_path, 203 file_path,
204 callback)))); 204 callback))));
205 } 205 }
206 206
207 void FileSystemProxy::Copy( 207 void FileSystemProxy::Copy(
208 const FileSystemURL& src_file_url, 208 const FileSystemURL& src_file_url,
209 const FileSystemURL& dest_file_url, 209 const FileSystemURL& dest_file_url,
210 const FileSystemOperation::StatusCallback& callback) { 210 const FileSystemOperation::StatusCallback& callback) {
211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
212 212
213 base::FilePath src_file_path, dest_file_path; 213 base::FilePath src_file_path, dest_file_path;
214 if (!ValidateUrl(src_file_url, &src_file_path) || 214 if (!ValidateUrl(src_file_url, &src_file_path) ||
215 !ValidateUrl(dest_file_url, &dest_file_path)) { 215 !ValidateUrl(dest_file_url, &dest_file_path)) {
216 MessageLoopProxy::current()->PostTask( 216 MessageLoopProxy::current()->PostTask(
217 FROM_HERE, 217 FROM_HERE,
218 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND)); 218 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND));
219 return; 219 return;
220 } 220 }
221 221
222 CallDriveFileSystemMethodOnUIThread( 222 CallFileSystemMethodOnUIThread(
223 base::Bind(&DriveFileSystemInterface::Copy, 223 base::Bind(&DriveFileSystemInterface::Copy,
224 base::Unretained(file_system_), 224 base::Unretained(file_system_),
225 src_file_path, 225 src_file_path,
226 dest_file_path, 226 dest_file_path,
227 google_apis::CreateRelayCallback( 227 google_apis::CreateRelayCallback(
228 base::Bind(&FileSystemProxy::OnStatusCallback, 228 base::Bind(&FileSystemProxy::OnStatusCallback,
229 this, 229 this,
230 callback)))); 230 callback))));
231 } 231 }
232 232
233 void FileSystemProxy::Move( 233 void FileSystemProxy::Move(
234 const FileSystemURL& src_file_url, 234 const FileSystemURL& src_file_url,
235 const FileSystemURL& dest_file_url, 235 const FileSystemURL& dest_file_url,
236 const FileSystemOperation::StatusCallback& callback) { 236 const FileSystemOperation::StatusCallback& callback) {
237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
238 238
239 base::FilePath src_file_path, dest_file_path; 239 base::FilePath src_file_path, dest_file_path;
240 if (!ValidateUrl(src_file_url, &src_file_path) || 240 if (!ValidateUrl(src_file_url, &src_file_path) ||
241 !ValidateUrl(dest_file_url, &dest_file_path)) { 241 !ValidateUrl(dest_file_url, &dest_file_path)) {
242 MessageLoopProxy::current()->PostTask( 242 MessageLoopProxy::current()->PostTask(
243 FROM_HERE, 243 FROM_HERE,
244 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND)); 244 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND));
245 return; 245 return;
246 } 246 }
247 247
248 CallDriveFileSystemMethodOnUIThread( 248 CallFileSystemMethodOnUIThread(
249 base::Bind(&DriveFileSystemInterface::Move, 249 base::Bind(&DriveFileSystemInterface::Move,
250 base::Unretained(file_system_), 250 base::Unretained(file_system_),
251 src_file_path, 251 src_file_path,
252 dest_file_path, 252 dest_file_path,
253 google_apis::CreateRelayCallback( 253 google_apis::CreateRelayCallback(
254 base::Bind(&FileSystemProxy::OnStatusCallback, 254 base::Bind(&FileSystemProxy::OnStatusCallback,
255 this, 255 this,
256 callback)))); 256 callback))));
257 } 257 }
258 258
259 void FileSystemProxy::ReadDirectory( 259 void FileSystemProxy::ReadDirectory(
260 const FileSystemURL& file_url, 260 const FileSystemURL& file_url,
261 const FileSystemOperation::ReadDirectoryCallback& callback) { 261 const FileSystemOperation::ReadDirectoryCallback& callback) {
262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
263 263
264 base::FilePath file_path; 264 base::FilePath file_path;
265 if (!ValidateUrl(file_url, &file_path)) { 265 if (!ValidateUrl(file_url, &file_path)) {
266 base::MessageLoopProxy::current()->PostTask( 266 base::MessageLoopProxy::current()->PostTask(
267 FROM_HERE, 267 FROM_HERE,
268 base::Bind(callback, 268 base::Bind(callback,
269 base::PLATFORM_FILE_ERROR_NOT_FOUND, 269 base::PLATFORM_FILE_ERROR_NOT_FOUND,
270 std::vector<base::FileUtilProxy::Entry>(), 270 std::vector<base::FileUtilProxy::Entry>(),
271 false)); 271 false));
272 return; 272 return;
273 } 273 }
274 274
275 CallDriveFileSystemMethodOnUIThread( 275 CallFileSystemMethodOnUIThread(
276 base::Bind(&DriveFileSystemInterface::ReadDirectoryByPath, 276 base::Bind(&DriveFileSystemInterface::ReadDirectoryByPath,
277 base::Unretained(file_system_), 277 base::Unretained(file_system_),
278 file_path, 278 file_path,
279 google_apis::CreateRelayCallback( 279 google_apis::CreateRelayCallback(
280 base::Bind(&FileSystemProxy::OnReadDirectory, 280 base::Bind(&FileSystemProxy::OnReadDirectory,
281 this, 281 this,
282 callback)))); 282 callback))));
283 } 283 }
284 284
285 void FileSystemProxy::Remove( 285 void FileSystemProxy::Remove(
286 const FileSystemURL& file_url, 286 const FileSystemURL& file_url,
287 bool recursive, 287 bool recursive,
288 const FileSystemOperation::StatusCallback& callback) { 288 const FileSystemOperation::StatusCallback& callback) {
289 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 289 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
290 290
291 base::FilePath file_path; 291 base::FilePath file_path;
292 if (!ValidateUrl(file_url, &file_path)) { 292 if (!ValidateUrl(file_url, &file_path)) {
293 MessageLoopProxy::current()->PostTask( 293 MessageLoopProxy::current()->PostTask(
294 FROM_HERE, 294 FROM_HERE,
295 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND)); 295 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND));
296 return; 296 return;
297 } 297 }
298 298
299 CallDriveFileSystemMethodOnUIThread( 299 CallFileSystemMethodOnUIThread(
300 base::Bind(&DriveFileSystemInterface::Remove, 300 base::Bind(&DriveFileSystemInterface::Remove,
301 base::Unretained(file_system_), 301 base::Unretained(file_system_),
302 file_path, 302 file_path,
303 recursive, 303 recursive,
304 google_apis::CreateRelayCallback( 304 google_apis::CreateRelayCallback(
305 base::Bind(&FileSystemProxy::OnStatusCallback, 305 base::Bind(&FileSystemProxy::OnStatusCallback,
306 this, 306 this,
307 callback)))); 307 callback))));
308 } 308 }
309 309
310 void FileSystemProxy::CreateDirectory( 310 void FileSystemProxy::CreateDirectory(
311 const FileSystemURL& file_url, 311 const FileSystemURL& file_url,
312 bool exclusive, 312 bool exclusive,
313 bool recursive, 313 bool recursive,
314 const FileSystemOperation::StatusCallback& callback) { 314 const FileSystemOperation::StatusCallback& callback) {
315 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 315 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
316 316
317 base::FilePath file_path; 317 base::FilePath file_path;
318 if (!ValidateUrl(file_url, &file_path)) { 318 if (!ValidateUrl(file_url, &file_path)) {
319 MessageLoopProxy::current()->PostTask( 319 MessageLoopProxy::current()->PostTask(
320 FROM_HERE, 320 FROM_HERE,
321 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND)); 321 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND));
322 return; 322 return;
323 } 323 }
324 324
325 CallDriveFileSystemMethodOnUIThread( 325 CallFileSystemMethodOnUIThread(
326 base::Bind(&DriveFileSystemInterface::CreateDirectory, 326 base::Bind(&DriveFileSystemInterface::CreateDirectory,
327 base::Unretained(file_system_), 327 base::Unretained(file_system_),
328 file_path, 328 file_path,
329 exclusive, 329 exclusive,
330 recursive, 330 recursive,
331 google_apis::CreateRelayCallback( 331 google_apis::CreateRelayCallback(
332 base::Bind(&FileSystemProxy::OnStatusCallback, 332 base::Bind(&FileSystemProxy::OnStatusCallback,
333 this, 333 this,
334 callback)))); 334 callback))));
335 } 335 }
336 336
337 void FileSystemProxy::CreateFile( 337 void FileSystemProxy::CreateFile(
338 const FileSystemURL& file_url, 338 const FileSystemURL& file_url,
339 bool exclusive, 339 bool exclusive,
340 const FileSystemOperation::StatusCallback& callback) { 340 const FileSystemOperation::StatusCallback& callback) {
341 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 341 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
342 342
343 base::FilePath file_path; 343 base::FilePath file_path;
344 if (!ValidateUrl(file_url, &file_path)) { 344 if (!ValidateUrl(file_url, &file_path)) {
345 MessageLoopProxy::current()->PostTask( 345 MessageLoopProxy::current()->PostTask(
346 FROM_HERE, 346 FROM_HERE,
347 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND)); 347 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND));
348 return; 348 return;
349 } 349 }
350 350
351 CallDriveFileSystemMethodOnUIThread( 351 CallFileSystemMethodOnUIThread(
352 base::Bind(&DriveFileSystemInterface::CreateFile, 352 base::Bind(&DriveFileSystemInterface::CreateFile,
353 base::Unretained(file_system_), 353 base::Unretained(file_system_),
354 file_path, 354 file_path,
355 exclusive, 355 exclusive,
356 google_apis::CreateRelayCallback( 356 google_apis::CreateRelayCallback(
357 base::Bind(&FileSystemProxy::OnStatusCallback, 357 base::Bind(&FileSystemProxy::OnStatusCallback,
358 this, 358 this,
359 callback)))); 359 callback))));
360 } 360 }
361 361
(...skipping 14 matching lines...) Expand all
376 if (!ValidateUrl(file_url, &file_path)) { 376 if (!ValidateUrl(file_url, &file_path)) {
377 MessageLoopProxy::current()->PostTask( 377 MessageLoopProxy::current()->PostTask(
378 FROM_HERE, 378 FROM_HERE,
379 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND)); 379 base::Bind(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND));
380 return; 380 return;
381 } 381 }
382 382
383 // TODO(kinaba): http://crbug.com/132780. 383 // TODO(kinaba): http://crbug.com/132780.
384 // Optimize the cases for small |length|, at least for |length| == 0. 384 // Optimize the cases for small |length|, at least for |length| == 0.
385 // CreateWritableSnapshotFile downloads the whole content unnecessarily. 385 // CreateWritableSnapshotFile downloads the whole content unnecessarily.
386 CallDriveFileSystemMethodOnUIThread( 386 CallFileSystemMethodOnUIThread(
387 base::Bind(&DriveFileSystemInterface::OpenFile, 387 base::Bind(&DriveFileSystemInterface::OpenFile,
388 base::Unretained(file_system_), 388 base::Unretained(file_system_),
389 file_path, 389 file_path,
390 google_apis::CreateRelayCallback( 390 google_apis::CreateRelayCallback(
391 base::Bind(&FileSystemProxy::OnFileOpenedForTruncate, 391 base::Bind(&FileSystemProxy::OnFileOpenedForTruncate,
392 this, 392 this,
393 file_path, 393 file_path,
394 length, 394 length,
395 callback)))); 395 callback))));
396 } 396 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 // if it really exists open it as truncated. 445 // if it really exists open it as truncated.
446 file_flags &= ~base::PLATFORM_FILE_CREATE; 446 file_flags &= ~base::PLATFORM_FILE_CREATE;
447 file_flags &= ~base::PLATFORM_FILE_CREATE_ALWAYS; 447 file_flags &= ~base::PLATFORM_FILE_CREATE_ALWAYS;
448 file_flags |= base::PLATFORM_FILE_OPEN_TRUNCATED; 448 file_flags |= base::PLATFORM_FILE_OPEN_TRUNCATED;
449 } else { 449 } else {
450 callback.Run(create_result, base::kInvalidPlatformFileValue, peer_handle); 450 callback.Run(create_result, base::kInvalidPlatformFileValue, peer_handle);
451 return; 451 return;
452 } 452 }
453 453
454 // Open created (or existing) file for writing. 454 // Open created (or existing) file for writing.
455 CallDriveFileSystemMethodOnUIThread( 455 CallFileSystemMethodOnUIThread(
456 base::Bind(&DriveFileSystemInterface::OpenFile, 456 base::Bind(&DriveFileSystemInterface::OpenFile,
457 base::Unretained(file_system_), 457 base::Unretained(file_system_),
458 file_path, 458 file_path,
459 google_apis::CreateRelayCallback( 459 google_apis::CreateRelayCallback(
460 base::Bind(&FileSystemProxy::OnOpenFileForWriting, 460 base::Bind(&FileSystemProxy::OnOpenFileForWriting,
461 this, 461 this,
462 file_flags, 462 file_flags,
463 peer_handle, 463 peer_handle,
464 callback)))); 464 callback))));
465 } 465 }
(...skipping 26 matching lines...) Expand all
492 } 492 }
493 493
494 void FileSystemProxy::DidTruncate( 494 void FileSystemProxy::DidTruncate(
495 const base::FilePath& virtual_path, 495 const base::FilePath& virtual_path,
496 const FileSystemOperation::StatusCallback& callback, 496 const FileSystemOperation::StatusCallback& callback,
497 base::PlatformFileError truncate_result) { 497 base::PlatformFileError truncate_result) {
498 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 498 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
499 499
500 // Truncation finished. We must close the file no matter |truncate_result| 500 // Truncation finished. We must close the file no matter |truncate_result|
501 // indicates an error or not. 501 // indicates an error or not.
502 CallDriveFileSystemMethodOnUIThread( 502 CallFileSystemMethodOnUIThread(
503 base::Bind(&DriveFileSystemInterface::CloseFile, 503 base::Bind(&DriveFileSystemInterface::CloseFile,
504 base::Unretained(file_system_), 504 base::Unretained(file_system_),
505 virtual_path, 505 virtual_path,
506 google_apis::CreateRelayCallback( 506 google_apis::CreateRelayCallback(
507 base::Bind(&DidCloseFileForTruncate, 507 base::Bind(&DidCloseFileForTruncate,
508 callback, 508 callback,
509 truncate_result)))); 509 truncate_result))));
510 } 510 }
511 511
512 void FileSystemProxy::OpenFile( 512 void FileSystemProxy::OpenFile(
(...skipping 28 matching lines...) Expand all
541 } 541 }
542 542
543 if ((file_flags & base::PLATFORM_FILE_OPEN) || 543 if ((file_flags & base::PLATFORM_FILE_OPEN) ||
544 (file_flags & base::PLATFORM_FILE_OPEN_ALWAYS) || 544 (file_flags & base::PLATFORM_FILE_OPEN_ALWAYS) ||
545 (file_flags & base::PLATFORM_FILE_OPEN_TRUNCATED)) { 545 (file_flags & base::PLATFORM_FILE_OPEN_TRUNCATED)) {
546 if ((file_flags & base::PLATFORM_FILE_OPEN_TRUNCATED) || 546 if ((file_flags & base::PLATFORM_FILE_OPEN_TRUNCATED) ||
547 (file_flags & base::PLATFORM_FILE_OPEN_ALWAYS) || 547 (file_flags & base::PLATFORM_FILE_OPEN_ALWAYS) ||
548 (file_flags & base::PLATFORM_FILE_WRITE) || 548 (file_flags & base::PLATFORM_FILE_WRITE) ||
549 (file_flags & base::PLATFORM_FILE_EXCLUSIVE_WRITE)) { 549 (file_flags & base::PLATFORM_FILE_EXCLUSIVE_WRITE)) {
550 // Open existing file for writing. 550 // Open existing file for writing.
551 CallDriveFileSystemMethodOnUIThread( 551 CallFileSystemMethodOnUIThread(
552 base::Bind(&DriveFileSystemInterface::OpenFile, 552 base::Bind(&DriveFileSystemInterface::OpenFile,
553 base::Unretained(file_system_), 553 base::Unretained(file_system_),
554 file_path, 554 file_path,
555 google_apis::CreateRelayCallback( 555 google_apis::CreateRelayCallback(
556 base::Bind(&FileSystemProxy::OnOpenFileForWriting, 556 base::Bind(&FileSystemProxy::OnOpenFileForWriting,
557 this, 557 this,
558 file_flags, 558 file_flags,
559 peer_handle, 559 peer_handle,
560 callback)))); 560 callback))));
561 } else { 561 } else {
562 // Read-only file open. 562 // Read-only file open.
563 CallDriveFileSystemMethodOnUIThread( 563 CallFileSystemMethodOnUIThread(
564 base::Bind(&DriveFileSystemInterface::GetFileByPath, 564 base::Bind(&DriveFileSystemInterface::GetFileByPath,
565 base::Unretained(file_system_), 565 base::Unretained(file_system_),
566 file_path, 566 file_path,
567 google_apis::CreateRelayCallback( 567 google_apis::CreateRelayCallback(
568 base::Bind(&OnGetFileByPathForOpen, 568 base::Bind(&OnGetFileByPathForOpen,
569 callback, 569 callback,
570 file_flags, 570 file_flags,
571 peer_handle)))); 571 peer_handle))));
572 } 572 }
573 } else if ((file_flags & base::PLATFORM_FILE_CREATE) || 573 } else if ((file_flags & base::PLATFORM_FILE_CREATE) ||
574 (file_flags & base::PLATFORM_FILE_CREATE_ALWAYS)) { 574 (file_flags & base::PLATFORM_FILE_CREATE_ALWAYS)) {
575 // Open existing file for writing. 575 // Open existing file for writing.
576 CallDriveFileSystemMethodOnUIThread( 576 CallFileSystemMethodOnUIThread(
577 base::Bind(&DriveFileSystemInterface::CreateFile, 577 base::Bind(&DriveFileSystemInterface::CreateFile,
578 base::Unretained(file_system_), 578 base::Unretained(file_system_),
579 file_path, 579 file_path,
580 file_flags & base::PLATFORM_FILE_EXCLUSIVE_WRITE, 580 file_flags & base::PLATFORM_FILE_EXCLUSIVE_WRITE,
581 google_apis::CreateRelayCallback( 581 google_apis::CreateRelayCallback(
582 base::Bind(&FileSystemProxy::OnCreateFileForOpen, 582 base::Bind(&FileSystemProxy::OnCreateFileForOpen,
583 this, 583 this,
584 file_path, 584 file_path,
585 file_flags, 585 file_flags,
586 peer_handle, 586 peer_handle,
587 callback)))); 587 callback))));
588 } else { 588 } else {
589 NOTREACHED() << "Unhandled file flags combination " << file_flags; 589 NOTREACHED() << "Unhandled file flags combination " << file_flags;
590 MessageLoopProxy::current()->PostTask( 590 MessageLoopProxy::current()->PostTask(
591 FROM_HERE, 591 FROM_HERE,
592 base::Bind(callback, 592 base::Bind(callback,
593 base::PLATFORM_FILE_ERROR_FAILED, 593 base::PLATFORM_FILE_ERROR_FAILED,
594 base::kInvalidPlatformFileValue, 594 base::kInvalidPlatformFileValue,
595 peer_handle)); 595 peer_handle));
596 } 596 }
597 } 597 }
598 598
599 void FileSystemProxy::NotifyCloseFile(const FileSystemURL& url) { 599 void FileSystemProxy::NotifyCloseFile(const FileSystemURL& url) {
600 base::FilePath file_path; 600 base::FilePath file_path;
601 if (!ValidateUrl(url, &file_path)) 601 if (!ValidateUrl(url, &file_path))
602 return; 602 return;
603 603
604 CallDriveFileSystemMethodOnUIThread( 604 CallFileSystemMethodOnUIThread(
605 base::Bind(&DriveFileSystemInterface::CloseFile, 605 base::Bind(&DriveFileSystemInterface::CloseFile,
606 base::Unretained(file_system_), 606 base::Unretained(file_system_),
607 file_path, 607 file_path,
608 google_apis::CreateRelayCallback( 608 google_apis::CreateRelayCallback(
609 base::Bind(&EmitDebugLogForCloseFile, 609 base::Bind(&EmitDebugLogForCloseFile,
610 file_path)))); 610 file_path))));
611 } 611 }
612 612
613 void FileSystemProxy::TouchFile( 613 void FileSystemProxy::TouchFile(
614 const fileapi::FileSystemURL& url, 614 const fileapi::FileSystemURL& url,
(...skipping 19 matching lines...) Expand all
634 MessageLoopProxy::current()->PostTask( 634 MessageLoopProxy::current()->PostTask(
635 FROM_HERE, 635 FROM_HERE,
636 base::Bind(callback, 636 base::Bind(callback,
637 base::PLATFORM_FILE_ERROR_NOT_FOUND, 637 base::PLATFORM_FILE_ERROR_NOT_FOUND,
638 base::PlatformFileInfo(), 638 base::PlatformFileInfo(),
639 base::FilePath(), 639 base::FilePath(),
640 scoped_refptr<ShareableFileReference>(NULL))); 640 scoped_refptr<ShareableFileReference>(NULL)));
641 return; 641 return;
642 } 642 }
643 643
644 CallDriveFileSystemMethodOnUIThread( 644 CallFileSystemMethodOnUIThread(
645 base::Bind(&DriveFileSystemInterface::GetEntryInfoByPath, 645 base::Bind(&DriveFileSystemInterface::GetEntryInfoByPath,
646 base::Unretained(file_system_), 646 base::Unretained(file_system_),
647 file_path, 647 file_path,
648 google_apis::CreateRelayCallback( 648 google_apis::CreateRelayCallback(
649 base::Bind(&FileSystemProxy::OnGetEntryInfoByPath, 649 base::Bind(&FileSystemProxy::OnGetEntryInfoByPath,
650 this, 650 this,
651 file_path, 651 file_path,
652 callback)))); 652 callback))));
653 } 653 }
654 654
655 void FileSystemProxy::OnGetEntryInfoByPath( 655 void FileSystemProxy::OnGetEntryInfoByPath(
656 const base::FilePath& entry_path, 656 const base::FilePath& entry_path,
657 const FileSystemOperation::SnapshotFileCallback& callback, 657 const FileSystemOperation::SnapshotFileCallback& callback,
658 FileError error, 658 FileError error,
659 scoped_ptr<DriveEntryProto> entry_proto) { 659 scoped_ptr<DriveEntryProto> entry_proto) {
660 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 660 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
661 661
662 if (error != FILE_ERROR_OK || !entry_proto.get()) { 662 if (error != FILE_ERROR_OK || !entry_proto.get()) {
663 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, 663 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND,
664 base::PlatformFileInfo(), 664 base::PlatformFileInfo(),
665 base::FilePath(), 665 base::FilePath(),
666 scoped_refptr<ShareableFileReference>(NULL)); 666 scoped_refptr<ShareableFileReference>(NULL));
667 return; 667 return;
668 } 668 }
669 669
670 base::PlatformFileInfo file_info; 670 base::PlatformFileInfo file_info;
671 util::ConvertProtoToPlatformFileInfo(entry_proto->file_info(), &file_info); 671 util::ConvertProtoToPlatformFileInfo(entry_proto->file_info(), &file_info);
672 672
673 CallDriveFileSystemMethodOnUIThread( 673 CallFileSystemMethodOnUIThread(
674 base::Bind(&DriveFileSystemInterface::GetFileByPath, 674 base::Bind(&DriveFileSystemInterface::GetFileByPath,
675 base::Unretained(file_system_), 675 base::Unretained(file_system_),
676 entry_path, 676 entry_path,
677 google_apis::CreateRelayCallback( 677 google_apis::CreateRelayCallback(
678 base::Bind(&CallSnapshotFileCallback, 678 base::Bind(&CallSnapshotFileCallback,
679 callback, 679 callback,
680 file_info)))); 680 file_info))));
681 } 681 }
682 682
683 void FileSystemProxy::CreateWritableSnapshotFile( 683 void FileSystemProxy::CreateWritableSnapshotFile(
684 const FileSystemURL& file_url, 684 const FileSystemURL& file_url,
685 const fileapi::WritableSnapshotFile& callback) { 685 const fileapi::WritableSnapshotFile& callback) {
686 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 686 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
687 687
688 base::FilePath file_path; 688 base::FilePath file_path;
689 if (!ValidateUrl(file_url, &file_path)) { 689 if (!ValidateUrl(file_url, &file_path)) {
690 MessageLoopProxy::current()->PostTask( 690 MessageLoopProxy::current()->PostTask(
691 FROM_HERE, 691 FROM_HERE,
692 base::Bind(callback, 692 base::Bind(callback,
693 base::PLATFORM_FILE_ERROR_NOT_FOUND, 693 base::PLATFORM_FILE_ERROR_NOT_FOUND,
694 base::FilePath(), 694 base::FilePath(),
695 scoped_refptr<ShareableFileReference>(NULL))); 695 scoped_refptr<ShareableFileReference>(NULL)));
696 return; 696 return;
697 } 697 }
698 698
699 CallDriveFileSystemMethodOnUIThread( 699 CallFileSystemMethodOnUIThread(
700 base::Bind(&DriveFileSystemInterface::OpenFile, 700 base::Bind(&DriveFileSystemInterface::OpenFile,
701 base::Unretained(file_system_), 701 base::Unretained(file_system_),
702 file_path, 702 file_path,
703 google_apis::CreateRelayCallback( 703 google_apis::CreateRelayCallback(
704 base::Bind( 704 base::Bind(
705 &FileSystemProxy::OnCreateWritableSnapshotFile, 705 &FileSystemProxy::OnCreateWritableSnapshotFile,
706 this, 706 this,
707 file_path, 707 file_path,
708 callback)))); 708 callback))));
709 } 709 }
710 710
711 FileSystemProxy::~FileSystemProxy() { 711 FileSystemProxy::~FileSystemProxy() {
712 // Should be deleted from the CrosMountPointProvider on UI thread. 712 // Should be deleted from the CrosMountPointProvider on UI thread.
713 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 713 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
714 } 714 }
715 715
716 // static. 716 // static.
717 bool FileSystemProxy::ValidateUrl( 717 bool FileSystemProxy::ValidateUrl(
718 const FileSystemURL& url, base::FilePath* file_path) { 718 const FileSystemURL& url, base::FilePath* file_path) {
719 *file_path = util::ExtractDrivePathFromFileSystemUrl(url); 719 *file_path = util::ExtractDrivePathFromFileSystemUrl(url);
720 return !file_path->empty(); 720 return !file_path->empty();
721 } 721 }
722 722
723 void FileSystemProxy::CallDriveFileSystemMethodOnUIThread( 723 void FileSystemProxy::CallFileSystemMethodOnUIThread(
724 const base::Closure& method_call) { 724 const base::Closure& method_call) {
725 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 725 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
726 BrowserThread::PostTask( 726 BrowserThread::PostTask(
727 BrowserThread::UI, 727 BrowserThread::UI,
728 FROM_HERE, 728 FROM_HERE,
729 base::Bind( 729 base::Bind(
730 &FileSystemProxy::CallDriveFileSystemMethodOnUIThreadInternal, 730 &FileSystemProxy::CallFileSystemMethodOnUIThreadInternal,
731 this, 731 this,
732 method_call)); 732 method_call));
733 } 733 }
734 734
735 void FileSystemProxy::CallDriveFileSystemMethodOnUIThreadInternal( 735 void FileSystemProxy::CallFileSystemMethodOnUIThreadInternal(
736 const base::Closure& method_call) { 736 const base::Closure& method_call) {
737 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 737 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
738 // If |file_system_| is NULL, it means the file system has already shut down. 738 // If |file_system_| is NULL, it means the file system has already shut down.
739 if (file_system_) 739 if (file_system_)
740 method_call.Run(); 740 method_call.Run();
741 } 741 }
742 742
743 void FileSystemProxy::OnStatusCallback( 743 void FileSystemProxy::OnStatusCallback(
744 const fileapi::FileSystemOperation::StatusCallback& callback, 744 const fileapi::FileSystemOperation::StatusCallback& callback,
745 FileError error) { 745 FileError error) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 } 819 }
820 820
821 callback.Run(FileErrorToPlatformError(result), local_path, file_ref); 821 callback.Run(FileErrorToPlatformError(result), local_path, file_ref);
822 } 822 }
823 823
824 void FileSystemProxy::CloseWritableSnapshotFile( 824 void FileSystemProxy::CloseWritableSnapshotFile(
825 const base::FilePath& virtual_path, 825 const base::FilePath& virtual_path,
826 const base::FilePath& local_path) { 826 const base::FilePath& local_path) {
827 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 827 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
828 828
829 CallDriveFileSystemMethodOnUIThread( 829 CallFileSystemMethodOnUIThread(
830 base::Bind(&DriveFileSystemInterface::CloseFile, 830 base::Bind(&DriveFileSystemInterface::CloseFile,
831 base::Unretained(file_system_), 831 base::Unretained(file_system_),
832 virtual_path, 832 virtual_path,
833 google_apis::CreateRelayCallback( 833 google_apis::CreateRelayCallback(
834 base::Bind(&EmitDebugLogForCloseFile, 834 base::Bind(&EmitDebugLogForCloseFile,
835 virtual_path)))); 835 virtual_path))));
836 } 836 }
837 837
838 } // namespace drive 838 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/file_system_proxy.h ('k') | chrome/browser/chromeos/drive/file_system_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698