Index: chrome/browser/automation/testing_automation_provider.cc |
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc |
index 274ba4d52d186330f9839e063edca783fe18b7ba..354a5607c491fafce05b331fed23dd0ee71b5d0b 100644 |
--- a/chrome/browser/automation/testing_automation_provider.cc |
+++ b/chrome/browser/automation/testing_automation_provider.cc |
@@ -2332,7 +2332,7 @@ void TestingAutomationProvider::SendJSONRequest(int handle, |
browser_handler_map["GetDownloadsInfo"] = |
&TestingAutomationProvider::GetDownloadsInfo; |
browser_handler_map["WaitForAllDownloadsToComplete"] = |
- &TestingAutomationProvider::WaitForDownloadsToComplete; |
+ &TestingAutomationProvider::WaitForAllDownloadsToComplete; |
browser_handler_map["PerformActionOnDownload"] = |
&TestingAutomationProvider::PerformActionOnDownload; |
@@ -2938,34 +2938,27 @@ void TestingAutomationProvider::GetDownloadsInfo(Browser* browser, |
reply.SendSuccess(return_value.get()); |
} |
-void TestingAutomationProvider::WaitForDownloadsToComplete( |
+void TestingAutomationProvider::WaitForAllDownloadsToComplete( |
Browser* browser, |
DictionaryValue* args, |
IPC::Message* reply_message) { |
+ ListValue* pre_download_ids = NULL; |
- // Look for a quick return. |
- if (!browser->profile()->HasCreatedDownloadManager()) { |
- // No download manager. |
- AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
+ if (!args->GetList("pre_download_ids", &pre_download_ids)) { |
+ AutomationJSONReply(this, reply_message) |
+ .SendError(StringPrintf("List of IDs of previous downloads required.")); |
return; |
} |
- std::vector<DownloadItem*> downloads; |
- browser->profile()->GetDownloadManager()-> |
- GetCurrentDownloads(FilePath(), &downloads); |
- if (downloads.empty()) { |
+ if (!browser->profile()->HasCreatedDownloadManager()) { |
+ // No download manager, so no downloads to wait for. |
AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
return; |
} |
- // The observer owns itself. When the last observed item pings, it |
- // deletes itself. |
- AutomationProviderDownloadItemObserver* item_observer = |
- new AutomationProviderDownloadItemObserver( |
- this, reply_message, downloads.size()); |
- for (std::vector<DownloadItem*>::iterator i = downloads.begin(); |
- i != downloads.end(); |
- i++) { |
- (*i)->AddObserver(item_observer); |
- } |
+ |
+ // This observer will delete itself. |
+ new AllDownloadsCompleteObserver( |
+ this, reply_message, browser->profile()->GetDownloadManager(), |
+ pre_download_ids); |
} |
namespace { |