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

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

Issue 10877006: Rename GDataErrorCode to DriveErrorCode, GDataFileError to DriveFileError (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor local variable name fix. Created 8 years, 4 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 <string> 7 #include <string>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 base::Bind(&GDataDownloadObserver::GetGDataTempDownloadPath, 128 base::Bind(&GDataDownloadObserver::GetGDataTempDownloadPath,
129 gdata_tmp_download_dir, 129 gdata_tmp_download_dir,
130 gdata_tmp_download_path), 130 gdata_tmp_download_path),
131 base::Bind(&RunSubstituteGDataDownloadCallback, 131 base::Bind(&RunSubstituteGDataDownloadCallback,
132 callback, 132 callback,
133 base::Owned(gdata_tmp_download_path))); 133 base::Owned(gdata_tmp_download_path)));
134 } 134 }
135 135
136 // Callback for GDataFileSystem::CreateDirectory. 136 // Callback for GDataFileSystem::CreateDirectory.
137 void OnCreateDirectory(const base::Closure& substitute_callback, 137 void OnCreateDirectory(const base::Closure& substitute_callback,
138 GDataFileError error) { 138 DriveFileError error) {
139 DVLOG(1) << "OnCreateDirectory " << error; 139 DVLOG(1) << "OnCreateDirectory " << error;
140 if (error == GDATA_FILE_OK) { 140 if (error == DRIVE_FILE_OK) {
141 substitute_callback.Run(); 141 substitute_callback.Run();
142 } else { 142 } else {
143 // TODO(achuith): Handle this. 143 // TODO(achuith): Handle this.
144 NOTREACHED(); 144 NOTREACHED();
145 } 145 }
146 } 146 }
147 147
148 // Callback for GDataFileSystem::GetEntryInfoByPath. 148 // Callback for GDataFileSystem::GetEntryInfoByPath.
149 void OnEntryFound(Profile* profile, 149 void OnEntryFound(Profile* profile,
150 const FilePath& gdata_dir_path, 150 const FilePath& gdata_dir_path,
151 const base::Closure& substitute_callback, 151 const base::Closure& substitute_callback,
152 GDataFileError error, 152 DriveFileError error,
153 scoped_ptr<DriveEntryProto> entry_proto) { 153 scoped_ptr<DriveEntryProto> entry_proto) {
154 if (error == GDATA_FILE_ERROR_NOT_FOUND) { 154 if (error == DRIVE_FILE_ERROR_NOT_FOUND) {
155 // Destination gdata directory doesn't exist, so create it. 155 // Destination gdata directory doesn't exist, so create it.
156 const bool is_exclusive = false, is_recursive = true; 156 const bool is_exclusive = false, is_recursive = true;
157 GetSystemService(profile)->file_system()->CreateDirectory( 157 GetSystemService(profile)->file_system()->CreateDirectory(
158 gdata_dir_path, is_exclusive, is_recursive, 158 gdata_dir_path, is_exclusive, is_recursive,
159 base::Bind(&OnCreateDirectory, substitute_callback)); 159 base::Bind(&OnCreateDirectory, substitute_callback));
160 } else if (error == GDATA_FILE_OK) { 160 } else if (error == DRIVE_FILE_OK) {
161 substitute_callback.Run(); 161 substitute_callback.Run();
162 } else { 162 } else {
163 // TODO(achuith): Handle this. 163 // TODO(achuith): Handle this.
164 NOTREACHED(); 164 NOTREACHED();
165 } 165 }
166 } 166 }
167 167
168 // Callback for DriveServiceInterface::Authenticate. 168 // Callback for DriveServiceInterface::Authenticate.
169 void OnAuthenticate(Profile* profile, 169 void OnAuthenticate(Profile* profile,
170 const FilePath& gdata_path, 170 const FilePath& gdata_path,
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 base::Bind( 498 base::Bind(
499 &GDataDownloadObserver::CreateUploadFileInfoAfterCheckExistence, 499 &GDataDownloadObserver::CreateUploadFileInfoAfterCheckExistence,
500 weak_ptr_factory_.GetWeakPtr(), 500 weak_ptr_factory_.GetWeakPtr(),
501 download->GetId(), 501 download->GetId(),
502 base::Passed(&upload_file_info))); 502 base::Passed(&upload_file_info)));
503 } 503 }
504 504
505 void GDataDownloadObserver::CreateUploadFileInfoAfterCheckExistence( 505 void GDataDownloadObserver::CreateUploadFileInfoAfterCheckExistence(
506 int32 download_id, 506 int32 download_id,
507 scoped_ptr<UploadFileInfo> upload_file_info, 507 scoped_ptr<UploadFileInfo> upload_file_info,
508 GDataFileError error, 508 DriveFileError error,
509 scoped_ptr<DriveEntryProto> entry_proto) { 509 scoped_ptr<DriveEntryProto> entry_proto) {
510 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 510 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
511 DCHECK(upload_file_info.get()); 511 DCHECK(upload_file_info.get());
512 512
513 if (entry_proto.get()) { 513 if (entry_proto.get()) {
514 // Make sure this isn't a directory. 514 // Make sure this isn't a directory.
515 if (entry_proto->file_info().is_directory()) { 515 if (entry_proto->file_info().is_directory()) {
516 DVLOG(1) << "Filename conflicts with existing directory: " 516 DVLOG(1) << "Filename conflicts with existing directory: "
517 << upload_file_info->title; 517 << upload_file_info->title;
518 return; 518 return;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 &GDataDownloadObserver::CreateUploadFileInfoAfterCheckTargetDir, 552 &GDataDownloadObserver::CreateUploadFileInfoAfterCheckTargetDir,
553 weak_ptr_factory_.GetWeakPtr(), 553 weak_ptr_factory_.GetWeakPtr(),
554 download_id, 554 download_id,
555 base::Passed(&upload_file_info))); 555 base::Passed(&upload_file_info)));
556 } 556 }
557 } 557 }
558 558
559 void GDataDownloadObserver::CreateUploadFileInfoAfterCheckTargetDir( 559 void GDataDownloadObserver::CreateUploadFileInfoAfterCheckTargetDir(
560 int32 download_id, 560 int32 download_id,
561 scoped_ptr<UploadFileInfo> upload_file_info, 561 scoped_ptr<UploadFileInfo> upload_file_info,
562 GDataFileError error, 562 DriveFileError error,
563 scoped_ptr<DriveEntryProto> entry_proto) { 563 scoped_ptr<DriveEntryProto> entry_proto) {
564 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 564 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
565 DCHECK(upload_file_info.get()); 565 DCHECK(upload_file_info.get());
566 566
567 if (entry_proto.get()) { 567 if (entry_proto.get()) {
568 // TODO(hshi): if the upload directory is no longer valid, use the root 568 // TODO(hshi): if the upload directory is no longer valid, use the root
569 // directory instead. 569 // directory instead.
570 upload_file_info->initial_upload_location = 570 upload_file_info->initial_upload_location =
571 GURL(entry_proto->upload_url()); 571 GURL(entry_proto->upload_url());
572 } else { 572 } else {
(...skipping 29 matching lines...) Expand all
602 upload_data->set_upload_id(upload_id); 602 upload_data->set_upload_id(upload_id);
603 } else { 603 } else {
604 const int upload_id = 604 const int upload_id =
605 gdata_uploader_->UploadNewFile(upload_file_info.Pass()); 605 gdata_uploader_->UploadNewFile(upload_file_info.Pass());
606 upload_data->set_upload_id(upload_id); 606 upload_data->set_upload_id(upload_id);
607 } 607 }
608 } 608 }
609 609
610 void GDataDownloadObserver::OnUploadComplete( 610 void GDataDownloadObserver::OnUploadComplete(
611 int32 download_id, 611 int32 download_id,
612 GDataFileError error, 612 DriveFileError error,
613 scoped_ptr<UploadFileInfo> upload_file_info) { 613 scoped_ptr<UploadFileInfo> upload_file_info) {
614 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 614 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
615 DCHECK(upload_file_info.get()); 615 DCHECK(upload_file_info.get());
616 DCHECK(upload_file_info->entry.get()); 616 DCHECK(upload_file_info->entry.get());
617 617
618 // Look up the DownloadItem for the |download_id|. 618 // Look up the DownloadItem for the |download_id|.
619 DownloadMap::iterator iter = pending_downloads_.find(download_id); 619 DownloadMap::iterator iter = pending_downloads_.find(download_id);
620 if (iter == pending_downloads_.end()) { 620 if (iter == pending_downloads_.end()) {
621 DVLOG(1) << "Pending download not found" << download_id; 621 DVLOG(1) << "Pending download not found" << download_id;
622 return; 622 return;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 file_system_->AddUploadedFile(UPLOAD_NEW_FILE, 665 file_system_->AddUploadedFile(UPLOAD_NEW_FILE,
666 upload_data->virtual_dir_path(), 666 upload_data->virtual_dir_path(),
667 entry.Pass(), 667 entry.Pass(),
668 download->GetTargetFilePath(), 668 download->GetTargetFilePath(),
669 DriveCache::FILE_OPERATION_MOVE, 669 DriveCache::FILE_OPERATION_MOVE,
670 base::Bind(&base::DoNothing)); 670 base::Bind(&base::DoNothing));
671 } 671 }
672 } 672 }
673 673
674 } // namespace gdata 674 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_download_observer.h ('k') | chrome/browser/chromeos/gdata/gdata_errorcode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698