Commit f674bb5d authored by Sebastien Seguin-Gagnon's avatar Sebastien Seguin-Gagnon Committed by Commit Bot

Revert "Fix DownloadManagerTestCase flakiness."

This reverts commit eabc228b.

Reason for revert: May have caused a compile error that closed the tree: https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/ios-webview/2197

Original change's description:
> Fix DownloadManagerTestCase flakiness.
> 
> On iOS 12 URLSession:dataTask:didReceiveData: delegate method can be
> called when task is in NSURLSessionTaskStateCompleted state. This
> resulted in extra URLFetcherResponseWriter::Finish call (one from
> didReceiveData: and one from didCompleteWithError:).
> URLFetcherResponseWriter::Finish DCHECKs if Finish is called twice, so
> the test was flaky.
> 
> This CL changes DownloadTaskImpl to only call
> URLFetcherResponseWriter::Finish from didCompleteWithError:.
> 
> Bug: 873204
> Change-Id: Ie6b8757e2c5c5d35da088fd108d92ee3ed13244d
> Reviewed-on: https://chromium-review.googlesource.com/c/1354233
> Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
> Commit-Queue: Eugene But <eugenebut@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#612249}

TBR=sdefresne@chromium.org,eugenebut@chromium.org

Change-Id: I1f7e7620911c73ce1f497fb6ae7b09ed16a2547f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 873204
Reviewed-on: https://chromium-review.googlesource.com/c/1355600Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Commit-Queue: Sebastien Seguin-Gagnon <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612251}
parent 6ba57378
...@@ -33,11 +33,8 @@ using web::WebThread; ...@@ -33,11 +33,8 @@ using web::WebThread;
namespace { namespace {
// Updates DownloadTaskImpl properties. |terminal_callback| is true if this is // Updates DownloadTaskImpl properties.
// the last update for this DownloadTaskImpl. using PropertiesBlock = void (^)(NSURLSessionTask*, NSError*);
using PropertiesBlock = void (^)(NSURLSessionTask*,
NSError*,
bool terminal_callback);
// Writes buffer and calls |completionHandler| when done. // Writes buffer and calls |completionHandler| when done.
using DataBlock = void (^)(scoped_refptr<net::IOBufferWithSize> buffer, using DataBlock = void (^)(scoped_refptr<net::IOBufferWithSize> buffer,
void (^completionHandler)()); void (^completionHandler)());
...@@ -117,8 +114,7 @@ int GetTaskPercentComplete(NSURLSessionTask* task) { ...@@ -117,8 +114,7 @@ int GetTaskPercentComplete(NSURLSessionTask* task) {
base::PostTaskWithTraits(FROM_HERE, {WebThread::UI}, base::BindOnce(^{ base::PostTaskWithTraits(FROM_HERE, {WebThread::UI}, base::BindOnce(^{
CRWURLSessionDelegate* strongSelf = weakSelf; CRWURLSessionDelegate* strongSelf = weakSelf;
if (strongSelf.propertiesBlock) if (strongSelf.propertiesBlock)
strongSelf.propertiesBlock( strongSelf.propertiesBlock(task, error);
task, error, /*terminal_callback=*/true);
})); }));
} }
...@@ -148,8 +144,7 @@ int GetTaskPercentComplete(NSURLSessionTask* task) { ...@@ -148,8 +144,7 @@ int GetTaskPercentComplete(NSURLSessionTask* task) {
base::PostTaskWithTraits(FROM_HERE, {WebThread::UI}, base::BindOnce(^{ base::PostTaskWithTraits(FROM_HERE, {WebThread::UI}, base::BindOnce(^{
CRWURLSessionDelegate* strongSelf = weakSelf; CRWURLSessionDelegate* strongSelf = weakSelf;
if (strongSelf.propertiesBlock) if (strongSelf.propertiesBlock)
weakSelf.propertiesBlock( weakSelf.propertiesBlock(task, nil);
task, nil, /*terminal_callback=*/false);
})); }));
} }
...@@ -343,8 +338,7 @@ NSURLSession* DownloadTaskImpl::CreateSession(NSString* identifier) { ...@@ -343,8 +338,7 @@ NSURLSession* DownloadTaskImpl::CreateSession(NSString* identifier) {
DCHECK(identifier.length); DCHECK(identifier.length);
base::WeakPtr<DownloadTaskImpl> weak_this = weak_factory_.GetWeakPtr(); base::WeakPtr<DownloadTaskImpl> weak_this = weak_factory_.GetWeakPtr();
id<NSURLSessionDataDelegate> session_delegate = [[CRWURLSessionDelegate alloc] id<NSURLSessionDataDelegate> session_delegate = [[CRWURLSessionDelegate alloc]
initWithPropertiesBlock:^(NSURLSessionTask* task, NSError* error, initWithPropertiesBlock:^(NSURLSessionTask* task, NSError* error) {
BOOL terminal_callback) {
if (!weak_this.get()) { if (!weak_this.get()) {
return; return;
} }
...@@ -367,7 +361,7 @@ NSURLSession* DownloadTaskImpl::CreateSession(NSString* identifier) { ...@@ -367,7 +361,7 @@ NSURLSession* DownloadTaskImpl::CreateSession(NSString* identifier) {
static_cast<NSHTTPURLResponse*>(task.response).statusCode; static_cast<NSHTTPURLResponse*>(task.response).statusCode;
} }
if (!terminal_callback) { if (task.state != NSURLSessionTaskStateCompleted) {
OnDownloadUpdated(); OnDownloadUpdated();
// Download is still in progress, nothing to do here. // Download is still in progress, nothing to do here.
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment