| OLD | NEW |
| 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 "components/drive/chromeos/file_system.h" | 5 #include "components/drive/chromeos/file_system.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 drive::internal::SearchMetadata( | 817 drive::internal::SearchMetadata( |
| 818 blocking_task_runner_, resource_metadata_, | 818 blocking_task_runner_, resource_metadata_, |
| 819 /* any file name */ "", base::Bind(&CheckHashes, hashes), | 819 /* any file name */ "", base::Bind(&CheckHashes, hashes), |
| 820 std::numeric_limits<size_t>::max(), | 820 std::numeric_limits<size_t>::max(), |
| 821 base::Bind(&RunSearchByHashesCallback, callback)); | 821 base::Bind(&RunSearchByHashesCallback, callback)); |
| 822 } | 822 } |
| 823 | 823 |
| 824 void FileSystem::OnFileChangedByOperation(const FileChange& changed_files) { | 824 void FileSystem::OnFileChangedByOperation(const FileChange& changed_files) { |
| 825 DCHECK(thread_checker_.CalledOnValidThread()); | 825 DCHECK(thread_checker_.CalledOnValidThread()); |
| 826 | 826 |
| 827 FOR_EACH_OBSERVER( | 827 for (auto& observer : observers_) |
| 828 FileSystemObserver, observers_, OnFileChanged(changed_files)); | 828 observer.OnFileChanged(changed_files); |
| 829 } | 829 } |
| 830 | 830 |
| 831 void FileSystem::OnEntryUpdatedByOperation(const ClientContext& context, | 831 void FileSystem::OnEntryUpdatedByOperation(const ClientContext& context, |
| 832 const std::string& local_id) { | 832 const std::string& local_id) { |
| 833 sync_client_->AddUpdateTask(context, local_id); | 833 sync_client_->AddUpdateTask(context, local_id); |
| 834 } | 834 } |
| 835 | 835 |
| 836 void FileSystem::OnDriveSyncError(file_system::DriveSyncErrorType type, | 836 void FileSystem::OnDriveSyncError(file_system::DriveSyncErrorType type, |
| 837 const std::string& local_id) { | 837 const std::string& local_id) { |
| 838 base::FilePath* file_path = new base::FilePath; | 838 base::FilePath* file_path = new base::FilePath; |
| 839 base::PostTaskAndReplyWithResult( | 839 base::PostTaskAndReplyWithResult( |
| 840 blocking_task_runner_.get(), | 840 blocking_task_runner_.get(), |
| 841 FROM_HERE, | 841 FROM_HERE, |
| 842 base::Bind(&internal::ResourceMetadata::GetFilePath, | 842 base::Bind(&internal::ResourceMetadata::GetFilePath, |
| 843 base::Unretained(resource_metadata_), | 843 base::Unretained(resource_metadata_), |
| 844 local_id, | 844 local_id, |
| 845 file_path), | 845 file_path), |
| 846 base::Bind(&FileSystem::OnDriveSyncErrorAfterGetFilePath, | 846 base::Bind(&FileSystem::OnDriveSyncErrorAfterGetFilePath, |
| 847 weak_ptr_factory_.GetWeakPtr(), | 847 weak_ptr_factory_.GetWeakPtr(), |
| 848 type, | 848 type, |
| 849 base::Owned(file_path))); | 849 base::Owned(file_path))); |
| 850 } | 850 } |
| 851 | 851 |
| 852 void FileSystem::OnDriveSyncErrorAfterGetFilePath( | 852 void FileSystem::OnDriveSyncErrorAfterGetFilePath( |
| 853 file_system::DriveSyncErrorType type, | 853 file_system::DriveSyncErrorType type, |
| 854 const base::FilePath* file_path, | 854 const base::FilePath* file_path, |
| 855 FileError error) { | 855 FileError error) { |
| 856 if (error != FILE_ERROR_OK) | 856 if (error != FILE_ERROR_OK) |
| 857 return; | 857 return; |
| 858 FOR_EACH_OBSERVER(FileSystemObserver, | 858 for (auto& observer : observers_) |
| 859 observers_, | 859 observer.OnDriveSyncError(type, *file_path); |
| 860 OnDriveSyncError(type, *file_path)); | |
| 861 } | 860 } |
| 862 | 861 |
| 863 bool FileSystem::WaitForSyncComplete(const std::string& local_id, | 862 bool FileSystem::WaitForSyncComplete(const std::string& local_id, |
| 864 const FileOperationCallback& callback) { | 863 const FileOperationCallback& callback) { |
| 865 return sync_client_->WaitForUpdateTaskToComplete(local_id, callback); | 864 return sync_client_->WaitForUpdateTaskToComplete(local_id, callback); |
| 866 } | 865 } |
| 867 | 866 |
| 868 void FileSystem::OnDirectoryReloaded(const base::FilePath& directory_path) { | 867 void FileSystem::OnDirectoryReloaded(const base::FilePath& directory_path) { |
| 869 DCHECK(thread_checker_.CalledOnValidThread()); | 868 DCHECK(thread_checker_.CalledOnValidThread()); |
| 870 | 869 |
| 871 FOR_EACH_OBSERVER( | 870 for (auto& observer : observers_) |
| 872 FileSystemObserver, observers_, OnDirectoryChanged(directory_path)); | 871 observer.OnDirectoryChanged(directory_path); |
| 873 } | 872 } |
| 874 | 873 |
| 875 void FileSystem::OnFileChanged(const FileChange& changed_files) { | 874 void FileSystem::OnFileChanged(const FileChange& changed_files) { |
| 876 DCHECK(thread_checker_.CalledOnValidThread()); | 875 DCHECK(thread_checker_.CalledOnValidThread()); |
| 877 | 876 |
| 878 FOR_EACH_OBSERVER( | 877 for (auto& observer : observers_) |
| 879 FileSystemObserver, observers_, OnFileChanged(changed_files)); | 878 observer.OnFileChanged(changed_files); |
| 880 } | 879 } |
| 881 | 880 |
| 882 void FileSystem::OnLoadFromServerComplete() { | 881 void FileSystem::OnLoadFromServerComplete() { |
| 883 DCHECK(thread_checker_.CalledOnValidThread()); | 882 DCHECK(thread_checker_.CalledOnValidThread()); |
| 884 | 883 |
| 885 sync_client_->StartCheckingExistingPinnedFiles(); | 884 sync_client_->StartCheckingExistingPinnedFiles(); |
| 886 } | 885 } |
| 887 | 886 |
| 888 void FileSystem::OnInitialLoadComplete() { | 887 void FileSystem::OnInitialLoadComplete() { |
| 889 DCHECK(thread_checker_.CalledOnValidThread()); | 888 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 | 1064 |
| 1066 void FileSystem::CalculateEvictableCacheSize( | 1065 void FileSystem::CalculateEvictableCacheSize( |
| 1067 const CacheSizeCallback& callback) { | 1066 const CacheSizeCallback& callback) { |
| 1068 DCHECK(thread_checker_.CalledOnValidThread()); | 1067 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1069 DCHECK(!callback.is_null()); | 1068 DCHECK(!callback.is_null()); |
| 1070 base::PostTaskAndReplyWithResult( | 1069 base::PostTaskAndReplyWithResult( |
| 1071 blocking_task_runner_.get(), FROM_HERE, | 1070 blocking_task_runner_.get(), FROM_HERE, |
| 1072 base::Bind(&CalculateEvictableCacheSizeOnBlockingPool, cache_), callback); | 1071 base::Bind(&CalculateEvictableCacheSizeOnBlockingPool, cache_), callback); |
| 1073 } | 1072 } |
| 1074 } // namespace drive | 1073 } // namespace drive |
| OLD | NEW |