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

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

Issue 16998003: Update CrOS to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 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 (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_cache.h" 5 #include "chrome/browser/chromeos/drive/file_cache.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 } // namespace 281 } // namespace
282 282
283 FileCache::FileCache(const base::FilePath& cache_root_path, 283 FileCache::FileCache(const base::FilePath& cache_root_path,
284 base::SequencedTaskRunner* blocking_task_runner, 284 base::SequencedTaskRunner* blocking_task_runner,
285 FreeDiskSpaceGetterInterface* free_disk_space_getter) 285 FreeDiskSpaceGetterInterface* free_disk_space_getter)
286 : cache_root_path_(cache_root_path), 286 : cache_root_path_(cache_root_path),
287 cache_paths_(GetCachePaths(cache_root_path_)), 287 cache_paths_(GetCachePaths(cache_root_path_)),
288 blocking_task_runner_(blocking_task_runner), 288 blocking_task_runner_(blocking_task_runner),
289 free_disk_space_getter_(free_disk_space_getter), 289 free_disk_space_getter_(free_disk_space_getter),
290 weak_ptr_factory_(this) { 290 weak_ptr_factory_(this) {
291 DCHECK(blocking_task_runner_); 291 DCHECK(blocking_task_runner_.get());
292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
293 } 293 }
294 294
295 FileCache::~FileCache() { 295 FileCache::~FileCache() {
296 // Must be on the sequenced worker pool, as |metadata_| must be deleted on 296 // Must be on the sequenced worker pool, as |metadata_| must be deleted on
297 // the sequenced worker pool. 297 // the sequenced worker pool.
298 AssertOnSequencedWorkerPool(); 298 AssertOnSequencedWorkerPool();
299 } 299 }
300 300
301 base::FilePath FileCache::GetCacheDirectoryPath( 301 base::FilePath FileCache::GetCacheDirectoryPath(
(...skipping 27 matching lines...) Expand all
329 if (file_origin == CACHED_FILE_MOUNTED) { 329 if (file_origin == CACHED_FILE_MOUNTED) {
330 DCHECK(sub_dir_type == CACHE_TYPE_PERSISTENT); 330 DCHECK(sub_dir_type == CACHE_TYPE_PERSISTENT);
331 base_name += base::FilePath::kExtensionSeparator; 331 base_name += base::FilePath::kExtensionSeparator;
332 base_name += util::kMountedArchiveFileExtension; 332 base_name += util::kMountedArchiveFileExtension;
333 } 333 }
334 return GetCacheDirectoryPath(sub_dir_type).Append( 334 return GetCacheDirectoryPath(sub_dir_type).Append(
335 base::FilePath::FromUTF8Unsafe(base_name)); 335 base::FilePath::FromUTF8Unsafe(base_name));
336 } 336 }
337 337
338 void FileCache::AssertOnSequencedWorkerPool() { 338 void FileCache::AssertOnSequencedWorkerPool() {
339 DCHECK(!blocking_task_runner_ || 339 DCHECK(!blocking_task_runner_.get() ||
340 blocking_task_runner_->RunsTasksOnCurrentThread()); 340 blocking_task_runner_->RunsTasksOnCurrentThread());
341 } 341 }
342 342
343 bool FileCache::IsUnderFileCacheDirectory(const base::FilePath& path) const { 343 bool FileCache::IsUnderFileCacheDirectory(const base::FilePath& path) const {
344 return cache_root_path_ == path || cache_root_path_.IsParent(path); 344 return cache_root_path_ == path || cache_root_path_.IsParent(path);
345 } 345 }
346 346
347 void FileCache::GetCacheEntryOnUIThread(const std::string& resource_id, 347 void FileCache::GetCacheEntryOnUIThread(const std::string& resource_id,
348 const std::string& md5, 348 const std::string& md5,
349 const GetCacheEntryCallback& callback) { 349 const GetCacheEntryCallback& callback) {
350 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 350 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
351 DCHECK(!callback.is_null()); 351 DCHECK(!callback.is_null());
352 352
353 FileCacheEntry* cache_entry = new FileCacheEntry; 353 FileCacheEntry* cache_entry = new FileCacheEntry;
354 base::PostTaskAndReplyWithResult( 354 base::PostTaskAndReplyWithResult(
355 blocking_task_runner_, 355 blocking_task_runner_.get(),
356 FROM_HERE, 356 FROM_HERE,
357 base::Bind(&FileCache::GetCacheEntry, 357 base::Bind(&FileCache::GetCacheEntry,
358 base::Unretained(this), resource_id, md5, cache_entry), 358 base::Unretained(this),
359 base::Bind(&RunGetCacheEntryCallback, 359 resource_id,
360 callback, base::Owned(cache_entry))); 360 md5,
361 cache_entry),
362 base::Bind(
363 &RunGetCacheEntryCallback, callback, base::Owned(cache_entry)));
361 } 364 }
362 365
363 bool FileCache::GetCacheEntry(const std::string& resource_id, 366 bool FileCache::GetCacheEntry(const std::string& resource_id,
364 const std::string& md5, 367 const std::string& md5,
365 FileCacheEntry* entry) { 368 FileCacheEntry* entry) {
366 DCHECK(entry); 369 DCHECK(entry);
367 AssertOnSequencedWorkerPool(); 370 AssertOnSequencedWorkerPool();
368 return metadata_->GetCacheEntry(resource_id, entry) && 371 return metadata_->GetCacheEntry(resource_id, entry) &&
369 CheckIfMd5Matches(md5, *entry); 372 CheckIfMd5Matches(md5, *entry);
370 } 373 }
(...skipping 23 matching lines...) Expand all
394 DCHECK(!it->HasError()); 397 DCHECK(!it->HasError());
395 } 398 }
396 399
397 void FileCache::FreeDiskSpaceIfNeededForOnUIThread( 400 void FileCache::FreeDiskSpaceIfNeededForOnUIThread(
398 int64 num_bytes, 401 int64 num_bytes,
399 const InitializeCacheCallback& callback) { 402 const InitializeCacheCallback& callback) {
400 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 403 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
401 DCHECK(!callback.is_null()); 404 DCHECK(!callback.is_null());
402 405
403 base::PostTaskAndReplyWithResult( 406 base::PostTaskAndReplyWithResult(
404 blocking_task_runner_, 407 blocking_task_runner_.get(),
405 FROM_HERE, 408 FROM_HERE,
406 base::Bind(&FileCache::FreeDiskSpaceIfNeededFor, 409 base::Bind(&FileCache::FreeDiskSpaceIfNeededFor,
407 base::Unretained(this), 410 base::Unretained(this),
408 num_bytes), 411 num_bytes),
409 callback); 412 callback);
410 } 413 }
411 414
412 bool FileCache::FreeDiskSpaceIfNeededFor(int64 num_bytes) { 415 bool FileCache::FreeDiskSpaceIfNeededFor(int64 num_bytes) {
413 AssertOnSequencedWorkerPool(); 416 AssertOnSequencedWorkerPool();
414 417
(...skipping 19 matching lines...) Expand all
434 return HasEnoughSpaceFor(num_bytes, cache_root_path_); 437 return HasEnoughSpaceFor(num_bytes, cache_root_path_);
435 } 438 }
436 439
437 void FileCache::GetFileOnUIThread(const std::string& resource_id, 440 void FileCache::GetFileOnUIThread(const std::string& resource_id,
438 const std::string& md5, 441 const std::string& md5,
439 const GetFileFromCacheCallback& callback) { 442 const GetFileFromCacheCallback& callback) {
440 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 443 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
441 DCHECK(!callback.is_null()); 444 DCHECK(!callback.is_null());
442 445
443 base::FilePath* cache_file_path = new base::FilePath; 446 base::FilePath* cache_file_path = new base::FilePath;
444 base::PostTaskAndReplyWithResult( 447 base::PostTaskAndReplyWithResult(blocking_task_runner_.get(),
445 blocking_task_runner_, 448 FROM_HERE,
446 FROM_HERE, 449 base::Bind(&FileCache::GetFile,
447 base::Bind(&FileCache::GetFile, 450 base::Unretained(this),
448 base::Unretained(this), resource_id, md5, cache_file_path), 451 resource_id,
449 base::Bind(&RunGetFileFromCacheCallback, 452 md5,
450 callback, base::Owned(cache_file_path))); 453 cache_file_path),
454 base::Bind(&RunGetFileFromCacheCallback,
455 callback,
456 base::Owned(cache_file_path)));
451 } 457 }
452 458
453 FileError FileCache::GetFile(const std::string& resource_id, 459 FileError FileCache::GetFile(const std::string& resource_id,
454 const std::string& md5, 460 const std::string& md5,
455 base::FilePath* cache_file_path) { 461 base::FilePath* cache_file_path) {
456 AssertOnSequencedWorkerPool(); 462 AssertOnSequencedWorkerPool();
457 DCHECK(cache_file_path); 463 DCHECK(cache_file_path);
458 464
459 FileCacheEntry cache_entry; 465 FileCacheEntry cache_entry;
460 if (!GetCacheEntry(resource_id, md5, &cache_entry) || 466 if (!GetCacheEntry(resource_id, md5, &cache_entry) ||
(...skipping 17 matching lines...) Expand all
478 } 484 }
479 485
480 void FileCache::StoreOnUIThread(const std::string& resource_id, 486 void FileCache::StoreOnUIThread(const std::string& resource_id,
481 const std::string& md5, 487 const std::string& md5,
482 const base::FilePath& source_path, 488 const base::FilePath& source_path,
483 FileOperationType file_operation_type, 489 FileOperationType file_operation_type,
484 const FileOperationCallback& callback) { 490 const FileOperationCallback& callback) {
485 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 491 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
486 DCHECK(!callback.is_null()); 492 DCHECK(!callback.is_null());
487 493
488 base::PostTaskAndReplyWithResult( 494 base::PostTaskAndReplyWithResult(blocking_task_runner_.get(),
489 blocking_task_runner_, 495 FROM_HERE,
490 FROM_HERE, 496 base::Bind(&FileCache::Store,
491 base::Bind(&FileCache::Store, 497 base::Unretained(this),
492 base::Unretained(this), 498 resource_id,
493 resource_id, md5, source_path, file_operation_type), 499 md5,
494 callback); 500 source_path,
501 file_operation_type),
502 callback);
495 } 503 }
496 504
497 FileError FileCache::Store(const std::string& resource_id, 505 FileError FileCache::Store(const std::string& resource_id,
498 const std::string& md5, 506 const std::string& md5,
499 const base::FilePath& source_path, 507 const base::FilePath& source_path,
500 FileOperationType file_operation_type) { 508 FileOperationType file_operation_type) {
501 AssertOnSequencedWorkerPool(); 509 AssertOnSequencedWorkerPool();
502 return StoreInternal(resource_id, md5, source_path, file_operation_type); 510 return StoreInternal(resource_id, md5, source_path, file_operation_type);
503 } 511 }
504 512
505 void FileCache::PinOnUIThread(const std::string& resource_id, 513 void FileCache::PinOnUIThread(const std::string& resource_id,
506 const std::string& md5, 514 const std::string& md5,
507 const FileOperationCallback& callback) { 515 const FileOperationCallback& callback) {
508 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 516 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
509 DCHECK(!callback.is_null()); 517 DCHECK(!callback.is_null());
510 518
511 base::PostTaskAndReplyWithResult( 519 base::PostTaskAndReplyWithResult(
512 blocking_task_runner_, 520 blocking_task_runner_.get(),
513 FROM_HERE, 521 FROM_HERE,
514 base::Bind(&FileCache::Pin, base::Unretained(this), resource_id, md5), 522 base::Bind(&FileCache::Pin, base::Unretained(this), resource_id, md5),
515 callback); 523 callback);
516 } 524 }
517 525
518 FileError FileCache::Pin(const std::string& resource_id, 526 FileError FileCache::Pin(const std::string& resource_id,
519 const std::string& md5) { 527 const std::string& md5) {
520 AssertOnSequencedWorkerPool(); 528 AssertOnSequencedWorkerPool();
521 529
522 bool is_persistent = true; 530 bool is_persistent = true;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 return FILE_ERROR_OK; 567 return FILE_ERROR_OK;
560 } 568 }
561 569
562 void FileCache::UnpinOnUIThread(const std::string& resource_id, 570 void FileCache::UnpinOnUIThread(const std::string& resource_id,
563 const std::string& md5, 571 const std::string& md5,
564 const FileOperationCallback& callback) { 572 const FileOperationCallback& callback) {
565 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 573 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
566 DCHECK(!callback.is_null()); 574 DCHECK(!callback.is_null());
567 575
568 base::PostTaskAndReplyWithResult( 576 base::PostTaskAndReplyWithResult(
569 blocking_task_runner_, 577 blocking_task_runner_.get(),
570 FROM_HERE, 578 FROM_HERE,
571 base::Bind(&FileCache::Unpin, base::Unretained(this), resource_id, md5), 579 base::Bind(&FileCache::Unpin, base::Unretained(this), resource_id, md5),
572 callback); 580 callback);
573 } 581 }
574 582
575 FileError FileCache::Unpin(const std::string& resource_id, 583 FileError FileCache::Unpin(const std::string& resource_id,
576 const std::string& md5) { 584 const std::string& md5) {
577 AssertOnSequencedWorkerPool(); 585 AssertOnSequencedWorkerPool();
578 586
579 // Unpinning a file means its entry must exist in cache. 587 // Unpinning a file means its entry must exist in cache.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 } 639 }
632 640
633 void FileCache::MarkAsMountedOnUIThread( 641 void FileCache::MarkAsMountedOnUIThread(
634 const std::string& resource_id, 642 const std::string& resource_id,
635 const GetFileFromCacheCallback& callback) { 643 const GetFileFromCacheCallback& callback) {
636 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 644 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
637 DCHECK(!callback.is_null()); 645 DCHECK(!callback.is_null());
638 646
639 base::FilePath* cache_file_path = new base::FilePath; 647 base::FilePath* cache_file_path = new base::FilePath;
640 base::PostTaskAndReplyWithResult( 648 base::PostTaskAndReplyWithResult(
641 blocking_task_runner_, 649 blocking_task_runner_.get(),
642 FROM_HERE, 650 FROM_HERE,
643 base::Bind(&FileCache::MarkAsMounted, 651 base::Bind(&FileCache::MarkAsMounted,
644 base::Unretained(this), resource_id, cache_file_path), 652 base::Unretained(this),
645 base::Bind(RunGetFileFromCacheCallback, 653 resource_id,
646 callback, base::Owned(cache_file_path))); 654 cache_file_path),
655 base::Bind(
656 RunGetFileFromCacheCallback, callback, base::Owned(cache_file_path)));
647 } 657 }
648 658
649 void FileCache::MarkAsUnmountedOnUIThread( 659 void FileCache::MarkAsUnmountedOnUIThread(
650 const base::FilePath& file_path, 660 const base::FilePath& file_path,
651 const FileOperationCallback& callback) { 661 const FileOperationCallback& callback) {
652 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 662 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
653 DCHECK(!callback.is_null()); 663 DCHECK(!callback.is_null());
654 664
655 base::PostTaskAndReplyWithResult( 665 base::PostTaskAndReplyWithResult(
656 blocking_task_runner_, 666 blocking_task_runner_.get(),
657 FROM_HERE, 667 FROM_HERE,
658 base::Bind(&FileCache::MarkAsUnmounted, 668 base::Bind(
659 base::Unretained(this), file_path), 669 &FileCache::MarkAsUnmounted, base::Unretained(this), file_path),
660 callback); 670 callback);
661 } 671 }
662 672
663 void FileCache::MarkDirtyOnUIThread(const std::string& resource_id, 673 void FileCache::MarkDirtyOnUIThread(const std::string& resource_id,
664 const std::string& md5, 674 const std::string& md5,
665 const FileOperationCallback& callback) { 675 const FileOperationCallback& callback) {
666 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 676 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
667 DCHECK(!callback.is_null()); 677 DCHECK(!callback.is_null());
668 678
669 base::PostTaskAndReplyWithResult( 679 base::PostTaskAndReplyWithResult(
670 blocking_task_runner_, 680 blocking_task_runner_.get(),
671 FROM_HERE, 681 FROM_HERE,
672 base::Bind(&FileCache::MarkDirty, 682 base::Bind(
673 base::Unretained(this), resource_id, md5), 683 &FileCache::MarkDirty, base::Unretained(this), resource_id, md5),
674 callback); 684 callback);
675 } 685 }
676 686
677 FileError FileCache::MarkDirty(const std::string& resource_id, 687 FileError FileCache::MarkDirty(const std::string& resource_id,
678 const std::string& md5) { 688 const std::string& md5) {
679 AssertOnSequencedWorkerPool(); 689 AssertOnSequencedWorkerPool();
680 690
681 // If file has already been marked dirty in previous instance of chrome, we 691 // If file has already been marked dirty in previous instance of chrome, we
682 // would have lost the md5 info during cache initialization, because the file 692 // would have lost the md5 info during cache initialization, because the file
683 // would have been renamed to .local extension. 693 // would have been renamed to .local extension.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 metadata_->AddOrUpdateCacheEntry(resource_id, cache_entry); 794 metadata_->AddOrUpdateCacheEntry(resource_id, cache_entry);
785 return FILE_ERROR_OK; 795 return FILE_ERROR_OK;
786 } 796 }
787 797
788 void FileCache::RemoveOnUIThread(const std::string& resource_id, 798 void FileCache::RemoveOnUIThread(const std::string& resource_id,
789 const FileOperationCallback& callback) { 799 const FileOperationCallback& callback) {
790 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 800 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
791 DCHECK(!callback.is_null()); 801 DCHECK(!callback.is_null());
792 802
793 base::PostTaskAndReplyWithResult( 803 base::PostTaskAndReplyWithResult(
794 blocking_task_runner_, 804 blocking_task_runner_.get(),
795 FROM_HERE, 805 FROM_HERE,
796 base::Bind(&FileCache::Remove, 806 base::Bind(&FileCache::Remove, base::Unretained(this), resource_id),
797 base::Unretained(this), resource_id),
798 callback); 807 callback);
799 } 808 }
800 809
801 FileError FileCache::Remove(const std::string& resource_id) { 810 FileError FileCache::Remove(const std::string& resource_id) {
802 AssertOnSequencedWorkerPool(); 811 AssertOnSequencedWorkerPool();
803 812
804 // MD5 is not passed into RemoveCacheEntry because we would delete all 813 // MD5 is not passed into RemoveCacheEntry because we would delete all
805 // cache files corresponding to <resource_id> regardless of the md5. 814 // cache files corresponding to <resource_id> regardless of the md5.
806 // So, search for entry in cache without taking md5 into account. 815 // So, search for entry in cache without taking md5 into account.
807 FileCacheEntry cache_entry; 816 FileCacheEntry cache_entry;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 metadata_->RemoveCacheEntry(resource_id); 855 metadata_->RemoveCacheEntry(resource_id);
847 856
848 return FILE_ERROR_OK; 857 return FILE_ERROR_OK;
849 } 858 }
850 859
851 void FileCache::ClearAllOnUIThread(const InitializeCacheCallback& callback) { 860 void FileCache::ClearAllOnUIThread(const InitializeCacheCallback& callback) {
852 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 861 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
853 DCHECK(!callback.is_null()); 862 DCHECK(!callback.is_null());
854 863
855 base::PostTaskAndReplyWithResult( 864 base::PostTaskAndReplyWithResult(
856 blocking_task_runner_, 865 blocking_task_runner_.get(),
857 FROM_HERE, 866 FROM_HERE,
858 base::Bind(&FileCache::ClearAll, base::Unretained(this)), 867 base::Bind(&FileCache::ClearAll, base::Unretained(this)),
859 callback); 868 callback);
860 } 869 }
861 870
862 void FileCache::RequestInitialize(const InitializeCacheCallback& callback) { 871 void FileCache::RequestInitialize(const InitializeCacheCallback& callback) {
863 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 872 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
864 DCHECK(!callback.is_null()); 873 DCHECK(!callback.is_null());
865 874
866 base::PostTaskAndReplyWithResult( 875 base::PostTaskAndReplyWithResult(
867 blocking_task_runner_, 876 blocking_task_runner_.get(),
868 FROM_HERE, 877 FROM_HERE,
869 base::Bind(&FileCache::InitializeOnBlockingPool, base::Unretained(this)), 878 base::Bind(&FileCache::InitializeOnBlockingPool, base::Unretained(this)),
870 callback); 879 callback);
871 } 880 }
872 881
873 void FileCache::Destroy() { 882 void FileCache::Destroy() {
874 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 883 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
875 884
876 // Invalidate the weak pointer. 885 // Invalidate the weak pointer.
877 weak_ptr_factory_.InvalidateWeakPtrs(); 886 weak_ptr_factory_.InvalidateWeakPtrs();
878 887
879 // Destroy myself on the blocking pool. 888 // Destroy myself on the blocking pool.
880 // Note that base::DeletePointer<> cannot be used as the destructor of this 889 // Note that base::DeletePointer<> cannot be used as the destructor of this
881 // class is private. 890 // class is private.
882 blocking_task_runner_->PostTask( 891 blocking_task_runner_->PostTask(
883 FROM_HERE, 892 FROM_HERE,
884 base::Bind(&FileCache::DestroyOnBlockingPool, base::Unretained(this))); 893 base::Bind(&FileCache::DestroyOnBlockingPool, base::Unretained(this)));
885 } 894 }
886 895
887 bool FileCache::InitializeOnBlockingPool() { 896 bool FileCache::InitializeOnBlockingPool() {
888 AssertOnSequencedWorkerPool(); 897 AssertOnSequencedWorkerPool();
889 898
890 if (!InitCachePaths(cache_paths_)) 899 if (!InitCachePaths(cache_paths_))
891 return false; 900 return false;
892 901
893 metadata_.reset(new FileCacheMetadata(blocking_task_runner_)); 902 metadata_.reset(new FileCacheMetadata(blocking_task_runner_.get()));
894 903
895 switch (metadata_->Initialize(cache_paths_[CACHE_TYPE_META])) { 904 switch (metadata_->Initialize(cache_paths_[CACHE_TYPE_META])) {
896 case FileCacheMetadata::INITIALIZE_FAILED: 905 case FileCacheMetadata::INITIALIZE_FAILED:
897 return false; 906 return false;
898 907
899 case FileCacheMetadata::INITIALIZE_OPENED: // Do nothing. 908 case FileCacheMetadata::INITIALIZE_OPENED: // Do nothing.
900 break; 909 break;
901 910
902 case FileCacheMetadata::INITIALIZE_CREATED: { 911 case FileCacheMetadata::INITIALIZE_CREATED: {
903 CacheMap cache_map; 912 CacheMap cache_map;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 } 1158 }
1150 1159
1151 // static 1160 // static
1152 FileCache::CacheSubDirectoryType FileCache::GetSubDirectoryType( 1161 FileCache::CacheSubDirectoryType FileCache::GetSubDirectoryType(
1153 const FileCacheEntry& cache_entry) { 1162 const FileCacheEntry& cache_entry) {
1154 return cache_entry.is_persistent() ? CACHE_TYPE_PERSISTENT : CACHE_TYPE_TMP; 1163 return cache_entry.is_persistent() ? CACHE_TYPE_PERSISTENT : CACHE_TYPE_TMP;
1155 } 1164 }
1156 1165
1157 } // namespace internal 1166 } // namespace internal
1158 } // namespace drive 1167 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_url_request_job.cc ('k') | chrome/browser/chromeos/drive/file_cache_metadata.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698