Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 7544026: Fix for flakiness in pyauto automation hook WaitForDownloadsToComplete. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with trunk; awaiting green trybots. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.h ('k') | chrome/test/functional/downloads.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.h ('k') | chrome/test/functional/downloads.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698