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

Side by Side Diff: chrome/browser/chromeos/drive/drive_file_system.cc

Issue 11530004: google_apis: DriveServiceInterface::GetResourceEntry() returns ResourceEntry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years 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
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/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 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 // - if we have enough space, start downloading the file from the server 959 // - if we have enough space, start downloading the file from the server
960 GetFileFromCacheParams params(in_params); 960 GetFileFromCacheParams params(in_params);
961 params.cache_file_path = cache_file_path; 961 params.cache_file_path = cache_file_path;
962 drive_service_->GetResourceEntry( 962 drive_service_->GetResourceEntry(
963 params.resource_id, 963 params.resource_id,
964 base::Bind(&DriveFileSystem::OnGetResourceEntry, 964 base::Bind(&DriveFileSystem::OnGetResourceEntry,
965 ui_weak_ptr_, 965 ui_weak_ptr_,
966 params)); 966 params));
967 } 967 }
968 968
969 void DriveFileSystem::OnGetResourceEntry(const GetFileFromCacheParams& params, 969 void DriveFileSystem::OnGetResourceEntry(
970 google_apis::GDataErrorCode status, 970 const GetFileFromCacheParams& params,
971 scoped_ptr<base::Value> data) { 971 google_apis::GDataErrorCode status,
972 scoped_ptr<google_apis::ResourceEntry> entry) {
972 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 973 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
973 DCHECK(!params.get_file_callback.is_null()); 974 DCHECK(!params.get_file_callback.is_null());
974 975
975 const DriveFileError error = util::GDataToDriveFileError(status); 976 const DriveFileError error = util::GDataToDriveFileError(status);
976 if (error != DRIVE_FILE_OK) { 977 if (error != DRIVE_FILE_OK) {
977 params.get_file_callback.Run(error, 978 params.get_file_callback.Run(error,
978 params.cache_file_path, 979 params.cache_file_path,
979 params.mime_type, 980 params.mime_type,
980 REGULAR_FILE); 981 REGULAR_FILE);
981 return; 982 return;
982 } 983 }
983 984
984 scoped_ptr<google_apis::ResourceEntry> entry;
985 if (!google_apis::util::IsDriveV2ApiEnabled()) {
986 entry = google_apis::ResourceEntry::ExtractAndParse(*data);
987 } else {
988 scoped_ptr<google_apis::FileResource> file_resource =
989 google_apis::FileResource::CreateFrom(*data);
990 entry = google_apis::ResourceEntry::CreateFromFileResource(
991 *file_resource);
992 }
993
994 GURL content_url = entry->content_url(); 985 GURL content_url = entry->content_url();
995 int64 file_size = entry->file_size(); 986 int64 file_size = entry->file_size();
996 987
997 // The content URL can be empty for non-downloadable files (such as files 988 // The content URL can be empty for non-downloadable files (such as files
998 // shared from others with "prevent downloading by viewers" flag set.) 989 // shared from others with "prevent downloading by viewers" flag set.)
999 if (content_url.is_empty()) { 990 if (content_url.is_empty()) {
1000 params.get_file_callback.Run(DRIVE_FILE_ERROR_ACCESS_DENIED, 991 params.get_file_callback.Run(DRIVE_FILE_ERROR_ACCESS_DENIED,
1001 params.cache_file_path, 992 params.cache_file_path,
1002 params.mime_type, 993 params.mime_type,
1003 REGULAR_FILE); 994 REGULAR_FILE);
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 return; 2170 return;
2180 } 2171 }
2181 2172
2182 PlatformFileInfoProto entry_file_info; 2173 PlatformFileInfoProto entry_file_info;
2183 util::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); 2174 util::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info);
2184 *entry_proto->mutable_file_info() = entry_file_info; 2175 *entry_proto->mutable_file_info() = entry_file_info;
2185 callback.Run(DRIVE_FILE_OK, entry_proto.Pass()); 2176 callback.Run(DRIVE_FILE_OK, entry_proto.Pass());
2186 } 2177 }
2187 2178
2188 } // namespace drive 2179 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_file_system.h ('k') | chrome/browser/chromeos/drive/drive_file_system_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698