Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor.cc

Issue 2186803004: predictors: Remove the HTTP restriction for speculative prefetch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 5 #include "chrome/browser/predictors/resource_prefetch_predictor.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 25 matching lines...) Expand all
36 #include "net/url_request/url_request.h" 36 #include "net/url_request/url_request.h"
37 #include "net/url_request/url_request_context_getter.h" 37 #include "net/url_request/url_request_context_getter.h"
38 38
39 using content::BrowserThread; 39 using content::BrowserThread;
40 40
41 namespace { 41 namespace {
42 42
43 // For reporting whether a subresource is handled or not, and for what reasons. 43 // For reporting whether a subresource is handled or not, and for what reasons.
44 enum ResourceStatus { 44 enum ResourceStatus {
45 RESOURCE_STATUS_HANDLED = 0, 45 RESOURCE_STATUS_HANDLED = 0,
46 RESOURCE_STATUS_NOT_HTTP_PAGE = 1, 46 RESOURCE_STATUS_NOT_HTTP_OR_HTTPS_PAGE = 1,
47 RESOURCE_STATUS_NOT_HTTP_RESOURCE = 2, 47 RESOURCE_STATUS_NOT_HTTP_OR_HTTPS_RESOURCE = 2,
48 RESOURCE_STATUS_UNSUPPORTED_MIME_TYPE = 4, 48 RESOURCE_STATUS_UNSUPPORTED_MIME_TYPE = 4,
49 RESOURCE_STATUS_NOT_GET = 8, 49 RESOURCE_STATUS_NOT_GET = 8,
50 RESOURCE_STATUS_URL_TOO_LONG = 16, 50 RESOURCE_STATUS_URL_TOO_LONG = 16,
51 RESOURCE_STATUS_NOT_CACHEABLE = 32, 51 RESOURCE_STATUS_NOT_CACHEABLE = 32,
52 RESOURCE_STATUS_HEADERS_MISSING = 64, 52 RESOURCE_STATUS_HEADERS_MISSING = 64,
53 RESOURCE_STATUS_MAX = 128, 53 RESOURCE_STATUS_MAX = 128,
54 }; 54 };
55 55
56 // For reporting various interesting events that occur during the loading of a 56 // For reporting various interesting events that occur during the loading of a
57 // single main frame. 57 // single main frame.
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 225
226 if (!request_info->IsMainFrame()) 226 if (!request_info->IsMainFrame())
227 return false; 227 return false;
228 228
229 return request_info->GetResourceType() == content::RESOURCE_TYPE_MAIN_FRAME && 229 return request_info->GetResourceType() == content::RESOURCE_TYPE_MAIN_FRAME &&
230 IsHandledMainPage(response); 230 IsHandledMainPage(response);
231 } 231 }
232 232
233 // static 233 // static
234 bool ResourcePrefetchPredictor::IsHandledMainPage(net::URLRequest* request) { 234 bool ResourcePrefetchPredictor::IsHandledMainPage(net::URLRequest* request) {
235 return request->original_url().scheme() == url::kHttpScheme; 235 return request->url().SchemeIsHTTPOrHTTPS();
236 } 236 }
237 237
238 // static 238 // static
239 bool ResourcePrefetchPredictor::IsHandledSubresource( 239 bool ResourcePrefetchPredictor::IsHandledSubresource(
240 net::URLRequest* response) { 240 net::URLRequest* response) {
241 int resource_status = 0; 241 int resource_status = 0;
242 if (response->first_party_for_cookies().scheme() != url::kHttpScheme)
243 resource_status |= RESOURCE_STATUS_NOT_HTTP_PAGE;
244 242
245 if (response->original_url().scheme() != url::kHttpScheme) 243 if (!response->first_party_for_cookies().SchemeIsHTTPOrHTTPS())
246 resource_status |= RESOURCE_STATUS_NOT_HTTP_RESOURCE; 244 resource_status |= RESOURCE_STATUS_NOT_HTTP_OR_HTTPS_PAGE;
245
246 if (!response->url().SchemeIsHTTPOrHTTPS())
247 resource_status |= RESOURCE_STATUS_NOT_HTTP_OR_HTTPS_RESOURCE;
247 248
248 std::string mime_type; 249 std::string mime_type;
249 response->GetMimeType(&mime_type); 250 response->GetMimeType(&mime_type);
250 if (!mime_type.empty() && !mime_util::IsSupportedImageMimeType(mime_type) && 251 if (!mime_type.empty() && !mime_util::IsSupportedImageMimeType(mime_type) &&
251 !mime_util::IsSupportedJavascriptMimeType(mime_type) && 252 !mime_util::IsSupportedJavascriptMimeType(mime_type) &&
252 !net::MatchesMimeType("text/css", mime_type)) { 253 !net::MatchesMimeType("text/css", mime_type)) {
253 resource_status |= RESOURCE_STATUS_UNSUPPORTED_MIME_TYPE; 254 resource_status |= RESOURCE_STATUS_UNSUPPORTED_MIME_TYPE;
254 } 255 }
255 256
256 if (response->method() != "GET") 257 if (response->method() != "GET")
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 // HistoryService is already loaded. Continue with Initialization. 1335 // HistoryService is already loaded. Continue with Initialization.
1335 OnHistoryAndCacheLoaded(); 1336 OnHistoryAndCacheLoaded();
1336 return; 1337 return;
1337 } 1338 }
1338 DCHECK(!history_service_observer_.IsObserving(history_service)); 1339 DCHECK(!history_service_observer_.IsObserving(history_service));
1339 history_service_observer_.Add(history_service); 1340 history_service_observer_.Add(history_service);
1340 return; 1341 return;
1341 } 1342 }
1342 1343
1343 } // namespace predictors 1344 } // namespace predictors
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698