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

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

Issue 10815008: gdata: Make GDataFileSystem::ReadDirectoryByPath() much more efficient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove a blank line Created 8 years, 5 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_download_observer.h" 5 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "chrome/browser/chromeos/gdata/gdata.pb.h" 9 #include "chrome/browser/chromeos/gdata/gdata.pb.h"
10 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" 10 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h"
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 upload_file_info->all_bytes_present = download->AllDataSaved(); 466 upload_file_info->all_bytes_present = download->AllDataSaved();
467 467
468 upload_file_info->completion_callback = 468 upload_file_info->completion_callback =
469 base::Bind(&GDataDownloadObserver::OnUploadComplete, 469 base::Bind(&GDataDownloadObserver::OnUploadComplete,
470 weak_ptr_factory_.GetWeakPtr(), 470 weak_ptr_factory_.GetWeakPtr(),
471 download->GetId()); 471 download->GetId());
472 472
473 // Get the GDataDirectory proto for the upload directory, then extract the 473 // Get the GDataDirectory proto for the upload directory, then extract the
474 // initial upload URL in OnReadDirectoryByPath(). 474 // initial upload URL in OnReadDirectoryByPath().
475 const FilePath upload_dir = upload_file_info->gdata_path.DirName(); 475 const FilePath upload_dir = upload_file_info->gdata_path.DirName();
476 file_system_->ReadDirectoryByPath( 476 file_system_->GetEntryInfoByPath(
477 upload_dir, 477 upload_dir,
478 base::Bind(&GDataDownloadObserver::OnReadDirectoryByPath, 478 base::Bind(&GDataDownloadObserver::OnGetEntryInfoByPath,
479 weak_ptr_factory_.GetWeakPtr(), 479 weak_ptr_factory_.GetWeakPtr(),
480 download->GetId(), 480 download->GetId(),
481 base::Passed(&upload_file_info))); 481 base::Passed(&upload_file_info)));
482 } 482 }
483 483
484 void GDataDownloadObserver::OnReadDirectoryByPath( 484 void GDataDownloadObserver::OnGetEntryInfoByPath(
485 int32 download_id, 485 int32 download_id,
486 scoped_ptr<UploadFileInfo> upload_file_info, 486 scoped_ptr<UploadFileInfo> upload_file_info,
487 GDataFileError error, 487 GDataFileError error,
488 bool /* hide_hosted_documents */, 488 scoped_ptr<GDataEntryProto> entry_proto) {
489 scoped_ptr<GDataDirectoryProto> dir_proto) {
490 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 489 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
491 DCHECK(upload_file_info.get()); 490 DCHECK(upload_file_info.get());
492 491
493 // TODO(hshi): if the upload directory is no longer valid, use the root 492 // TODO(hshi): if the upload directory is no longer valid, use the root
494 // directory instead. 493 // directory instead.
495 upload_file_info->initial_upload_location = 494 upload_file_info->initial_upload_location =
496 dir_proto.get() ? GURL(dir_proto->gdata_entry().upload_url()) : GURL(); 495 entry_proto.get() ? GURL(entry_proto->upload_url()) : GURL();
497 496
498 StartUpload(download_id, upload_file_info.Pass()); 497 StartUpload(download_id, upload_file_info.Pass());
499 } 498 }
500 499
501 void GDataDownloadObserver::StartUpload( 500 void GDataDownloadObserver::StartUpload(
502 int32 download_id, 501 int32 download_id,
503 scoped_ptr<UploadFileInfo> upload_file_info) { 502 scoped_ptr<UploadFileInfo> upload_file_info) {
504 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 503 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
505 DCHECK(upload_file_info.get()); 504 DCHECK(upload_file_info.get());
506 505
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 // use the final target path when the download item is in COMPLETE state. 570 // use the final target path when the download item is in COMPLETE state.
572 file_system_->AddUploadedFile(UPLOAD_NEW_FILE, 571 file_system_->AddUploadedFile(UPLOAD_NEW_FILE,
573 upload_data->virtual_dir_path(), 572 upload_data->virtual_dir_path(),
574 entry.Pass(), 573 entry.Pass(),
575 download->GetTargetFilePath(), 574 download->GetTargetFilePath(),
576 GDataCache::FILE_OPERATION_MOVE, 575 GDataCache::FILE_OPERATION_MOVE,
577 base::Bind(&base::DoNothing)); 576 base::Bind(&base::DoNothing));
578 } 577 }
579 578
580 } // namespace gdata 579 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698