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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_file_system.cc

Issue 10836154: gdata: Use GDataDirectoryService::GetEntryInfoByPath() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/gdata/gdata_file_system.h" 5 #include "chrome/browser/chromeos/gdata/gdata_file_system.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 GetDownloadDataCallback()); 718 GetDownloadDataCallback());
719 } 719 }
720 720
721 void GDataFileSystem::TransferFileFromLocalToRemote( 721 void GDataFileSystem::TransferFileFromLocalToRemote(
722 const FilePath& local_src_file_path, 722 const FilePath& local_src_file_path,
723 const FilePath& remote_dest_file_path, 723 const FilePath& remote_dest_file_path,
724 const FileOperationCallback& callback) { 724 const FileOperationCallback& callback) {
725 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 725 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
726 726
727 // Make sure the destination directory exists. 727 // Make sure the destination directory exists.
728 GetEntryInfoByPath( 728 directory_service_->GetEntryInfoByPath(
729 remote_dest_file_path.DirName(), 729 remote_dest_file_path.DirName(),
730 base::Bind( 730 base::Bind(
731 &GDataFileSystem::TransferFileFromLocalToRemoteAfterGetEntryInfo, 731 &GDataFileSystem::TransferFileFromLocalToRemoteAfterGetEntryInfo,
732 ui_weak_ptr_, 732 ui_weak_ptr_,
733 local_src_file_path, 733 local_src_file_path,
734 remote_dest_file_path, 734 remote_dest_file_path,
735 callback)); 735 callback));
736 } 736 }
737 737
738 void GDataFileSystem::TransferFileFromLocalToRemoteAfterGetEntryInfo( 738 void GDataFileSystem::TransferFileFromLocalToRemoteAfterGetEntryInfo(
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 DCHECK(content_type); 842 DCHECK(content_type);
843 843
844 if (*error != GDATA_FILE_OK) { 844 if (*error != GDATA_FILE_OK) {
845 if (!params.callback.is_null()) 845 if (!params.callback.is_null())
846 params.callback.Run(*error); 846 params.callback.Run(*error);
847 847
848 return; 848 return;
849 } 849 }
850 850
851 // Make sure the destination directory exists. 851 // Make sure the destination directory exists.
852 GetEntryInfoByPath( 852 directory_service_->GetEntryInfoByPath(
853 params.remote_file_path.DirName(), 853 params.remote_file_path.DirName(),
854 base::Bind( 854 base::Bind(
855 &GDataFileSystem::StartFileUploadOnUIThreadAfterGetEntryInfo, 855 &GDataFileSystem::StartFileUploadOnUIThreadAfterGetEntryInfo,
856 ui_weak_ptr_, 856 ui_weak_ptr_,
857 params, 857 params,
858 *file_size, 858 *file_size,
859 *content_type)); 859 *content_type));
860 } 860 }
861 861
862 void GDataFileSystem::StartFileUploadOnUIThreadAfterGetEntryInfo( 862 void GDataFileSystem::StartFileUploadOnUIThreadAfterGetEntryInfo(
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 // It is a no-op if the file is renamed to the same name. 1073 // It is a no-op if the file is renamed to the same name.
1074 if (file_path.BaseName().value() == new_name) { 1074 if (file_path.BaseName().value() == new_name) {
1075 if (!callback.is_null()) { 1075 if (!callback.is_null()) {
1076 MessageLoop::current()->PostTask( 1076 MessageLoop::current()->PostTask(
1077 FROM_HERE, base::Bind(callback, GDATA_FILE_OK, file_path)); 1077 FROM_HERE, base::Bind(callback, GDATA_FILE_OK, file_path));
1078 } 1078 }
1079 return; 1079 return;
1080 } 1080 }
1081 1081
1082 // Get the edit URL of an entry at |file_path|. 1082 // Get the edit URL of an entry at |file_path|.
1083 GetEntryInfoByPath(file_path, 1083 directory_service_->GetEntryInfoByPath(
1084 base::Bind( 1084 file_path,
1085 &GDataFileSystem::RenameAfterGetEntryInfo, 1085 base::Bind(
1086 ui_weak_ptr_, 1086 &GDataFileSystem::RenameAfterGetEntryInfo,
1087 file_path, 1087 ui_weak_ptr_,
1088 new_name, 1088 file_path,
1089 callback)); 1089 new_name,
1090 callback));
1090 } 1091 }
1091 1092
1092 void GDataFileSystem::RenameAfterGetEntryInfo( 1093 void GDataFileSystem::RenameAfterGetEntryInfo(
1093 const FilePath& file_path, 1094 const FilePath& file_path,
1094 const FilePath::StringType& new_name, 1095 const FilePath::StringType& new_name,
1095 const FilePathUpdateCallback& callback, 1096 const FilePathUpdateCallback& callback,
1096 GDataFileError error, 1097 GDataFileError error,
1097 scoped_ptr<GDataEntryProto> entry_proto) { 1098 scoped_ptr<GDataEntryProto> entry_proto) {
1098 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1099 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1099 1100
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 CreateRelayCallback(callback))); 1291 CreateRelayCallback(callback)));
1291 } 1292 }
1292 1293
1293 void GDataFileSystem::RemoveOnUIThread( 1294 void GDataFileSystem::RemoveOnUIThread(
1294 const FilePath& file_path, 1295 const FilePath& file_path,
1295 bool is_recursive, 1296 bool is_recursive,
1296 const FileOperationCallback& callback) { 1297 const FileOperationCallback& callback) {
1297 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1298 1299
1299 // Get the edit URL of an entry at |file_path|. 1300 // Get the edit URL of an entry at |file_path|.
1300 GetEntryInfoByPath(file_path, 1301 directory_service_->GetEntryInfoByPath(
1301 base::Bind( 1302 file_path,
1302 &GDataFileSystem::RemoveOnUIThreadAfterGetEntryInfo, 1303 base::Bind(
1303 ui_weak_ptr_, 1304 &GDataFileSystem::RemoveOnUIThreadAfterGetEntryInfo,
1304 file_path, 1305 ui_weak_ptr_,
1305 is_recursive, 1306 file_path,
1306 callback)); 1307 is_recursive,
1308 callback));
1307 } 1309 }
1308 1310
1309 void GDataFileSystem::RemoveOnUIThreadAfterGetEntryInfo( 1311 void GDataFileSystem::RemoveOnUIThreadAfterGetEntryInfo(
1310 const FilePath& file_path, 1312 const FilePath& file_path,
1311 bool /* is_recursive */, 1313 bool /* is_recursive */,
1312 const FileOperationCallback& callback, 1314 const FileOperationCallback& callback,
1313 GDataFileError error, 1315 GDataFileError error,
1314 scoped_ptr<GDataEntryProto> entry_proto) { 1316 scoped_ptr<GDataEntryProto> entry_proto) {
1315 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1317 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1316 1318
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 CreateRelayCallback(get_file_callback), 1496 CreateRelayCallback(get_file_callback),
1495 CreateRelayCallback(get_download_data_callback))); 1497 CreateRelayCallback(get_download_data_callback)));
1496 } 1498 }
1497 1499
1498 void GDataFileSystem::GetFileByPathOnUIThread( 1500 void GDataFileSystem::GetFileByPathOnUIThread(
1499 const FilePath& file_path, 1501 const FilePath& file_path,
1500 const GetFileCallback& get_file_callback, 1502 const GetFileCallback& get_file_callback,
1501 const GetDownloadDataCallback& get_download_data_callback) { 1503 const GetDownloadDataCallback& get_download_data_callback) {
1502 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1504 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1503 1505
1504 GetEntryInfoByPath( 1506 directory_service_->GetEntryInfoByPath(
1505 file_path, 1507 file_path,
1506 base::Bind(&GDataFileSystem::OnGetEntryInfoCompleteForGetFileByPath, 1508 base::Bind(&GDataFileSystem::OnGetEntryInfoCompleteForGetFileByPath,
1507 ui_weak_ptr_, 1509 ui_weak_ptr_,
1508 file_path, 1510 file_path,
1509 CreateRelayCallback(get_file_callback), 1511 CreateRelayCallback(get_file_callback),
1510 CreateRelayCallback(get_download_data_callback))); 1512 CreateRelayCallback(get_download_data_callback)));
1511 } 1513 }
1512 1514
1513 void GDataFileSystem::OnGetEntryInfoCompleteForGetFileByPath( 1515 void GDataFileSystem::OnGetEntryInfoCompleteForGetFileByPath(
1514 const FilePath& file_path, 1516 const FilePath& file_path,
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1895 base::Bind(&GDataFileSystem::RequestDirectoryRefreshOnUIThread, 1897 base::Bind(&GDataFileSystem::RequestDirectoryRefreshOnUIThread,
1896 ui_weak_ptr_, 1898 ui_weak_ptr_,
1897 file_path)); 1899 file_path));
1898 } 1900 }
1899 1901
1900 void GDataFileSystem::RequestDirectoryRefreshOnUIThread( 1902 void GDataFileSystem::RequestDirectoryRefreshOnUIThread(
1901 const FilePath& file_path) { 1903 const FilePath& file_path) {
1902 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1904 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1903 1905
1904 // Make sure the destination directory exists. 1906 // Make sure the destination directory exists.
1905 GetEntryInfoByPath( 1907 directory_service_->GetEntryInfoByPath(
1906 file_path, 1908 file_path,
1907 base::Bind( 1909 base::Bind(
1908 &GDataFileSystem::RequestDirectoryRefreshOnUIThreadAfterGetEntryInfo, 1910 &GDataFileSystem::RequestDirectoryRefreshOnUIThreadAfterGetEntryInfo,
1909 ui_weak_ptr_, 1911 ui_weak_ptr_,
1910 file_path)); 1912 file_path));
1911 } 1913 }
1912 1914
1913 void GDataFileSystem::RequestDirectoryRefreshOnUIThreadAfterGetEntryInfo( 1915 void GDataFileSystem::RequestDirectoryRefreshOnUIThreadAfterGetEntryInfo(
1914 const FilePath& file_path, 1916 const FilePath& file_path,
1915 GDataFileError error, 1917 GDataFileError error,
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
3012 // Open->Open->modify->Close->modify->Close; the second modify may not be 3014 // Open->Open->modify->Close->modify->Close; the second modify may not be
3013 // synchronized to the server since it is already Closed on the cache). 3015 // synchronized to the server since it is already Closed on the cache).
3014 if (open_files_.find(file_path) != open_files_.end()) { 3016 if (open_files_.find(file_path) != open_files_.end()) {
3015 MessageLoop::current()->PostTask( 3017 MessageLoop::current()->PostTask(
3016 FROM_HERE, 3018 FROM_HERE,
3017 base::Bind(callback, GDATA_FILE_ERROR_IN_USE, FilePath())); 3019 base::Bind(callback, GDATA_FILE_ERROR_IN_USE, FilePath()));
3018 return; 3020 return;
3019 } 3021 }
3020 open_files_.insert(file_path); 3022 open_files_.insert(file_path);
3021 3023
3022 GetEntryInfoByPath( 3024 directory_service_->GetEntryInfoByPath(
3023 file_path, 3025 file_path,
3024 base::Bind(&GDataFileSystem::OnGetEntryInfoCompleteForOpenFile, 3026 base::Bind(&GDataFileSystem::OnGetEntryInfoCompleteForOpenFile,
3025 ui_weak_ptr_, 3027 ui_weak_ptr_,
3026 file_path, 3028 file_path,
3027 base::Bind(&GDataFileSystem::OnOpenFileFinished, 3029 base::Bind(&GDataFileSystem::OnOpenFileFinished,
3028 ui_weak_ptr_, 3030 ui_weak_ptr_,
3029 file_path, 3031 file_path,
3030 callback))); 3032 callback)));
3031 } 3033 }
3032 3034
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
3411 } 3413 }
3412 3414
3413 PlatformFileInfoProto entry_file_info; 3415 PlatformFileInfoProto entry_file_info;
3414 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); 3416 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info);
3415 *entry_proto->mutable_file_info() = entry_file_info; 3417 *entry_proto->mutable_file_info() = entry_file_info;
3416 if (!callback.is_null()) 3418 if (!callback.is_null())
3417 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); 3419 callback.Run(GDATA_FILE_OK, entry_proto.Pass());
3418 } 3420 }
3419 3421
3420 } // namespace gdata 3422 } // namespace gdata
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698