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/drive_file_system.h" | 5 #include "chrome/browser/chromeos/drive/drive_file_system.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 DCHECK(!callback.is_null()); | 1007 DCHECK(!callback.is_null()); |
1008 | 1008 |
1009 if (error != DRIVE_FILE_OK) { | 1009 if (error != DRIVE_FILE_OK) { |
1010 callback.Run(error); | 1010 callback.Run(error); |
1011 return; | 1011 return; |
1012 } | 1012 } |
1013 if (!entry_proto->file_info().is_directory()) { | 1013 if (!entry_proto->file_info().is_directory()) { |
1014 callback.Run(DRIVE_FILE_ERROR_NOT_A_DIRECTORY); | 1014 callback.Run(DRIVE_FILE_ERROR_NOT_A_DIRECTORY); |
1015 return; | 1015 return; |
1016 } | 1016 } |
| 1017 if (util::IsSpecialResourceId(entry_proto->resource_id())) { |
| 1018 // Do not load special directories. Just return. |
| 1019 callback.Run(DRIVE_FILE_OK); |
| 1020 return; |
| 1021 } |
1017 | 1022 |
1018 change_list_loader_->LoadDirectoryFromServer( | 1023 change_list_loader_->LoadDirectoryFromServer( |
1019 entry_proto->resource_id(), | 1024 entry_proto->resource_id(), |
1020 callback); | 1025 callback); |
1021 } | 1026 } |
1022 | 1027 |
1023 void DriveFileSystem::UpdateFileByResourceId( | 1028 void DriveFileSystem::UpdateFileByResourceId( |
1024 const std::string& resource_id, | 1029 const std::string& resource_id, |
1025 const DriveClientContext& context, | 1030 const DriveClientContext& context, |
1026 const FileOperationCallback& callback) { | 1031 const FileOperationCallback& callback) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 const bool should_run_callback = (i + 1 == entries.size()); | 1108 const bool should_run_callback = (i + 1 == entries.size()); |
1104 const DriveEntryProto& entry_proto = entries[i]; | 1109 const DriveEntryProto& entry_proto = entries[i]; |
1105 | 1110 |
1106 const GetEntryInfoWithFilePathCallback entry_info_callback = | 1111 const GetEntryInfoWithFilePathCallback entry_info_callback = |
1107 base::Bind(&DriveFileSystem::AddToSearchResults, | 1112 base::Bind(&DriveFileSystem::AddToSearchResults, |
1108 weak_ptr_factory_.GetWeakPtr(), | 1113 weak_ptr_factory_.GetWeakPtr(), |
1109 results, | 1114 results, |
1110 should_run_callback, | 1115 should_run_callback, |
1111 callback); | 1116 callback); |
1112 | 1117 |
1113 // Some entries (e.g. shared_with_me files) are not tracked in | 1118 resource_metadata_->RefreshEntry(entry_proto, entry_info_callback); |
1114 // DriveResourceMetadata, so that we skip RefreshEntry() and call the | |
1115 // callback directly. | |
1116 if (!shared_with_me) { | |
1117 resource_metadata_->RefreshEntry(entry_proto, entry_info_callback); | |
1118 } else { | |
1119 entry_info_callback.Run( | |
1120 DRIVE_FILE_OK, | |
1121 base::FilePath::FromUTF8Unsafe(entry_proto.base_name()), | |
1122 scoped_ptr<DriveEntryProto>(new DriveEntryProto(entry_proto))); | |
1123 } | |
1124 } | 1119 } |
1125 } | 1120 } |
1126 | 1121 |
1127 void DriveFileSystem::AddToSearchResults( | 1122 void DriveFileSystem::AddToSearchResults( |
1128 std::vector<SearchResultInfo>* results, | 1123 std::vector<SearchResultInfo>* results, |
1129 bool should_run_callback, | 1124 bool should_run_callback, |
1130 const base::Closure& callback, | 1125 const base::Closure& callback, |
1131 DriveFileError error, | 1126 DriveFileError error, |
1132 const base::FilePath& drive_file_path, | 1127 const base::FilePath& drive_file_path, |
1133 scoped_ptr<DriveEntryProto> entry_proto) { | 1128 scoped_ptr<DriveEntryProto> entry_proto) { |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1712 return; | 1707 return; |
1713 } | 1708 } |
1714 | 1709 |
1715 PlatformFileInfoProto entry_file_info; | 1710 PlatformFileInfoProto entry_file_info; |
1716 util::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); | 1711 util::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); |
1717 *entry_proto->mutable_file_info() = entry_file_info; | 1712 *entry_proto->mutable_file_info() = entry_file_info; |
1718 callback.Run(DRIVE_FILE_OK, entry_proto.Pass()); | 1713 callback.Run(DRIVE_FILE_OK, entry_proto.Pass()); |
1719 } | 1714 } |
1720 | 1715 |
1721 } // namespace drive | 1716 } // namespace drive |
OLD | NEW |