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

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

Issue 10543037: gdata: Convert public synchronous functions in GDataFileSystem to asynchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Toni's comments @ 06/08/12 10:59AM PDT. Created 8 years, 6 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
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_proxy.h" 5 #include "chrome/browser/chromeos/gdata/gdata_file_system_proxy.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 return; 208 return;
209 } 209 }
210 210
211 file_system_->CreateDirectory(file_path, exclusive, recursive, callback); 211 file_system_->CreateDirectory(file_path, exclusive, recursive, callback);
212 } 212 }
213 213
214 void GDataFileSystemProxy::CreateSnapshotFile( 214 void GDataFileSystemProxy::CreateSnapshotFile(
215 const GURL& file_url, 215 const GURL& file_url,
216 const FileSystemOperationInterface::SnapshotFileCallback& callback) { 216 const FileSystemOperationInterface::SnapshotFileCallback& callback) {
217 FilePath file_path; 217 FilePath file_path;
218 base::PlatformFileInfo file_info; 218 if (!ValidateUrl(file_url, &file_path)) {
219 GDataFileProperties file_properties;
220 if (!ValidateUrl(file_url, &file_path) ||
221 !file_system_->GetFileInfoByPath(file_path, &file_properties)) {
222 MessageLoopProxy::current()->PostTask(FROM_HERE, 219 MessageLoopProxy::current()->PostTask(FROM_HERE,
223 base::Bind(callback, 220 base::Bind(callback,
224 base::PLATFORM_FILE_ERROR_NOT_FOUND, 221 base::PLATFORM_FILE_ERROR_NOT_FOUND,
225 base::PlatformFileInfo(), 222 base::PlatformFileInfo(),
226 FilePath(), 223 FilePath(),
227 scoped_refptr<ShareableFileReference>(NULL))); 224 scoped_refptr<ShareableFileReference>(NULL)));
228 return; 225 return;
229 } 226 }
230 227
231 file_system_->GetFileByPath(file_path, 228 file_system_->GetEntryInfoByPathAsync(
229 file_path,
230 base::Bind(&GDataFileSystemProxy::OnGetEntryInfoByPathAsync,
231 this, callback));
232 }
233
234 void GDataFileSystemProxy::OnGetEntryInfoByPathAsync(
235 const FileSystemOperationInterface::SnapshotFileCallback& callback,
236 base::PlatformFileError error,
237 const FilePath& entry_path,
238 scoped_ptr<GDataEntryProto> entry_proto) {
239 if (error != base::PLATFORM_FILE_OK || !entry_proto.get()) {
240 MessageLoopProxy::current()->PostTask(FROM_HERE,
241 base::Bind(callback,
242 base::PLATFORM_FILE_ERROR_NOT_FOUND,
243 base::PlatformFileInfo(),
244 FilePath(),
245 scoped_refptr<ShareableFileReference>(NULL)));
246 return;
247 }
248
249 base::PlatformFileInfo file_info;
250 GDataEntry::ConvertProtoToPlatformFileInfo(
251 entry_proto->file_info(),
252 &file_info);
253
254 file_system_->GetFileByPath(entry_path,
232 base::Bind(&CallSnapshotFileCallback, 255 base::Bind(&CallSnapshotFileCallback,
233 callback, 256 callback,
234 file_properties.file_info), 257 file_info),
235 GetDownloadDataCallback()); 258 GetDownloadDataCallback());
236 } 259 }
237 260
238 // static. 261 // static.
239 bool GDataFileSystemProxy::ValidateUrl(const GURL& url, FilePath* file_path) { 262 bool GDataFileSystemProxy::ValidateUrl(const GURL& url, FilePath* file_path) {
240 // what platform you're on. 263 // what platform you're on.
241 FilePath raw_path; 264 FilePath raw_path;
242 fileapi::FileSystemType type = fileapi::kFileSystemTypeUnknown; 265 fileapi::FileSystemType type = fileapi::kFileSystemTypeUnknown;
243 if (!fileapi::CrackFileSystemURL(url, NULL, &type, file_path) || 266 if (!fileapi::CrackFileSystemURL(url, NULL, &type, file_path) ||
244 type != fileapi::kFileSystemTypeExternal) { 267 type != fileapi::kFileSystemTypeExternal) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 if (hide_hosted_documents && proto.is_hosted_document()) 312 if (hide_hosted_documents && proto.is_hosted_document())
290 continue; 313 continue;
291 entries.push_back( 314 entries.push_back(
292 GDataEntryProtoToFileUtilProxyEntry(proto.gdata_entry())); 315 GDataEntryProtoToFileUtilProxyEntry(proto.gdata_entry()));
293 } 316 }
294 317
295 callback.Run(base::PLATFORM_FILE_OK, entries, false); 318 callback.Run(base::PLATFORM_FILE_OK, entries, false);
296 } 319 }
297 320
298 } // namespace gdata 321 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system_proxy.h ('k') | chrome/browser/chromeos/gdata/gdata_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698