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 d892388f609154fc306b555b959c284e1a0b3004..306b9a67341d73cfdbbe76f27549fae0ba62ecd0 100644 |
--- a/chrome/browser/automation/testing_automation_provider.cc |
+++ b/chrome/browser/automation/testing_automation_provider.cc |
@@ -2942,10 +2942,18 @@ void TestingAutomationProvider::WaitForDownloadsToComplete( |
new AutomationProviderDownloadItemObserver( |
this, reply_message, downloads.size()); |
for (std::vector<DownloadItem*>::iterator i = downloads.begin(); |
- i != downloads.end(); |
- i++) { |
+ i != downloads.end(); ++i) { |
(*i)->AddObserver(item_observer); |
} |
+ // It's possible that pending downloads may have completed before the observer |
Paweł Hajdan Jr.
2011/08/01 22:42:10
Seems hacky. How about starting the new download o
Nirnimesh
2011/08/01 22:49:24
In a perfect world, yes. But the flakes in the dow
dennis_jeffrey
2011/08/02 00:04:53
The suggested approach works well in the case wher
Paweł Hajdan Jr.
2011/08/02 16:53:23
Please show me the bugs and I can fix them. Let's
Paweł Hajdan Jr.
2011/08/02 16:53:23
This is a known problem with pyauto. I see the fol
|
+ // above has been completely set up. Handle this case by checking again and |
+ // returning if there are no pending downloads. |
+ browser->profile()->GetDownloadManager()-> |
+ GetCurrentDownloads(FilePath(), &downloads); |
+ if (downloads.empty()) { |
+ delete item_observer; |
+ AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
+ } |
} |
namespace { |