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

Side by Side Diff: chrome/browser/net/predictor.cc

Issue 1131293004: Add cross origin to Blink-driven preconnect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 5 years, 6 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
OLDNEW
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/net/predictor.h" 5 #include "chrome/browser/net/predictor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <set> 9 #include <set>
10 #include <sstream> 10 #include <sstream>
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 // a frequent occurrence on Android. 830 // a frequent occurrence on Android.
831 TrimReferrersNow(); 831 TrimReferrersNow();
832 SerializeReferrers(referral_list); 832 SerializeReferrers(referral_list);
833 833
834 completion->Signal(); 834 completion->Signal();
835 } 835 }
836 836
837 void Predictor::PreconnectUrl(const GURL& url, 837 void Predictor::PreconnectUrl(const GURL& url,
838 const GURL& first_party_for_cookies, 838 const GURL& first_party_for_cookies,
839 UrlInfo::ResolutionMotivation motivation, 839 UrlInfo::ResolutionMotivation motivation,
840 int count) { 840 int count,
841 bool is_credentials_flag_set) {
841 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || 842 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
842 BrowserThread::CurrentlyOn(BrowserThread::IO)); 843 BrowserThread::CurrentlyOn(BrowserThread::IO));
843 844
844 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { 845 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) {
845 PreconnectUrlOnIOThread(url, first_party_for_cookies, motivation, count); 846 PreconnectUrlOnIOThread(url,
847 first_party_for_cookies,
848 motivation,
849 count,
850 is_credentials_flag_set);
846 } else { 851 } else {
847 BrowserThread::PostTask( 852 BrowserThread::PostTask(
848 BrowserThread::IO, 853 BrowserThread::IO,
849 FROM_HERE, 854 FROM_HERE,
850 base::Bind(&Predictor::PreconnectUrlOnIOThread, 855 base::Bind(&Predictor::PreconnectUrlOnIOThread,
851 base::Unretained(this), url, first_party_for_cookies, 856 base::Unretained(this), url, first_party_for_cookies,
852 motivation, count)); 857 motivation, count, is_credentials_flag_set));
853 } 858 }
854 } 859 }
855 860
856 void Predictor::PreconnectUrlOnIOThread( 861 void Predictor::PreconnectUrlOnIOThread(
857 const GURL& original_url, 862 const GURL& original_url,
858 const GURL& first_party_for_cookies, 863 const GURL& first_party_for_cookies,
859 UrlInfo::ResolutionMotivation motivation, 864 UrlInfo::ResolutionMotivation motivation,
860 int count) { 865 int count,
866 bool is_credentials_flag_set) {
861 // Skip the HSTS redirect. 867 // Skip the HSTS redirect.
862 GURL url = GetHSTSRedirectOnIOThread(original_url); 868 GURL url = GetHSTSRedirectOnIOThread(original_url);
863 869
864 if (observer_) { 870 if (observer_) {
865 observer_->OnPreconnectUrl( 871 observer_->OnPreconnectUrl(
866 url, first_party_for_cookies, motivation, count); 872 url, first_party_for_cookies, motivation, count);
867 } 873 }
868 874
869 PreconnectOnIOThread(url, 875 PreconnectOnIOThread(url,
870 first_party_for_cookies, 876 first_party_for_cookies,
871 motivation, 877 motivation,
872 count, 878 count,
873 url_request_context_getter_.get()); 879 url_request_context_getter_.get(),
880 is_credentials_flag_set);
874 } 881 }
875 882
876 void Predictor::PredictFrameSubresources(const GURL& url, 883 void Predictor::PredictFrameSubresources(const GURL& url,
877 const GURL& first_party_for_cookies) { 884 const GURL& first_party_for_cookies) {
878 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || 885 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
879 BrowserThread::CurrentlyOn(BrowserThread::IO)); 886 BrowserThread::CurrentlyOn(BrowserThread::IO));
880 if (!predictor_enabled_) 887 if (!predictor_enabled_)
881 return; 888 return;
882 if (!CanPreresolveAndPreconnect()) 889 if (!CanPreresolveAndPreconnect())
883 return; 890 return;
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 } 1323 }
1317 1324
1318 void SimplePredictor::ShutdownOnUIThread() { 1325 void SimplePredictor::ShutdownOnUIThread() {
1319 SetShutdown(true); 1326 SetShutdown(true);
1320 } 1327 }
1321 1328
1322 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; } 1329 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; }
1323 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; } 1330 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; }
1324 1331
1325 } // namespace chrome_browser_net 1332 } // namespace chrome_browser_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698