| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/predictors/resource_prefetch_predictor_tab_helper.h" | 5 #include "chrome/browser/predictors/resource_prefetch_predictor_tab_helper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "chrome/browser/predictors/loading_predictor.h" | 9 #include "chrome/browser/predictors/loading_predictor.h" |
| 10 #include "chrome/browser/predictors/loading_predictor_factory.h" | 10 #include "chrome/browser/predictors/loading_predictor_factory.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 const GURL& url, | 43 const GURL& url, |
| 44 const std::string& mime_type, | 44 const std::string& mime_type, |
| 45 content::ResourceType resource_type) { | 45 content::ResourceType resource_type) { |
| 46 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 46 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 47 | 47 |
| 48 auto* loading_predictor = LoadingPredictorFactory::GetForProfile( | 48 auto* loading_predictor = LoadingPredictorFactory::GetForProfile( |
| 49 Profile::FromBrowserContext(web_contents()->GetBrowserContext())); | 49 Profile::FromBrowserContext(web_contents()->GetBrowserContext())); |
| 50 if (!loading_predictor) | 50 if (!loading_predictor) |
| 51 return; | 51 return; |
| 52 | 52 |
| 53 ResourcePrefetchPredictor::URLRequestSummary summary; | 53 URLRequestSummary summary; |
| 54 summary.navigation_id = NavigationID(web_contents()); | 54 summary.navigation_id = NavigationID(web_contents()); |
| 55 summary.resource_url = url; | 55 summary.resource_url = url; |
| 56 summary.request_url = url; | 56 summary.request_url = url; |
| 57 summary.mime_type = mime_type; | 57 summary.mime_type = mime_type; |
| 58 summary.resource_type = | 58 summary.resource_type = LoadingDataCollector::GetResourceTypeFromMimeType( |
| 59 ResourcePrefetchPredictor::GetResourceTypeFromMimeType( | 59 mime_type, resource_type); |
| 60 mime_type, resource_type); | |
| 61 summary.was_cached = true; | 60 summary.was_cached = true; |
| 62 auto* collector = loading_predictor->loading_data_collector(); | 61 auto* collector = loading_predictor->loading_data_collector(); |
| 63 collector->RecordURLResponse(summary); | 62 collector->RecordURLResponse(summary); |
| 64 } | 63 } |
| 65 | 64 |
| 66 } // namespace predictors | 65 } // namespace predictors |
| OLD | NEW |