| 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 "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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 | 512 |
| 513 void GDataDownloadObserver::MoveFileToGDataCache(DownloadItem* download) { | 513 void GDataDownloadObserver::MoveFileToGDataCache(DownloadItem* download) { |
| 514 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 514 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 515 | 515 |
| 516 UploadingExternalData* data = GetUploadingExternalData(download); | 516 UploadingExternalData* data = GetUploadingExternalData(download); |
| 517 if (!data) { | 517 if (!data) { |
| 518 NOTREACHED(); | 518 NOTREACHED(); |
| 519 return; | 519 return; |
| 520 } | 520 } |
| 521 | 521 |
| 522 // Take ownership of the DocumentEntry object. It will be released upon | 522 // Pass ownership of the DocumentEntry object to AddUploadedFile(). |
| 523 // completion of the AddUploadedFile() call below. | 523 scoped_ptr<DocumentEntry> entry = data->entry_passed(); |
| 524 DocumentEntry* entry = data->entry_passed().release(); | 524 if (!entry.get()) { |
| 525 if (!entry) { | |
| 526 NOTREACHED(); | 525 NOTREACHED(); |
| 527 return; | 526 return; |
| 528 } | 527 } |
| 529 | 528 |
| 530 // Move downloaded file to gdata cache. Note that |content_file_path| should | 529 // Move downloaded file to gdata cache. Note that |content_file_path| should |
| 531 // use the final target path when the download item is in COMPLETE state. | 530 // use the final target path when the download item is in COMPLETE state. |
| 532 file_system_->AddUploadedFile(UPLOAD_NEW_FILE, | 531 file_system_->AddUploadedFile(UPLOAD_NEW_FILE, |
| 533 data->virtual_dir_path(), | 532 data->virtual_dir_path(), |
| 534 entry, | 533 entry.Pass(), |
| 535 download->GetTargetFilePath(), | 534 download->GetTargetFilePath(), |
| 536 GDataCache::FILE_OPERATION_MOVE, | 535 GDataCache::FILE_OPERATION_MOVE, |
| 537 base::Bind(&base::DeletePointer<DocumentEntry>, | 536 base::Bind(&base::DoNothing)); |
| 538 entry)); | |
| 539 } | 537 } |
| 540 | 538 |
| 541 } // namespace gdata | 539 } // namespace gdata |
| OLD | NEW |