| 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 "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" | 5 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 io_data->resource_prefetch_predictor_observer()->OnRequestStarted( | 471 io_data->resource_prefetch_predictor_observer()->OnRequestStarted( |
| 472 request, resource_type, info->GetChildID(), info->GetRenderFrameID()); | 472 request, resource_type, info->GetChildID(), info->GetRenderFrameID()); |
| 473 } | 473 } |
| 474 } | 474 } |
| 475 | 475 |
| 476 void ChromeResourceDispatcherHostDelegate::DownloadStarting( | 476 void ChromeResourceDispatcherHostDelegate::DownloadStarting( |
| 477 net::URLRequest* request, | 477 net::URLRequest* request, |
| 478 content::ResourceContext* resource_context, | 478 content::ResourceContext* resource_context, |
| 479 int child_id, | 479 int child_id, |
| 480 int route_id, | 480 int route_id, |
| 481 int request_id, | |
| 482 bool is_content_initiated, | 481 bool is_content_initiated, |
| 483 bool must_download, | 482 bool must_download, |
| 484 ScopedVector<content::ResourceThrottle>* throttles) { | 483 ScopedVector<content::ResourceThrottle>* throttles) { |
| 485 BrowserThread::PostTask( | 484 BrowserThread::PostTask( |
| 486 BrowserThread::UI, FROM_HERE, | 485 BrowserThread::UI, FROM_HERE, |
| 487 base::Bind(&NotifyDownloadInitiatedOnUI, child_id, route_id)); | 486 base::Bind(&NotifyDownloadInitiatedOnUI, child_id, route_id)); |
| 488 | 487 |
| 489 // If it's from the web, we don't trust it, so we push the throttle on. | 488 // If it's from the web, we don't trust it, so we push the throttle on. |
| 490 if (is_content_initiated) { | 489 if (is_content_initiated) { |
| 491 const content::ResourceRequestInfo* info = | 490 const content::ResourceRequestInfo* info = |
| 492 content::ResourceRequestInfo::ForRequest(request); | 491 content::ResourceRequestInfo::ForRequest(request); |
| 493 throttles->push_back(new DownloadResourceThrottle( | 492 throttles->push_back(new DownloadResourceThrottle( |
| 494 download_request_limiter_, info->GetWebContentsGetterForRequest(), | 493 download_request_limiter_, info->GetWebContentsGetterForRequest(), |
| 495 request->url(), request->method())); | 494 request->url(), request->method())); |
| 496 #if BUILDFLAG(ANDROID_JAVA_UI) | 495 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 497 throttles->push_back( | 496 throttles->push_back( |
| 498 new chrome::InterceptDownloadResourceThrottle( | 497 new chrome::InterceptDownloadResourceThrottle( |
| 499 request, child_id, route_id, request_id, must_download)); | 498 request, child_id, route_id, must_download)); |
| 500 #endif | 499 #endif |
| 501 } | 500 } |
| 502 | 501 |
| 503 // If this isn't a new request, we've seen this before and added the standard | 502 // If this isn't a new request, we've seen this before and added the standard |
| 504 // resource throttles already so no need to add it again. | 503 // resource throttles already so no need to add it again. |
| 505 if (!request->is_pending()) { | 504 if (!request->is_pending()) { |
| 506 AppendStandardResourceThrottles(request, | 505 AppendStandardResourceThrottles(request, |
| 507 resource_context, | 506 resource_context, |
| 508 content::RESOURCE_TYPE_MAIN_FRAME, | 507 content::RESOURCE_TYPE_MAIN_FRAME, |
| 509 throttles); | 508 throttles); |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 data_reduction_proxy::DataReductionProxyData* data_reduction_proxy_data = | 841 data_reduction_proxy::DataReductionProxyData* data_reduction_proxy_data = |
| 843 data_reduction_proxy::DataReductionProxyData::GetData(*request); | 842 data_reduction_proxy::DataReductionProxyData::GetData(*request); |
| 844 // DeepCopy the DataReductionProxyData from the URLRequest to prevent the | 843 // DeepCopy the DataReductionProxyData from the URLRequest to prevent the |
| 845 // URLRequest and DataReductionProxyData from both having ownership of the | 844 // URLRequest and DataReductionProxyData from both having ownership of the |
| 846 // same object. This copy will be shortlived as it will be deep copied again | 845 // same object. This copy will be shortlived as it will be deep copied again |
| 847 // when content makes a clone of NavigationData for the UI thread. | 846 // when content makes a clone of NavigationData for the UI thread. |
| 848 if (data_reduction_proxy_data) | 847 if (data_reduction_proxy_data) |
| 849 data->SetDataReductionProxyData(data_reduction_proxy_data->DeepCopy()); | 848 data->SetDataReductionProxyData(data_reduction_proxy_data->DeepCopy()); |
| 850 return data; | 849 return data; |
| 851 } | 850 } |
| OLD | NEW |