Index: chrome/browser/download/download_path_reservation_tracker.cc |
=================================================================== |
--- chrome/browser/download/download_path_reservation_tracker.cc (revision 275705) |
+++ chrome/browser/download/download_path_reservation_tracker.cc (working copy) |
@@ -147,15 +147,14 @@ |
// writeable. |
// - Truncates the suggested name if it exceeds the filesystem's limit. |
// - Uniquifies |suggested_path| if |should_uniquify_path| is true. |
-// - Schedules |callback| on the UI thread with the reserved path and a flag |
-// indicating whether the returned path has been successfully verified. |
-void CreateReservation( |
+// - Returns true if |reserved_path| has been successfully verified. |
+bool CreateReservation( |
ReservationKey key, |
const base::FilePath& suggested_path, |
const base::FilePath& default_download_path, |
bool create_directory, |
DownloadPathReservationTracker::FilenameConflictAction conflict_action, |
- const DownloadPathReservationTracker::ReservedPathCallback& callback) { |
+ base::FilePath* reserved_path) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
DCHECK(suggested_path.IsAbsolute()); |
@@ -243,8 +242,8 @@ |
reservations[key] = target_path; |
bool verified = (is_path_writeable && !has_conflicts && !name_too_long); |
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
- base::Bind(callback, target_path, verified)); |
+ *reserved_path = target_path; |
+ return verified; |
} |
// Called on the FILE thread to update the path of the reservation associated |
@@ -277,6 +276,14 @@ |
} |
} |
+void RunGetReservedPathCallback( |
+ const DownloadPathReservationTracker::ReservedPathCallback& callback, |
+ const base::FilePath* reserved_path, |
+ bool verified) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ callback.Run(*reserved_path, verified); |
+} |
+ |
DownloadItemObserver::DownloadItemObserver(DownloadItem* download_item) |
: download_item_(download_item), |
last_target_path_(download_item->GetTargetFilePath()) { |
@@ -349,14 +356,20 @@ |
new DownloadItemObserver(download_item); |
// DownloadItemObserver deletes itself. |
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind( |
- &CreateReservation, |
- download_item, |
- target_path, |
- default_path, |
- create_directory, |
- conflict_action, |
- callback)); |
+ base::FilePath* reserved_path = new base::FilePath; |
+ BrowserThread::PostTaskAndReplyWithResult( |
+ BrowserThread::FILE, |
+ FROM_HERE, |
+ base::Bind(&CreateReservation, |
+ download_item, |
+ target_path, |
+ default_path, |
+ create_directory, |
+ conflict_action, |
+ reserved_path), |
+ base::Bind(&RunGetReservedPathCallback, |
+ callback, |
+ base::Owned(reserved_path))); |
} |
// static |