| 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/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" |
| 11 #include "base/supports_user_data.h" | 11 #include "base/supports_user_data.h" |
| 12 #include "chrome/browser/chromeos/gdata/drive.pb.h" |
| 12 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" | 13 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" |
| 13 #include "chrome/browser/chromeos/gdata/gdata.pb.h" | |
| 14 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" | 14 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" |
| 15 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | 15 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
| 16 #include "chrome/browser/chromeos/gdata/gdata_upload_file_info.h" | 16 #include "chrome/browser/chromeos/gdata/gdata_upload_file_info.h" |
| 17 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" | 17 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" |
| 18 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 18 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
| 19 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" | 19 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" |
| 20 #include "chrome/browser/download/download_completion_blocker.h" | 20 #include "chrome/browser/download/download_completion_blocker.h" |
| 21 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
| 22 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
| 23 | 23 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 GDataFileError error, |
| 153 scoped_ptr<GDataEntryProto> entry_proto) { | 153 scoped_ptr<DriveEntryProto> entry_proto) { |
| 154 if (error == GDATA_FILE_ERROR_NOT_FOUND) { | 154 if (error == GDATA_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 == GDATA_FILE_OK) { |
| 161 substitute_callback.Run(); | 161 substitute_callback.Run(); |
| 162 } else { | 162 } else { |
| 163 // TODO(achuith): Handle this. | 163 // TODO(achuith): Handle this. |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 GDataFileError error, |
| 509 scoped_ptr<GDataEntryProto> 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; |
| 519 } | 519 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 GDataFileError error, |
| 563 scoped_ptr<GDataEntryProto> 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 { |
| 573 upload_file_info->initial_upload_location = GURL(); | 573 upload_file_info->initial_upload_location = GURL(); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 GDataCache::FILE_OPERATION_MOVE, | 669 GDataCache::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 |
| OLD | NEW |