| 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 "chrome/browser/chromeos/drive/file_system.h" | 5 #include "chrome/browser/chromeos/drive/file_system.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/chromeos/drive/change_list_loader.h" | 10 #include "chrome/browser/chromeos/drive/change_list_loader.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/browser/chromeos/drive/file_system/touch_operation.h" | 25 #include "chrome/browser/chromeos/drive/file_system/touch_operation.h" |
| 26 #include "chrome/browser/chromeos/drive/file_system/truncate_operation.h" | 26 #include "chrome/browser/chromeos/drive/file_system/truncate_operation.h" |
| 27 #include "chrome/browser/chromeos/drive/file_system_observer.h" | 27 #include "chrome/browser/chromeos/drive/file_system_observer.h" |
| 28 #include "chrome/browser/chromeos/drive/file_system_util.h" | 28 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 29 #include "chrome/browser/chromeos/drive/job_scheduler.h" | 29 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
| 30 #include "chrome/browser/chromeos/drive/remove_stale_cache_files.h" | 30 #include "chrome/browser/chromeos/drive/remove_stale_cache_files.h" |
| 31 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" | 31 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" |
| 32 #include "chrome/browser/chromeos/drive/search_metadata.h" | 32 #include "chrome/browser/chromeos/drive/search_metadata.h" |
| 33 #include "chrome/browser/chromeos/drive/sync_client.h" | 33 #include "chrome/browser/chromeos/drive/sync_client.h" |
| 34 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
| 35 #include "components/user_manager/user_id.h" |
| 35 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
| 36 #include "google_apis/drive/drive_api_parser.h" | 37 #include "google_apis/drive/drive_api_parser.h" |
| 37 | 38 |
| 38 using content::BrowserThread; | 39 using content::BrowserThread; |
| 39 | 40 |
| 40 namespace drive { | 41 namespace drive { |
| 41 namespace { | 42 namespace { |
| 42 | 43 |
| 43 // Gets a ResourceEntry from the metadata, and overwrites its file info when the | 44 // Gets a ResourceEntry from the metadata, and overwrites its file info when the |
| 44 // cached file is dirty. | 45 // cached file is dirty. |
| (...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 base::PostTaskAndReplyWithResult( | 955 base::PostTaskAndReplyWithResult( |
| 955 blocking_task_runner_.get(), | 956 blocking_task_runner_.get(), |
| 956 FROM_HERE, | 957 FROM_HERE, |
| 957 base::Bind(&internal::FileCache::MarkAsUnmounted, | 958 base::Bind(&internal::FileCache::MarkAsUnmounted, |
| 958 base::Unretained(cache_), | 959 base::Unretained(cache_), |
| 959 cache_file_path), | 960 cache_file_path), |
| 960 callback); | 961 callback); |
| 961 } | 962 } |
| 962 | 963 |
| 963 void FileSystem::AddPermission(const base::FilePath& drive_file_path, | 964 void FileSystem::AddPermission(const base::FilePath& drive_file_path, |
| 964 const std::string& email, | 965 const user_manager::UserID& user_id, |
| 965 google_apis::drive::PermissionRole role, | 966 google_apis::drive::PermissionRole role, |
| 966 const FileOperationCallback& callback) { | 967 const FileOperationCallback& callback) { |
| 967 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 968 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 968 DCHECK(!callback.is_null()); | 969 DCHECK(!callback.is_null()); |
| 969 | 970 |
| 970 // Resolve the resource id. | 971 // Resolve the resource id. |
| 971 ResourceEntry* const entry = new ResourceEntry; | 972 ResourceEntry* const entry = new ResourceEntry; |
| 972 base::PostTaskAndReplyWithResult( | 973 base::PostTaskAndReplyWithResult( |
| 973 blocking_task_runner_.get(), | 974 blocking_task_runner_.get(), |
| 974 FROM_HERE, | 975 FROM_HERE, |
| 975 base::Bind(&internal::ResourceMetadata::GetResourceEntryByPath, | 976 base::Bind(&internal::ResourceMetadata::GetResourceEntryByPath, |
| 976 base::Unretained(resource_metadata_), | 977 base::Unretained(resource_metadata_), |
| 977 drive_file_path, | 978 drive_file_path, |
| 978 entry), | 979 entry), |
| 979 base::Bind(&FileSystem::AddPermissionAfterGetResourceEntry, | 980 base::Bind(&FileSystem::AddPermissionAfterGetResourceEntry, |
| 980 weak_ptr_factory_.GetWeakPtr(), | 981 weak_ptr_factory_.GetWeakPtr(), |
| 981 email, | 982 user_id, |
| 982 role, | 983 role, |
| 983 callback, | 984 callback, |
| 984 base::Owned(entry))); | 985 base::Owned(entry))); |
| 985 } | 986 } |
| 986 | 987 |
| 987 void FileSystem::AddPermissionAfterGetResourceEntry( | 988 void FileSystem::AddPermissionAfterGetResourceEntry( |
| 988 const std::string& email, | 989 const user_manager::UserID& user_id, |
| 989 google_apis::drive::PermissionRole role, | 990 google_apis::drive::PermissionRole role, |
| 990 const FileOperationCallback& callback, | 991 const FileOperationCallback& callback, |
| 991 ResourceEntry* entry, | 992 ResourceEntry* entry, |
| 992 FileError error) { | 993 FileError error) { |
| 993 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 994 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 994 | 995 |
| 995 if (error != FILE_ERROR_OK) { | 996 if (error != FILE_ERROR_OK) { |
| 996 callback.Run(error); | 997 callback.Run(error); |
| 997 return; | 998 return; |
| 998 } | 999 } |
| 999 | 1000 |
| 1000 scheduler_->AddPermission( | 1001 scheduler_->AddPermission( |
| 1001 entry->resource_id(), | 1002 entry->resource_id(), |
| 1002 email, | 1003 user_id, |
| 1003 role, | 1004 role, |
| 1004 base::Bind(&RunFileOperationCallbackAsEntryActionCallback, callback)); | 1005 base::Bind(&RunFileOperationCallbackAsEntryActionCallback, callback)); |
| 1005 } | 1006 } |
| 1006 | 1007 |
| 1007 void FileSystem::SetProperty( | 1008 void FileSystem::SetProperty( |
| 1008 const base::FilePath& drive_file_path, | 1009 const base::FilePath& drive_file_path, |
| 1009 google_apis::drive::Property::Visibility visibility, | 1010 google_apis::drive::Property::Visibility visibility, |
| 1010 const std::string& key, | 1011 const std::string& key, |
| 1011 const std::string& value, | 1012 const std::string& value, |
| 1012 const FileOperationCallback& callback) { | 1013 const FileOperationCallback& callback) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 int64 num_bytes, | 1050 int64 num_bytes, |
| 1050 const FreeDiskSpaceCallback& callback) { | 1051 const FreeDiskSpaceCallback& callback) { |
| 1051 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1052 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1052 DCHECK(!callback.is_null()); | 1053 DCHECK(!callback.is_null()); |
| 1053 base::PostTaskAndReplyWithResult( | 1054 base::PostTaskAndReplyWithResult( |
| 1054 blocking_task_runner_.get(), FROM_HERE, | 1055 blocking_task_runner_.get(), FROM_HERE, |
| 1055 base::Bind(&FreeDiskSpaceIfNeededForOnBlockingPool, cache_, num_bytes), | 1056 base::Bind(&FreeDiskSpaceIfNeededForOnBlockingPool, cache_, num_bytes), |
| 1056 callback); | 1057 callback); |
| 1057 } | 1058 } |
| 1058 } // namespace drive | 1059 } // namespace drive |
| OLD | NEW |