Index: chrome/browser/chromeos/gdata/gdata_download_observer.cc |
diff --git a/chrome/browser/chromeos/gdata/gdata_download_observer.cc b/chrome/browser/chromeos/gdata/gdata_download_observer.cc |
index d3989fdf569d4a26dbebf7a144cbd4790f55cafb..61ab9d96507e96d6a56ea390c747893916a280b3 100644 |
--- a/chrome/browser/chromeos/gdata/gdata_download_observer.cc |
+++ b/chrome/browser/chromeos/gdata/gdata_download_observer.cc |
@@ -169,8 +169,11 @@ void OnAuthenticate(Profile* profile, |
} // namespace |
-GDataDownloadObserver::GDataDownloadObserver() |
- : gdata_uploader_(NULL), |
+GDataDownloadObserver::GDataDownloadObserver( |
+ GDataUploader* uploader, |
+ GDataFileSystem* file_system) |
+ : gdata_uploader_(uploader), |
+ file_system_(file_system), |
download_manager_(NULL), |
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
} |
@@ -186,12 +189,9 @@ GDataDownloadObserver::~GDataDownloadObserver() { |
} |
void GDataDownloadObserver::Initialize( |
- GDataUploader* gdata_uploader, |
DownloadManager* download_manager, |
const FilePath& gdata_tmp_download_path) { |
- DCHECK(gdata_uploader); |
DCHECK(!gdata_tmp_download_path.empty()); |
- gdata_uploader_ = gdata_uploader; |
download_manager_ = download_manager; |
if (download_manager_) |
download_manager_->AddObserver(this); |
@@ -474,6 +474,22 @@ void GDataDownloadObserver::OnUploadComplete( |
base::PlatformFileError error, |
scoped_ptr<UploadFileInfo> upload_file_info) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ DCHECK(upload_file_info.get()); |
+ |
+ if (error == base::PLATFORM_FILE_OK && upload_file_info->entry.get()) { |
+ // Save a local copy of the UploadFileInfo pointer. Depending on order of |
+ // argument evaluation, scoped_ptr<T>::release() may invalidate the scoped |
+ // pointer before it can be dereferenced to access its members. |
+ const UploadFileInfo* upload_file_info_ptr = upload_file_info.get(); |
+ file_system_->AddUploadedFile(UPLOAD_NEW_FILE, |
+ upload_file_info_ptr->gdata_path.DirName(), |
satorux1
2012/07/09 22:08:16
nit: indentation is off? please align parameters v
hshi1
2012/07/09 22:11:49
Done.
|
+ upload_file_info_ptr->entry.get(), |
+ upload_file_info_ptr->file_path, |
+ GDataCache::FILE_OPERATION_COPY, |
+ base::Bind(&base::DeletePointer<UploadFileInfo>, |
+ upload_file_info.release())); |
+ } |
+ |
DownloadMap::iterator iter = pending_downloads_.find(download_id); |
if (iter == pending_downloads_.end()) { |
DVLOG(1) << "Pending download not found" << download_id; |