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

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: . 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 RESERVED_1 = 1,
47 RESOURCE_STATUS_NOT_HTTP_RESOURCE = 2, 47 RESERVED_2 = 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 true;
pasko 2016/07/27 14:06:24 we agreed offline that we should explicitly accept
Benoit L 2016/07/27 14:25:56 Done.
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
245 if (response->original_url().scheme() != url::kHttpScheme)
246 resource_status |= RESOURCE_STATUS_NOT_HTTP_RESOURCE;
247 242
248 std::string mime_type; 243 std::string mime_type;
249 response->GetMimeType(&mime_type); 244 response->GetMimeType(&mime_type);
250 if (!mime_type.empty() && !mime_util::IsSupportedImageMimeType(mime_type) && 245 if (!mime_type.empty() && !mime_util::IsSupportedImageMimeType(mime_type) &&
251 !mime_util::IsSupportedJavascriptMimeType(mime_type) && 246 !mime_util::IsSupportedJavascriptMimeType(mime_type) &&
252 !net::MatchesMimeType("text/css", mime_type)) { 247 !net::MatchesMimeType("text/css", mime_type)) {
253 resource_status |= RESOURCE_STATUS_UNSUPPORTED_MIME_TYPE; 248 resource_status |= RESOURCE_STATUS_UNSUPPORTED_MIME_TYPE;
254 } 249 }
255 250
256 if (response->method() != "GET") 251 if (response->method() != "GET")
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 // HistoryService is already loaded. Continue with Initialization. 1329 // HistoryService is already loaded. Continue with Initialization.
1335 OnHistoryAndCacheLoaded(); 1330 OnHistoryAndCacheLoaded();
1336 return; 1331 return;
1337 } 1332 }
1338 DCHECK(!history_service_observer_.IsObserving(history_service)); 1333 DCHECK(!history_service_observer_.IsObserving(history_service));
1339 history_service_observer_.Add(history_service); 1334 history_service_observer_.Add(history_service);
1340 return; 1335 return;
1341 } 1336 }
1342 1337
1343 } // namespace predictors 1338 } // 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