| 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/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" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/json/json_file_value_serializer.h" | 12 #include "base/json/json_file_value_serializer.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/message_loop_proxy.h" | 14 #include "base/message_loop_proxy.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/platform_file.h" | 16 #include "base/platform_file.h" |
| 17 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/threading/sequenced_worker_pool.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "chrome/browser/chromeos/gdata/drive.pb.h" |
| 19 #include "chrome/browser/chromeos/gdata/drive_api_parser.h" | 20 #include "chrome/browser/chromeos/gdata/drive_api_parser.h" |
| 20 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" | 21 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" |
| 21 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" | 22 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" |
| 22 #include "chrome/browser/chromeos/gdata/gdata.pb.h" | |
| 23 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" | 23 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" |
| 24 #include "chrome/browser/chromeos/gdata/gdata_files.h" | 24 #include "chrome/browser/chromeos/gdata/gdata_files.h" |
| 25 #include "chrome/browser/chromeos/gdata/gdata_protocol_handler.h" | 25 #include "chrome/browser/chromeos/gdata/gdata_protocol_handler.h" |
| 26 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | 26 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
| 27 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" | 27 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" |
| 28 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 28 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
| 29 #include "chrome/browser/chromeos/gdata/task_util.h" | 29 #include "chrome/browser/chromeos/gdata/task_util.h" |
| 30 #include "chrome/browser/prefs/pref_service.h" | 30 #include "chrome/browser/prefs/pref_service.h" |
| 31 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
| 32 #include "chrome/common/chrome_notification_types.h" | 32 #include "chrome/common/chrome_notification_types.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 callback.Run(error, next_feed, result_vec.Pass()); | 258 callback.Run(error, next_feed, result_vec.Pass()); |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 | 261 |
| 262 // Helper function for binding |path| to GetEntryInfoWithFilePathCallback and | 262 // Helper function for binding |path| to GetEntryInfoWithFilePathCallback and |
| 263 // create GetEntryInfoCallback. | 263 // create GetEntryInfoCallback. |
| 264 void RunGetEntryInfoWithFilePathCallback( | 264 void RunGetEntryInfoWithFilePathCallback( |
| 265 const GetEntryInfoWithFilePathCallback& callback, | 265 const GetEntryInfoWithFilePathCallback& callback, |
| 266 const FilePath& path, | 266 const FilePath& path, |
| 267 GDataFileError error, | 267 GDataFileError error, |
| 268 scoped_ptr<GDataEntryProto> entry_proto) { | 268 scoped_ptr<DriveEntryProto> entry_proto) { |
| 269 if (!callback.is_null()) | 269 if (!callback.is_null()) |
| 270 callback.Run(error, path, entry_proto.Pass()); | 270 callback.Run(error, path, entry_proto.Pass()); |
| 271 } | 271 } |
| 272 | 272 |
| 273 } // namespace | 273 } // namespace |
| 274 | 274 |
| 275 // GDataFileSystem::CreateDirectoryParams struct implementation. | 275 // GDataFileSystem::CreateDirectoryParams struct implementation. |
| 276 struct GDataFileSystem::CreateDirectoryParams { | 276 struct GDataFileSystem::CreateDirectoryParams { |
| 277 CreateDirectoryParams(const FilePath& created_directory_path, | 277 CreateDirectoryParams(const FilePath& created_directory_path, |
| 278 const FilePath& target_directory_path, | 278 const FilePath& target_directory_path, |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 callback)); | 546 callback)); |
| 547 } | 547 } |
| 548 | 548 |
| 549 void GDataFileSystem::GetEntryInfoByEntryOnUIThread( | 549 void GDataFileSystem::GetEntryInfoByEntryOnUIThread( |
| 550 const GetEntryInfoWithFilePathCallback& callback, | 550 const GetEntryInfoWithFilePathCallback& callback, |
| 551 GDataEntry* entry) { | 551 GDataEntry* entry) { |
| 552 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 552 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 553 DCHECK(!callback.is_null()); | 553 DCHECK(!callback.is_null()); |
| 554 | 554 |
| 555 if (entry) { | 555 if (entry) { |
| 556 scoped_ptr<GDataEntryProto> entry_proto(new GDataEntryProto); | 556 scoped_ptr<DriveEntryProto> entry_proto(new DriveEntryProto); |
| 557 entry->ToProtoFull(entry_proto.get()); | 557 entry->ToProtoFull(entry_proto.get()); |
| 558 CheckLocalModificationAndRun( | 558 CheckLocalModificationAndRun( |
| 559 entry_proto.Pass(), | 559 entry_proto.Pass(), |
| 560 base::Bind(&RunGetEntryInfoWithFilePathCallback, | 560 base::Bind(&RunGetEntryInfoWithFilePathCallback, |
| 561 callback, entry->GetFilePath())); | 561 callback, entry->GetFilePath())); |
| 562 } else { | 562 } else { |
| 563 callback.Run(GDATA_FILE_ERROR_NOT_FOUND, | 563 callback.Run(GDATA_FILE_ERROR_NOT_FOUND, |
| 564 FilePath(), | 564 FilePath(), |
| 565 scoped_ptr<GDataEntryProto>()); | 565 scoped_ptr<DriveEntryProto>()); |
| 566 } | 566 } |
| 567 } | 567 } |
| 568 | 568 |
| 569 void GDataFileSystem::LoadFeedIfNeeded(const FileOperationCallback& callback) { | 569 void GDataFileSystem::LoadFeedIfNeeded(const FileOperationCallback& callback) { |
| 570 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 570 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 571 DCHECK(!callback.is_null()); | 571 DCHECK(!callback.is_null()); |
| 572 | 572 |
| 573 if (directory_service_->origin() == INITIALIZING) { | 573 if (directory_service_->origin() == INITIALIZING) { |
| 574 // If root feed is not initialized but the initialization process has | 574 // If root feed is not initialized but the initialization process has |
| 575 // already started, add an observer to execute the remaining task after | 575 // already started, add an observer to execute the remaining task after |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 local_src_file_path, | 628 local_src_file_path, |
| 629 remote_dest_file_path, | 629 remote_dest_file_path, |
| 630 callback)); | 630 callback)); |
| 631 } | 631 } |
| 632 | 632 |
| 633 void GDataFileSystem::TransferFileFromLocalToRemoteAfterGetEntryInfo( | 633 void GDataFileSystem::TransferFileFromLocalToRemoteAfterGetEntryInfo( |
| 634 const FilePath& local_src_file_path, | 634 const FilePath& local_src_file_path, |
| 635 const FilePath& remote_dest_file_path, | 635 const FilePath& remote_dest_file_path, |
| 636 const FileOperationCallback& callback, | 636 const FileOperationCallback& callback, |
| 637 GDataFileError error, | 637 GDataFileError error, |
| 638 scoped_ptr<GDataEntryProto> entry_proto) { | 638 scoped_ptr<DriveEntryProto> entry_proto) { |
| 639 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 639 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 640 DCHECK(!callback.is_null()); | 640 DCHECK(!callback.is_null()); |
| 641 | 641 |
| 642 if (error != GDATA_FILE_OK) { | 642 if (error != GDATA_FILE_OK) { |
| 643 callback.Run(error); | 643 callback.Run(error); |
| 644 return; | 644 return; |
| 645 } | 645 } |
| 646 | 646 |
| 647 DCHECK(entry_proto.get()); | 647 DCHECK(entry_proto.get()); |
| 648 if (!entry_proto->file_info().is_directory()) { | 648 if (!entry_proto->file_info().is_directory()) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 params, | 748 params, |
| 749 *file_size, | 749 *file_size, |
| 750 *content_type)); | 750 *content_type)); |
| 751 } | 751 } |
| 752 | 752 |
| 753 void GDataFileSystem::StartFileUploadOnUIThreadAfterGetEntryInfo( | 753 void GDataFileSystem::StartFileUploadOnUIThreadAfterGetEntryInfo( |
| 754 const StartFileUploadParams& params, | 754 const StartFileUploadParams& params, |
| 755 int64 file_size, | 755 int64 file_size, |
| 756 std::string content_type, | 756 std::string content_type, |
| 757 GDataFileError error, | 757 GDataFileError error, |
| 758 scoped_ptr<GDataEntryProto> entry_proto) { | 758 scoped_ptr<DriveEntryProto> entry_proto) { |
| 759 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 759 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 760 | 760 |
| 761 if (entry_proto.get() && !entry_proto->file_info().is_directory()) | 761 if (entry_proto.get() && !entry_proto->file_info().is_directory()) |
| 762 error = GDATA_FILE_ERROR_NOT_A_DIRECTORY; | 762 error = GDATA_FILE_ERROR_NOT_A_DIRECTORY; |
| 763 | 763 |
| 764 if (error != GDATA_FILE_OK) { | 764 if (error != GDATA_FILE_OK) { |
| 765 if (!params.callback.is_null()) | 765 if (!params.callback.is_null()) |
| 766 params.callback.Run(error); | 766 params.callback.Run(error); |
| 767 return; | 767 return; |
| 768 } | 768 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 DCHECK(result.get()); | 846 DCHECK(result.get()); |
| 847 | 847 |
| 848 if (result->first.error != GDATA_FILE_OK) { | 848 if (result->first.error != GDATA_FILE_OK) { |
| 849 callback.Run(result->first.error); | 849 callback.Run(result->first.error); |
| 850 return; | 850 return; |
| 851 } else if (result->second.error != GDATA_FILE_OK) { | 851 } else if (result->second.error != GDATA_FILE_OK) { |
| 852 callback.Run(result->second.error); | 852 callback.Run(result->second.error); |
| 853 return; | 853 return; |
| 854 } | 854 } |
| 855 | 855 |
| 856 scoped_ptr<GDataEntryProto> src_file_proto = result->first.proto.Pass(); | 856 scoped_ptr<DriveEntryProto> src_file_proto = result->first.proto.Pass(); |
| 857 scoped_ptr<GDataEntryProto> dest_parent_proto = result->second.proto.Pass(); | 857 scoped_ptr<DriveEntryProto> dest_parent_proto = result->second.proto.Pass(); |
| 858 | 858 |
| 859 if (!dest_parent_proto->file_info().is_directory()) { | 859 if (!dest_parent_proto->file_info().is_directory()) { |
| 860 callback.Run(GDATA_FILE_ERROR_NOT_A_DIRECTORY); | 860 callback.Run(GDATA_FILE_ERROR_NOT_A_DIRECTORY); |
| 861 return; | 861 return; |
| 862 } else if (src_file_proto->file_info().is_directory()) { | 862 } else if (src_file_proto->file_info().is_directory()) { |
| 863 // TODO(kochi): Implement copy for directories. In the interim, | 863 // TODO(kochi): Implement copy for directories. In the interim, |
| 864 // we handle recursive directory copy in the file manager. | 864 // we handle recursive directory copy in the file manager. |
| 865 // crbug.com/141596 | 865 // crbug.com/141596 |
| 866 callback.Run(GDATA_FILE_ERROR_INVALID_OPERATION); | 866 callback.Run(GDATA_FILE_ERROR_INVALID_OPERATION); |
| 867 return; | 867 return; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 file_path, | 976 file_path, |
| 977 new_name, | 977 new_name, |
| 978 callback)); | 978 callback)); |
| 979 } | 979 } |
| 980 | 980 |
| 981 void GDataFileSystem::RenameAfterGetEntryInfo( | 981 void GDataFileSystem::RenameAfterGetEntryInfo( |
| 982 const FilePath& file_path, | 982 const FilePath& file_path, |
| 983 const FilePath::StringType& new_name, | 983 const FilePath::StringType& new_name, |
| 984 const FileMoveCallback& callback, | 984 const FileMoveCallback& callback, |
| 985 GDataFileError error, | 985 GDataFileError error, |
| 986 scoped_ptr<GDataEntryProto> entry_proto) { | 986 scoped_ptr<DriveEntryProto> entry_proto) { |
| 987 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 987 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 988 | 988 |
| 989 if (error != GDATA_FILE_OK) { | 989 if (error != GDATA_FILE_OK) { |
| 990 if (!callback.is_null()) | 990 if (!callback.is_null()) |
| 991 callback.Run(error, file_path); | 991 callback.Run(error, file_path); |
| 992 return; | 992 return; |
| 993 } | 993 } |
| 994 DCHECK(entry_proto.get()); | 994 DCHECK(entry_proto.get()); |
| 995 | 995 |
| 996 // Drop the .g<something> extension from |new_name| if the file being | 996 // Drop the .g<something> extension from |new_name| if the file being |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 DCHECK(result.get()); | 1054 DCHECK(result.get()); |
| 1055 | 1055 |
| 1056 if (result->first.error != GDATA_FILE_OK) { | 1056 if (result->first.error != GDATA_FILE_OK) { |
| 1057 callback.Run(result->first.error); | 1057 callback.Run(result->first.error); |
| 1058 return; | 1058 return; |
| 1059 } else if (result->second.error != GDATA_FILE_OK) { | 1059 } else if (result->second.error != GDATA_FILE_OK) { |
| 1060 callback.Run(result->second.error); | 1060 callback.Run(result->second.error); |
| 1061 return; | 1061 return; |
| 1062 } | 1062 } |
| 1063 | 1063 |
| 1064 scoped_ptr<GDataEntryProto> dest_parent_proto = result->second.proto.Pass(); | 1064 scoped_ptr<DriveEntryProto> dest_parent_proto = result->second.proto.Pass(); |
| 1065 if (!dest_parent_proto->file_info().is_directory()) { | 1065 if (!dest_parent_proto->file_info().is_directory()) { |
| 1066 callback.Run(GDATA_FILE_ERROR_NOT_A_DIRECTORY); | 1066 callback.Run(GDATA_FILE_ERROR_NOT_A_DIRECTORY); |
| 1067 return; | 1067 return; |
| 1068 } | 1068 } |
| 1069 | 1069 |
| 1070 // If the file/directory is moved to the same directory, just rename it. | 1070 // If the file/directory is moved to the same directory, just rename it. |
| 1071 const FilePath& src_file_path = result->first.path; | 1071 const FilePath& src_file_path = result->first.path; |
| 1072 const FilePath& dest_parent_path = result->second.path; | 1072 const FilePath& dest_parent_path = result->second.path; |
| 1073 if (src_file_path.DirName() == dest_parent_path) { | 1073 if (src_file_path.DirName() == dest_parent_path) { |
| 1074 FileMoveCallback final_file_path_update_callback = | 1074 FileMoveCallback final_file_path_update_callback = |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 DCHECK(result.get()); | 1137 DCHECK(result.get()); |
| 1138 | 1138 |
| 1139 if (result->first.error != GDATA_FILE_OK) { | 1139 if (result->first.error != GDATA_FILE_OK) { |
| 1140 callback.Run(result->first.error); | 1140 callback.Run(result->first.error); |
| 1141 return; | 1141 return; |
| 1142 } else if (result->second.error != GDATA_FILE_OK) { | 1142 } else if (result->second.error != GDATA_FILE_OK) { |
| 1143 callback.Run(result->second.error); | 1143 callback.Run(result->second.error); |
| 1144 return; | 1144 return; |
| 1145 } | 1145 } |
| 1146 | 1146 |
| 1147 scoped_ptr<GDataEntryProto> src_proto = result->first.proto.Pass(); | 1147 scoped_ptr<DriveEntryProto> src_proto = result->first.proto.Pass(); |
| 1148 scoped_ptr<GDataEntryProto> dir_proto = result->second.proto.Pass(); | 1148 scoped_ptr<DriveEntryProto> dir_proto = result->second.proto.Pass(); |
| 1149 | 1149 |
| 1150 if (!dir_proto->file_info().is_directory()) { | 1150 if (!dir_proto->file_info().is_directory()) { |
| 1151 callback.Run(GDATA_FILE_ERROR_NOT_A_DIRECTORY); | 1151 callback.Run(GDATA_FILE_ERROR_NOT_A_DIRECTORY); |
| 1152 return; | 1152 return; |
| 1153 } | 1153 } |
| 1154 | 1154 |
| 1155 const FilePath& file_path = result->first.path; | 1155 const FilePath& file_path = result->first.path; |
| 1156 const FilePath& dir_path = result->second.path; | 1156 const FilePath& dir_path = result->second.path; |
| 1157 drive_service_->AddResourceToDirectory( | 1157 drive_service_->AddResourceToDirectory( |
| 1158 GURL(dir_proto->content_url()), | 1158 GURL(dir_proto->content_url()), |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 const FilePath& file_path = result->first.path; | 1197 const FilePath& file_path = result->first.path; |
| 1198 const FilePath& dir_path = result->second.path; | 1198 const FilePath& dir_path = result->second.path; |
| 1199 if (result->first.error != GDATA_FILE_OK) { | 1199 if (result->first.error != GDATA_FILE_OK) { |
| 1200 callback.Run(result->first.error, file_path); | 1200 callback.Run(result->first.error, file_path); |
| 1201 return; | 1201 return; |
| 1202 } else if (result->second.error != GDATA_FILE_OK) { | 1202 } else if (result->second.error != GDATA_FILE_OK) { |
| 1203 callback.Run(result->second.error, file_path); | 1203 callback.Run(result->second.error, file_path); |
| 1204 return; | 1204 return; |
| 1205 } | 1205 } |
| 1206 | 1206 |
| 1207 scoped_ptr<GDataEntryProto> entry_proto = result->first.proto.Pass(); | 1207 scoped_ptr<DriveEntryProto> entry_proto = result->first.proto.Pass(); |
| 1208 scoped_ptr<GDataEntryProto> dir_proto = result->second.proto.Pass(); | 1208 scoped_ptr<DriveEntryProto> dir_proto = result->second.proto.Pass(); |
| 1209 | 1209 |
| 1210 if (!dir_proto->file_info().is_directory()) { | 1210 if (!dir_proto->file_info().is_directory()) { |
| 1211 callback.Run(GDATA_FILE_ERROR_NOT_A_DIRECTORY, file_path); | 1211 callback.Run(GDATA_FILE_ERROR_NOT_A_DIRECTORY, file_path); |
| 1212 return; | 1212 return; |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 drive_service_->RemoveResourceFromDirectory( | 1215 drive_service_->RemoveResourceFromDirectory( |
| 1216 GURL(dir_proto->content_url()), | 1216 GURL(dir_proto->content_url()), |
| 1217 GURL(entry_proto->edit_url()), | 1217 GURL(entry_proto->edit_url()), |
| 1218 entry_proto->resource_id(), | 1218 entry_proto->resource_id(), |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1250 file_path, | 1250 file_path, |
| 1251 is_recursive, | 1251 is_recursive, |
| 1252 callback)); | 1252 callback)); |
| 1253 } | 1253 } |
| 1254 | 1254 |
| 1255 void GDataFileSystem::RemoveOnUIThreadAfterGetEntryInfo( | 1255 void GDataFileSystem::RemoveOnUIThreadAfterGetEntryInfo( |
| 1256 const FilePath& file_path, | 1256 const FilePath& file_path, |
| 1257 bool /* is_recursive */, | 1257 bool /* is_recursive */, |
| 1258 const FileOperationCallback& callback, | 1258 const FileOperationCallback& callback, |
| 1259 GDataFileError error, | 1259 GDataFileError error, |
| 1260 scoped_ptr<GDataEntryProto> entry_proto) { | 1260 scoped_ptr<DriveEntryProto> entry_proto) { |
| 1261 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1261 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1262 | 1262 |
| 1263 if (error != GDATA_FILE_OK) { | 1263 if (error != GDATA_FILE_OK) { |
| 1264 if (!callback.is_null()) { | 1264 if (!callback.is_null()) { |
| 1265 base::MessageLoopProxy::current()->PostTask( | 1265 base::MessageLoopProxy::current()->PostTask( |
| 1266 FROM_HERE, base::Bind(callback, error)); | 1266 FROM_HERE, base::Bind(callback, error)); |
| 1267 } | 1267 } |
| 1268 return; | 1268 return; |
| 1269 } | 1269 } |
| 1270 | 1270 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1388 file_path, | 1388 file_path, |
| 1389 is_exclusive, | 1389 is_exclusive, |
| 1390 callback)); | 1390 callback)); |
| 1391 } | 1391 } |
| 1392 | 1392 |
| 1393 void GDataFileSystem::OnGetEntryInfoForCreateFile( | 1393 void GDataFileSystem::OnGetEntryInfoForCreateFile( |
| 1394 const FilePath& file_path, | 1394 const FilePath& file_path, |
| 1395 bool is_exclusive, | 1395 bool is_exclusive, |
| 1396 const FileOperationCallback& callback, | 1396 const FileOperationCallback& callback, |
| 1397 GDataFileError result, | 1397 GDataFileError result, |
| 1398 scoped_ptr<GDataEntryProto> entry_proto) { | 1398 scoped_ptr<DriveEntryProto> entry_proto) { |
| 1399 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1399 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1400 DCHECK(!callback.is_null()); | 1400 DCHECK(!callback.is_null()); |
| 1401 | 1401 |
| 1402 // The |file_path| is invalid. It is an error. | 1402 // The |file_path| is invalid. It is an error. |
| 1403 if (result != GDATA_FILE_ERROR_NOT_FOUND && | 1403 if (result != GDATA_FILE_ERROR_NOT_FOUND && |
| 1404 result != GDATA_FILE_OK) { | 1404 result != GDATA_FILE_OK) { |
| 1405 callback.Run(result); | 1405 callback.Run(result); |
| 1406 return; | 1406 return; |
| 1407 } | 1407 } |
| 1408 | 1408 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1456 file_path, | 1456 file_path, |
| 1457 CreateRelayCallback(get_file_callback), | 1457 CreateRelayCallback(get_file_callback), |
| 1458 CreateRelayCallback(get_content_callback))); | 1458 CreateRelayCallback(get_content_callback))); |
| 1459 } | 1459 } |
| 1460 | 1460 |
| 1461 void GDataFileSystem::OnGetEntryInfoCompleteForGetFileByPath( | 1461 void GDataFileSystem::OnGetEntryInfoCompleteForGetFileByPath( |
| 1462 const FilePath& file_path, | 1462 const FilePath& file_path, |
| 1463 const GetFileCallback& get_file_callback, | 1463 const GetFileCallback& get_file_callback, |
| 1464 const GetContentCallback& get_content_callback, | 1464 const GetContentCallback& get_content_callback, |
| 1465 GDataFileError error, | 1465 GDataFileError error, |
| 1466 scoped_ptr<GDataEntryProto> entry_proto) { | 1466 scoped_ptr<DriveEntryProto> entry_proto) { |
| 1467 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1467 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1468 | 1468 |
| 1469 // If |error| == PLATFORM_FILE_OK then |entry_proto| must be valid. | 1469 // If |error| == PLATFORM_FILE_OK then |entry_proto| must be valid. |
| 1470 DCHECK(error != GDATA_FILE_OK || | 1470 DCHECK(error != GDATA_FILE_OK || |
| 1471 (entry_proto.get() && !entry_proto->resource_id().empty())); | 1471 (entry_proto.get() && !entry_proto->resource_id().empty())); |
| 1472 GetResolvedFileByPath(file_path, | 1472 GetResolvedFileByPath(file_path, |
| 1473 get_file_callback, | 1473 get_file_callback, |
| 1474 get_content_callback, | 1474 get_content_callback, |
| 1475 error, | 1475 error, |
| 1476 entry_proto.get()); | 1476 entry_proto.get()); |
| 1477 } | 1477 } |
| 1478 | 1478 |
| 1479 void GDataFileSystem::GetResolvedFileByPath( | 1479 void GDataFileSystem::GetResolvedFileByPath( |
| 1480 const FilePath& file_path, | 1480 const FilePath& file_path, |
| 1481 const GetFileCallback& get_file_callback, | 1481 const GetFileCallback& get_file_callback, |
| 1482 const GetContentCallback& get_content_callback, | 1482 const GetContentCallback& get_content_callback, |
| 1483 GDataFileError error, | 1483 GDataFileError error, |
| 1484 const GDataEntryProto* entry_proto) { | 1484 const DriveEntryProto* entry_proto) { |
| 1485 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1485 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1486 | 1486 |
| 1487 if (entry_proto && !entry_proto->has_file_specific_info()) | 1487 if (entry_proto && !entry_proto->has_file_specific_info()) |
| 1488 error = GDATA_FILE_ERROR_NOT_FOUND; | 1488 error = GDATA_FILE_ERROR_NOT_FOUND; |
| 1489 | 1489 |
| 1490 if (error != GDATA_FILE_OK) { | 1490 if (error != GDATA_FILE_OK) { |
| 1491 if (!get_file_callback.is_null()) { | 1491 if (!get_file_callback.is_null()) { |
| 1492 MessageLoop::current()->PostTask( | 1492 MessageLoop::current()->PostTask( |
| 1493 FROM_HERE, | 1493 FROM_HERE, |
| 1494 base::Bind(get_file_callback, | 1494 base::Bind(get_file_callback, |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1765 } | 1765 } |
| 1766 | 1766 |
| 1767 void GDataFileSystem::GetEntryInfoByPathOnUIThreadAfterLoad( | 1767 void GDataFileSystem::GetEntryInfoByPathOnUIThreadAfterLoad( |
| 1768 const FilePath& file_path, | 1768 const FilePath& file_path, |
| 1769 const GetEntryInfoCallback& callback, | 1769 const GetEntryInfoCallback& callback, |
| 1770 GDataFileError error) { | 1770 GDataFileError error) { |
| 1771 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1771 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1772 DCHECK(!callback.is_null()); | 1772 DCHECK(!callback.is_null()); |
| 1773 | 1773 |
| 1774 if (error != GDATA_FILE_OK) { | 1774 if (error != GDATA_FILE_OK) { |
| 1775 callback.Run(error, scoped_ptr<GDataEntryProto>()); | 1775 callback.Run(error, scoped_ptr<DriveEntryProto>()); |
| 1776 return; | 1776 return; |
| 1777 } | 1777 } |
| 1778 | 1778 |
| 1779 directory_service_->GetEntryInfoByPath( | 1779 directory_service_->GetEntryInfoByPath( |
| 1780 file_path, | 1780 file_path, |
| 1781 base::Bind(&GDataFileSystem::GetEntryInfoByPathOnUIThreadAfterGetEntry, | 1781 base::Bind(&GDataFileSystem::GetEntryInfoByPathOnUIThreadAfterGetEntry, |
| 1782 ui_weak_ptr_, | 1782 ui_weak_ptr_, |
| 1783 callback)); | 1783 callback)); |
| 1784 } | 1784 } |
| 1785 | 1785 |
| 1786 void GDataFileSystem::GetEntryInfoByPathOnUIThreadAfterGetEntry( | 1786 void GDataFileSystem::GetEntryInfoByPathOnUIThreadAfterGetEntry( |
| 1787 const GetEntryInfoCallback& callback, | 1787 const GetEntryInfoCallback& callback, |
| 1788 GDataFileError error, | 1788 GDataFileError error, |
| 1789 scoped_ptr<GDataEntryProto> entry_proto) { | 1789 scoped_ptr<DriveEntryProto> entry_proto) { |
| 1790 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1790 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1791 DCHECK(!callback.is_null()); | 1791 DCHECK(!callback.is_null()); |
| 1792 | 1792 |
| 1793 if (error != GDATA_FILE_OK) { | 1793 if (error != GDATA_FILE_OK) { |
| 1794 callback.Run(error, scoped_ptr<GDataEntryProto>()); | 1794 callback.Run(error, scoped_ptr<DriveEntryProto>()); |
| 1795 return; | 1795 return; |
| 1796 } | 1796 } |
| 1797 DCHECK(entry_proto.get()); | 1797 DCHECK(entry_proto.get()); |
| 1798 | 1798 |
| 1799 CheckLocalModificationAndRun(entry_proto.Pass(), callback); | 1799 CheckLocalModificationAndRun(entry_proto.Pass(), callback); |
| 1800 } | 1800 } |
| 1801 | 1801 |
| 1802 void GDataFileSystem::ReadDirectoryByPath( | 1802 void GDataFileSystem::ReadDirectoryByPath( |
| 1803 const FilePath& file_path, | 1803 const FilePath& file_path, |
| 1804 const ReadDirectoryWithSettingCallback& callback) { | 1804 const ReadDirectoryWithSettingCallback& callback) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1829 void GDataFileSystem::ReadDirectoryByPathOnUIThreadAfterLoad( | 1829 void GDataFileSystem::ReadDirectoryByPathOnUIThreadAfterLoad( |
| 1830 const FilePath& file_path, | 1830 const FilePath& file_path, |
| 1831 const ReadDirectoryWithSettingCallback& callback, | 1831 const ReadDirectoryWithSettingCallback& callback, |
| 1832 GDataFileError error) { | 1832 GDataFileError error) { |
| 1833 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1833 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1834 DCHECK(!callback.is_null()); | 1834 DCHECK(!callback.is_null()); |
| 1835 | 1835 |
| 1836 if (error != GDATA_FILE_OK) { | 1836 if (error != GDATA_FILE_OK) { |
| 1837 callback.Run(error, | 1837 callback.Run(error, |
| 1838 hide_hosted_docs_, | 1838 hide_hosted_docs_, |
| 1839 scoped_ptr<GDataEntryProtoVector>()); | 1839 scoped_ptr<DriveEntryProtoVector>()); |
| 1840 return; | 1840 return; |
| 1841 } | 1841 } |
| 1842 | 1842 |
| 1843 directory_service_->ReadDirectoryByPath( | 1843 directory_service_->ReadDirectoryByPath( |
| 1844 file_path, | 1844 file_path, |
| 1845 base::Bind(&GDataFileSystem::ReadDirectoryByPathOnUIThreadAfterRead, | 1845 base::Bind(&GDataFileSystem::ReadDirectoryByPathOnUIThreadAfterRead, |
| 1846 ui_weak_ptr_, | 1846 ui_weak_ptr_, |
| 1847 callback)); | 1847 callback)); |
| 1848 } | 1848 } |
| 1849 | 1849 |
| 1850 void GDataFileSystem::ReadDirectoryByPathOnUIThreadAfterRead( | 1850 void GDataFileSystem::ReadDirectoryByPathOnUIThreadAfterRead( |
| 1851 const ReadDirectoryWithSettingCallback& callback, | 1851 const ReadDirectoryWithSettingCallback& callback, |
| 1852 GDataFileError error, | 1852 GDataFileError error, |
| 1853 scoped_ptr<GDataEntryProtoVector> entries) { | 1853 scoped_ptr<DriveEntryProtoVector> entries) { |
| 1854 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1854 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1855 DCHECK(!callback.is_null()); | 1855 DCHECK(!callback.is_null()); |
| 1856 | 1856 |
| 1857 if (error != GDATA_FILE_OK) { | 1857 if (error != GDATA_FILE_OK) { |
| 1858 callback.Run(error, | 1858 callback.Run(error, |
| 1859 hide_hosted_docs_, | 1859 hide_hosted_docs_, |
| 1860 scoped_ptr<GDataEntryProtoVector>()); | 1860 scoped_ptr<DriveEntryProtoVector>()); |
| 1861 return; | 1861 return; |
| 1862 } | 1862 } |
| 1863 DCHECK(entries.get()); // This is valid for emptry directories too. | 1863 DCHECK(entries.get()); // This is valid for emptry directories too. |
| 1864 | 1864 |
| 1865 callback.Run(GDATA_FILE_OK, hide_hosted_docs_, entries.Pass()); | 1865 callback.Run(GDATA_FILE_OK, hide_hosted_docs_, entries.Pass()); |
| 1866 } | 1866 } |
| 1867 | 1867 |
| 1868 void GDataFileSystem::RequestDirectoryRefresh(const FilePath& file_path) { | 1868 void GDataFileSystem::RequestDirectoryRefresh(const FilePath& file_path) { |
| 1869 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 1869 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
| 1870 BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1870 BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1883 file_path, | 1883 file_path, |
| 1884 base::Bind( | 1884 base::Bind( |
| 1885 &GDataFileSystem::RequestDirectoryRefreshOnUIThreadAfterGetEntryInfo, | 1885 &GDataFileSystem::RequestDirectoryRefreshOnUIThreadAfterGetEntryInfo, |
| 1886 ui_weak_ptr_, | 1886 ui_weak_ptr_, |
| 1887 file_path)); | 1887 file_path)); |
| 1888 } | 1888 } |
| 1889 | 1889 |
| 1890 void GDataFileSystem::RequestDirectoryRefreshOnUIThreadAfterGetEntryInfo( | 1890 void GDataFileSystem::RequestDirectoryRefreshOnUIThreadAfterGetEntryInfo( |
| 1891 const FilePath& file_path, | 1891 const FilePath& file_path, |
| 1892 GDataFileError error, | 1892 GDataFileError error, |
| 1893 scoped_ptr<GDataEntryProto> entry_proto) { | 1893 scoped_ptr<DriveEntryProto> entry_proto) { |
| 1894 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1894 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1895 | 1895 |
| 1896 if (error != GDATA_FILE_OK || | 1896 if (error != GDATA_FILE_OK || |
| 1897 !entry_proto->file_info().is_directory()) { | 1897 !entry_proto->file_info().is_directory()) { |
| 1898 LOG(ERROR) << "Directory entry not found: " << file_path.value(); | 1898 LOG(ERROR) << "Directory entry not found: " << file_path.value(); |
| 1899 return; | 1899 return; |
| 1900 } | 1900 } |
| 1901 | 1901 |
| 1902 feed_loader_->LoadDirectoryFromServer( | 1902 feed_loader_->LoadDirectoryFromServer( |
| 1903 directory_service_->origin(), | 1903 directory_service_->origin(), |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2480 status, | 2480 status, |
| 2481 content_url, | 2481 content_url, |
| 2482 downloaded_file_path, | 2482 downloaded_file_path, |
| 2483 base::Owned(has_enough_space))); | 2483 base::Owned(has_enough_space))); |
| 2484 } | 2484 } |
| 2485 | 2485 |
| 2486 void GDataFileSystem::UnpinIfPinned( | 2486 void GDataFileSystem::UnpinIfPinned( |
| 2487 const std::string& resource_id, | 2487 const std::string& resource_id, |
| 2488 const std::string& md5, | 2488 const std::string& md5, |
| 2489 bool success, | 2489 bool success, |
| 2490 const GDataCacheEntry& cache_entry) { | 2490 const DriveCacheEntry& cache_entry) { |
| 2491 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2491 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2492 // TODO(hshi): http://crbug.com/127138 notify when file properties change. | 2492 // TODO(hshi): http://crbug.com/127138 notify when file properties change. |
| 2493 // This allows file manager to clear the "Available offline" checkbox. | 2493 // This allows file manager to clear the "Available offline" checkbox. |
| 2494 if (success && cache_entry.is_pinned()) | 2494 if (success && cache_entry.is_pinned()) |
| 2495 cache_->UnpinOnUIThread(resource_id, md5, CacheOperationCallback()); | 2495 cache_->UnpinOnUIThread(resource_id, md5, CacheOperationCallback()); |
| 2496 } | 2496 } |
| 2497 | 2497 |
| 2498 void GDataFileSystem::OnFileDownloadedAndSpaceChecked( | 2498 void GDataFileSystem::OnFileDownloadedAndSpaceChecked( |
| 2499 const GetFileFromCacheParams& params, | 2499 const GetFileFromCacheParams& params, |
| 2500 GDataErrorCode status, | 2500 GDataErrorCode status, |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3062 base::Bind(&GDataFileSystem::OnOpenFileFinished, | 3062 base::Bind(&GDataFileSystem::OnOpenFileFinished, |
| 3063 ui_weak_ptr_, | 3063 ui_weak_ptr_, |
| 3064 file_path, | 3064 file_path, |
| 3065 callback))); | 3065 callback))); |
| 3066 } | 3066 } |
| 3067 | 3067 |
| 3068 void GDataFileSystem::OnGetEntryInfoCompleteForOpenFile( | 3068 void GDataFileSystem::OnGetEntryInfoCompleteForOpenFile( |
| 3069 const FilePath& file_path, | 3069 const FilePath& file_path, |
| 3070 const OpenFileCallback& callback, | 3070 const OpenFileCallback& callback, |
| 3071 GDataFileError error, | 3071 GDataFileError error, |
| 3072 scoped_ptr<GDataEntryProto> entry_proto) { | 3072 scoped_ptr<DriveEntryProto> entry_proto) { |
| 3073 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 3073 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 3074 | 3074 |
| 3075 if (entry_proto.get() && !entry_proto->has_file_specific_info()) | 3075 if (entry_proto.get() && !entry_proto->has_file_specific_info()) |
| 3076 error = GDATA_FILE_ERROR_NOT_FOUND; | 3076 error = GDATA_FILE_ERROR_NOT_FOUND; |
| 3077 | 3077 |
| 3078 if (error == GDATA_FILE_OK) { | 3078 if (error == GDATA_FILE_OK) { |
| 3079 if (entry_proto->file_specific_info().file_md5().empty() || | 3079 if (entry_proto->file_specific_info().file_md5().empty() || |
| 3080 entry_proto->file_specific_info().is_hosted_document()) { | 3080 entry_proto->file_specific_info().is_hosted_document()) { |
| 3081 // No support for opening a directory or hosted document. | 3081 // No support for opening a directory or hosted document. |
| 3082 error = GDATA_FILE_ERROR_INVALID_OPERATION; | 3082 error = GDATA_FILE_ERROR_INVALID_OPERATION; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3192 base::Bind(&GDataFileSystem::CloseFileOnUIThreadFinalize, | 3192 base::Bind(&GDataFileSystem::CloseFileOnUIThreadFinalize, |
| 3193 ui_weak_ptr_, | 3193 ui_weak_ptr_, |
| 3194 file_path, | 3194 file_path, |
| 3195 callback))); | 3195 callback))); |
| 3196 } | 3196 } |
| 3197 | 3197 |
| 3198 void GDataFileSystem::CloseFileOnUIThreadAfterGetEntryInfo( | 3198 void GDataFileSystem::CloseFileOnUIThreadAfterGetEntryInfo( |
| 3199 const FilePath& file_path, | 3199 const FilePath& file_path, |
| 3200 const FileOperationCallback& callback, | 3200 const FileOperationCallback& callback, |
| 3201 GDataFileError error, | 3201 GDataFileError error, |
| 3202 scoped_ptr<GDataEntryProto> entry_proto) { | 3202 scoped_ptr<DriveEntryProto> entry_proto) { |
| 3203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 3203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 3204 DCHECK(!callback.is_null()); | 3204 DCHECK(!callback.is_null()); |
| 3205 | 3205 |
| 3206 if (entry_proto.get() && !entry_proto->has_file_specific_info()) | 3206 if (entry_proto.get() && !entry_proto->has_file_specific_info()) |
| 3207 error = GDATA_FILE_ERROR_NOT_FOUND; | 3207 error = GDATA_FILE_ERROR_NOT_FOUND; |
| 3208 | 3208 |
| 3209 if (error != GDATA_FILE_OK) { | 3209 if (error != GDATA_FILE_OK) { |
| 3210 callback.Run(error); | 3210 callback.Run(error); |
| 3211 return; | 3211 return; |
| 3212 } | 3212 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3247 // All the invocation of |callback| from operations initiated from CloseFile | 3247 // All the invocation of |callback| from operations initiated from CloseFile |
| 3248 // must go through here. Removes the |file_path| from the remembered set so | 3248 // must go through here. Removes the |file_path| from the remembered set so |
| 3249 // that subsequent operations can open the file again. | 3249 // that subsequent operations can open the file again. |
| 3250 open_files_.erase(file_path); | 3250 open_files_.erase(file_path); |
| 3251 | 3251 |
| 3252 // Then invokes the user-supplied callback function. | 3252 // Then invokes the user-supplied callback function. |
| 3253 callback.Run(result); | 3253 callback.Run(result); |
| 3254 } | 3254 } |
| 3255 | 3255 |
| 3256 void GDataFileSystem::CheckLocalModificationAndRun( | 3256 void GDataFileSystem::CheckLocalModificationAndRun( |
| 3257 scoped_ptr<GDataEntryProto> entry_proto, | 3257 scoped_ptr<DriveEntryProto> entry_proto, |
| 3258 const GetEntryInfoCallback& callback) { | 3258 const GetEntryInfoCallback& callback) { |
| 3259 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 3259 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 3260 DCHECK(entry_proto.get()); | 3260 DCHECK(entry_proto.get()); |
| 3261 DCHECK(!callback.is_null()); | 3261 DCHECK(!callback.is_null()); |
| 3262 | 3262 |
| 3263 // For entries that will never be cached, use the original entry info as is. | 3263 // For entries that will never be cached, use the original entry info as is. |
| 3264 if (!entry_proto->has_file_specific_info() || | 3264 if (!entry_proto->has_file_specific_info() || |
| 3265 entry_proto->file_specific_info().is_hosted_document()) { | 3265 entry_proto->file_specific_info().is_hosted_document()) { |
| 3266 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); | 3266 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); |
| 3267 return; | 3267 return; |
| 3268 } | 3268 } |
| 3269 | 3269 |
| 3270 // Checks if the file is cached and modified locally. | 3270 // Checks if the file is cached and modified locally. |
| 3271 const std::string resource_id = entry_proto->resource_id(); | 3271 const std::string resource_id = entry_proto->resource_id(); |
| 3272 const std::string md5 = entry_proto->file_specific_info().file_md5(); | 3272 const std::string md5 = entry_proto->file_specific_info().file_md5(); |
| 3273 cache_->GetCacheEntryOnUIThread( | 3273 cache_->GetCacheEntryOnUIThread( |
| 3274 resource_id, | 3274 resource_id, |
| 3275 md5, | 3275 md5, |
| 3276 base::Bind( | 3276 base::Bind( |
| 3277 &GDataFileSystem::CheckLocalModificationAndRunAfterGetCacheEntry, | 3277 &GDataFileSystem::CheckLocalModificationAndRunAfterGetCacheEntry, |
| 3278 ui_weak_ptr_, base::Passed(&entry_proto), callback)); | 3278 ui_weak_ptr_, base::Passed(&entry_proto), callback)); |
| 3279 } | 3279 } |
| 3280 | 3280 |
| 3281 void GDataFileSystem::CheckLocalModificationAndRunAfterGetCacheEntry( | 3281 void GDataFileSystem::CheckLocalModificationAndRunAfterGetCacheEntry( |
| 3282 scoped_ptr<GDataEntryProto> entry_proto, | 3282 scoped_ptr<DriveEntryProto> entry_proto, |
| 3283 const GetEntryInfoCallback& callback, | 3283 const GetEntryInfoCallback& callback, |
| 3284 bool success, | 3284 bool success, |
| 3285 const GDataCacheEntry& cache_entry) { | 3285 const DriveCacheEntry& cache_entry) { |
| 3286 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 3286 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 3287 DCHECK(!callback.is_null()); | 3287 DCHECK(!callback.is_null()); |
| 3288 | 3288 |
| 3289 // When no dirty cache is found, use the original entry info as is. | 3289 // When no dirty cache is found, use the original entry info as is. |
| 3290 if (!success || !cache_entry.is_dirty()) { | 3290 if (!success || !cache_entry.is_dirty()) { |
| 3291 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); | 3291 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); |
| 3292 return; | 3292 return; |
| 3293 } | 3293 } |
| 3294 | 3294 |
| 3295 // Gets the cache file path. | 3295 // Gets the cache file path. |
| 3296 const std::string& resource_id = entry_proto->resource_id(); | 3296 const std::string& resource_id = entry_proto->resource_id(); |
| 3297 const std::string& md5 = entry_proto->file_specific_info().file_md5(); | 3297 const std::string& md5 = entry_proto->file_specific_info().file_md5(); |
| 3298 cache_->GetFileOnUIThread( | 3298 cache_->GetFileOnUIThread( |
| 3299 resource_id, | 3299 resource_id, |
| 3300 md5, | 3300 md5, |
| 3301 base::Bind( | 3301 base::Bind( |
| 3302 &GDataFileSystem::CheckLocalModificationAndRunAfterGetCacheFile, | 3302 &GDataFileSystem::CheckLocalModificationAndRunAfterGetCacheFile, |
| 3303 ui_weak_ptr_, base::Passed(&entry_proto), callback)); | 3303 ui_weak_ptr_, base::Passed(&entry_proto), callback)); |
| 3304 } | 3304 } |
| 3305 | 3305 |
| 3306 void GDataFileSystem::CheckLocalModificationAndRunAfterGetCacheFile( | 3306 void GDataFileSystem::CheckLocalModificationAndRunAfterGetCacheFile( |
| 3307 scoped_ptr<GDataEntryProto> entry_proto, | 3307 scoped_ptr<DriveEntryProto> entry_proto, |
| 3308 const GetEntryInfoCallback& callback, | 3308 const GetEntryInfoCallback& callback, |
| 3309 GDataFileError error, | 3309 GDataFileError error, |
| 3310 const std::string& resource_id, | 3310 const std::string& resource_id, |
| 3311 const std::string& md5, | 3311 const std::string& md5, |
| 3312 const FilePath& local_cache_path) { | 3312 const FilePath& local_cache_path) { |
| 3313 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 3313 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 3314 DCHECK(!callback.is_null()); | 3314 DCHECK(!callback.is_null()); |
| 3315 | 3315 |
| 3316 // When no dirty cache is found, use the original entry info as is. | 3316 // When no dirty cache is found, use the original entry info as is. |
| 3317 if (error != GDATA_FILE_OK) { | 3317 if (error != GDATA_FILE_OK) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3331 base::Unretained(get_file_info_result)), | 3331 base::Unretained(get_file_info_result)), |
| 3332 base::Bind(&GDataFileSystem::CheckLocalModificationAndRunAfterGetFileInfo, | 3332 base::Bind(&GDataFileSystem::CheckLocalModificationAndRunAfterGetFileInfo, |
| 3333 ui_weak_ptr_, | 3333 ui_weak_ptr_, |
| 3334 base::Passed(&entry_proto), | 3334 base::Passed(&entry_proto), |
| 3335 callback, | 3335 callback, |
| 3336 base::Owned(file_info), | 3336 base::Owned(file_info), |
| 3337 base::Owned(get_file_info_result))); | 3337 base::Owned(get_file_info_result))); |
| 3338 } | 3338 } |
| 3339 | 3339 |
| 3340 void GDataFileSystem::CheckLocalModificationAndRunAfterGetFileInfo( | 3340 void GDataFileSystem::CheckLocalModificationAndRunAfterGetFileInfo( |
| 3341 scoped_ptr<GDataEntryProto> entry_proto, | 3341 scoped_ptr<DriveEntryProto> entry_proto, |
| 3342 const GetEntryInfoCallback& callback, | 3342 const GetEntryInfoCallback& callback, |
| 3343 base::PlatformFileInfo* file_info, | 3343 base::PlatformFileInfo* file_info, |
| 3344 bool* get_file_info_result) { | 3344 bool* get_file_info_result) { |
| 3345 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 3345 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 3346 DCHECK(!callback.is_null()); | 3346 DCHECK(!callback.is_null()); |
| 3347 | 3347 |
| 3348 if (!*get_file_info_result) { | 3348 if (!*get_file_info_result) { |
| 3349 callback.Run(GDATA_FILE_ERROR_NOT_FOUND, scoped_ptr<GDataEntryProto>()); | 3349 callback.Run(GDATA_FILE_ERROR_NOT_FOUND, scoped_ptr<DriveEntryProto>()); |
| 3350 return; | 3350 return; |
| 3351 } | 3351 } |
| 3352 | 3352 |
| 3353 PlatformFileInfoProto entry_file_info; | 3353 PlatformFileInfoProto entry_file_info; |
| 3354 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); | 3354 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); |
| 3355 *entry_proto->mutable_file_info() = entry_file_info; | 3355 *entry_proto->mutable_file_info() = entry_file_info; |
| 3356 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); | 3356 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); |
| 3357 } | 3357 } |
| 3358 | 3358 |
| 3359 } // namespace gdata | 3359 } // namespace gdata |
| OLD | NEW |