| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "content/browser/download/download_resource_handler.h" | 5 #include "content/browser/download/download_resource_handler.h" | 
| 6 | 6 | 
| 7 #include <string> | 7 #include <string> | 
| 8 | 8 | 
| 9 #include "base/bind.h" | 9 #include "base/bind.h" | 
| 10 #include "base/logging.h" | 10 #include "base/logging.h" | 
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 121       on_response_started_called_(false) { | 121       on_response_started_called_(false) { | 
| 122   RecordDownloadCount(UNTHROTTLED_COUNT); | 122   RecordDownloadCount(UNTHROTTLED_COUNT); | 
| 123 | 123 | 
| 124   // Do UI thread initialization for tab_info_ asap after | 124   // Do UI thread initialization for tab_info_ asap after | 
| 125   // DownloadResourceHandler creation since the tab could be navigated | 125   // DownloadResourceHandler creation since the tab could be navigated | 
| 126   // before StartOnUIThread gets called.  This is safe because deletion | 126   // before StartOnUIThread gets called.  This is safe because deletion | 
| 127   // will occur via PostTask() as well, which will serialized behind this | 127   // will occur via PostTask() as well, which will serialized behind this | 
| 128   // PostTask() | 128   // PostTask() | 
| 129   const ResourceRequestInfoImpl* request_info = GetRequestInfo(); | 129   const ResourceRequestInfoImpl* request_info = GetRequestInfo(); | 
| 130   BrowserThread::PostTask( | 130   BrowserThread::PostTask( | 
| 131       BrowserThread::UI, | 131       BrowserThread::UI, FROM_HERE, | 
| 132       FROM_HERE, |  | 
| 133       base::Bind(&InitializeDownloadTabInfoOnUIThread, | 132       base::Bind(&InitializeDownloadTabInfoOnUIThread, | 
| 134                  DownloadRequestHandle(AsWeakPtr(), | 133                  DownloadRequestHandle(AsWeakPtr(), request_info->GetChildID(), | 
| 135                                        request_info->GetChildID(), |  | 
| 136                                        request_info->GetRouteID(), | 134                                        request_info->GetRouteID(), | 
| 137                                        request_info->GetRequestID()), | 135                                        request_info->GetRequestID(), | 
|  | 136                                        request_info->frame_tree_node_id()), | 
| 138                  tab_info_.get())); | 137                  tab_info_.get())); | 
| 139   power_save_blocker_ = PowerSaveBlocker::Create( | 138   power_save_blocker_ = PowerSaveBlocker::Create( | 
| 140       PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, | 139       PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, | 
| 141       PowerSaveBlocker::kReasonOther, "Download in progress"); | 140       PowerSaveBlocker::kReasonOther, "Download in progress"); | 
| 142 } | 141 } | 
| 143 | 142 | 
| 144 bool DownloadResourceHandler::OnUploadProgress(uint64 position, | 143 bool DownloadResourceHandler::OnUploadProgress(uint64 position, | 
| 145                                                uint64 size) { | 144                                                uint64 size) { | 
| 146   return true; | 145   return true; | 
| 147 } | 146 } | 
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 201   info->download_id = download_id_; | 200   info->download_id = download_id_; | 
| 202   info->url_chain = request()->url_chain(); | 201   info->url_chain = request()->url_chain(); | 
| 203   info->referrer_url = GURL(request()->referrer()); | 202   info->referrer_url = GURL(request()->referrer()); | 
| 204   info->mime_type = response->head.mime_type; | 203   info->mime_type = response->head.mime_type; | 
| 205   info->remote_address = request()->GetSocketAddress().host(); | 204   info->remote_address = request()->GetSocketAddress().host(); | 
| 206   request()->GetResponseHeaderByName("content-disposition", | 205   request()->GetResponseHeaderByName("content-disposition", | 
| 207                                      &info->content_disposition); | 206                                      &info->content_disposition); | 
| 208   RecordDownloadMimeType(info->mime_type); | 207   RecordDownloadMimeType(info->mime_type); | 
| 209   RecordDownloadContentDisposition(info->content_disposition); | 208   RecordDownloadContentDisposition(info->content_disposition); | 
| 210 | 209 | 
| 211   info->request_handle = | 210   info->request_handle = DownloadRequestHandle( | 
| 212       DownloadRequestHandle(AsWeakPtr(), request_info->GetChildID(), | 211       AsWeakPtr(), request_info->GetChildID(), request_info->GetRouteID(), | 
| 213                             request_info->GetRouteID(), | 212       request_info->GetRequestID(), request_info->frame_tree_node_id()); | 
| 214                             request_info->GetRequestID()); |  | 
| 215 | 213 | 
| 216   // Get the last modified time and etag. | 214   // Get the last modified time and etag. | 
| 217   const net::HttpResponseHeaders* headers = request()->response_headers(); | 215   const net::HttpResponseHeaders* headers = request()->response_headers(); | 
| 218   if (headers) { | 216   if (headers) { | 
| 219     if (headers->HasStrongValidators()) { | 217     if (headers->HasStrongValidators()) { | 
| 220       // If we don't have strong validators as per RFC 2616 section 13.3.3, then | 218       // If we don't have strong validators as per RFC 2616 section 13.3.3, then | 
| 221       // we neither store nor use them for range requests. | 219       // we neither store nor use them for range requests. | 
| 222       if (!headers->EnumerateHeader(NULL, "Last-Modified", | 220       if (!headers->EnumerateHeader(NULL, "Last-Modified", | 
| 223                                     &info->last_modified)) | 221                                     &info->last_modified)) | 
| 224         info->last_modified.clear(); | 222         info->last_modified.clear(); | 
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 538     BrowserThread::PostTask( | 536     BrowserThread::PostTask( | 
| 539         BrowserThread::UI, FROM_HERE, | 537         BrowserThread::UI, FROM_HERE, | 
| 540         base::Bind(&DeleteOnUIThread, base::Passed(&tab_info_))); | 538         base::Bind(&DeleteOnUIThread, base::Passed(&tab_info_))); | 
| 541   } | 539   } | 
| 542 | 540 | 
| 543   UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", | 541   UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", | 
| 544                       base::TimeTicks::Now() - download_start_time_); | 542                       base::TimeTicks::Now() - download_start_time_); | 
| 545 } | 543 } | 
| 546 | 544 | 
| 547 }  // namespace content | 545 }  // namespace content | 
| OLD | NEW | 
|---|