Index: content/browser/download/download_resource_handler.cc |
diff --git a/content/browser/download/download_resource_handler.cc b/content/browser/download/download_resource_handler.cc |
index 05d22a8ee73cfe46f093aa7503646ed3a2bb6f98..a224b325f8891bb567774fac15eb05601e71a3d6 100644 |
--- a/content/browser/download/download_resource_handler.cc |
+++ b/content/browser/download/download_resource_handler.cc |
@@ -106,19 +106,6 @@ DownloadResourceHandler::DownloadResourceHandler(net::URLRequest* request) |
: ResourceHandler(request), |
tab_info_(new DownloadTabInfo()), |
core_(request, this) { |
- // Do UI thread initialization for tab_info_ asap after |
- // DownloadResourceHandler creation since the tab could be navigated |
- // before StartOnUIThread gets called. This is safe because deletion |
- // will occur via PostTask() as well, which will serialized behind this |
- // PostTask() |
- const ResourceRequestInfoImpl* request_info = GetRequestInfo(); |
- BrowserThread::PostTask( |
- BrowserThread::UI, FROM_HERE, |
- base::Bind( |
- &InitializeDownloadTabInfoOnUIThread, |
- DownloadRequestHandle(AsWeakPtr(), |
- request_info->GetWebContentsGetterForRequest()), |
- tab_info_.get())); |
} |
DownloadResourceHandler::~DownloadResourceHandler() { |
@@ -197,6 +184,20 @@ void DownloadResourceHandler::OnStart( |
} |
const ResourceRequestInfoImpl* request_info = GetRequestInfo(); |
+ // Post the task (InitializeDownloadTabInfoOnUIThread) to initialize the |
+ // tab_info_ structure on the UI thread before posting the StartOnUIThread() |
+ // task. The tab could be navigated away before either of these tasks run, |
+ // which is safe because the deletion of the tab_info_ structure also occurs |
+ // on the UI thread via PostTask() which will be serialized behind these |
+ // tasks. |
Randy Smith (Not in Mondays)
2016/08/21 23:32:57
I'm sorry, I don't understand what drove moving th
ananta
2016/08/22 19:14:57
The ResourceRequestInfoImpl instance which is asso
Randy Smith (Not in Mondays)
2016/08/23 19:54:45
So the code is squirrelly, so I may be mistaken, b
|
+ BrowserThread::PostTask( |
+ BrowserThread::UI, FROM_HERE, |
+ base::Bind( |
+ &InitializeDownloadTabInfoOnUIThread, |
+ DownloadRequestHandle( |
+ AsWeakPtr(), request_info->GetWebContentsGetterForRequest()), |
+ tab_info_.get())); |
+ |
create_info->has_user_gesture = request_info->HasUserGesture(); |
create_info->transition_type = request_info->GetPageTransition(); |