| 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/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 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 // TODO(jar): I need to discard names that have long since expired. | 1036 // TODO(jar): I need to discard names that have long since expired. |
| 1037 // Currently we only add to the domain map :-/ | 1037 // Currently we only add to the domain map :-/ |
| 1038 | 1038 |
| 1039 DCHECK(info->HasUrl(url)); | 1039 DCHECK(info->HasUrl(url)); |
| 1040 | 1040 |
| 1041 if (!info->NeedsDnsUpdate()) { | 1041 if (!info->NeedsDnsUpdate()) { |
| 1042 info->DLogResultsStats("DNS PrefetchNotUpdated"); | 1042 info->DLogResultsStats("DNS PrefetchNotUpdated"); |
| 1043 return NULL; | 1043 return NULL; |
| 1044 } | 1044 } |
| 1045 | 1045 |
| 1046 bool would_likely_proxy; | 1046 if (WouldLikelyProxyURL(url)) { |
| 1047 { | |
| 1048 // TODO(ttuttle): Remove ScopedTracker below once crbug.com/436671 is fixed. | |
| 1049 tracked_objects::ScopedTracker tracking_profile( | |
| 1050 FROM_HERE_WITH_EXPLICIT_FUNCTION("436671 WouldLikelyProxyURL()")); | |
| 1051 would_likely_proxy = WouldLikelyProxyURL(url); | |
| 1052 } | |
| 1053 | |
| 1054 if (would_likely_proxy) { | |
| 1055 info->DLogResultsStats("DNS PrefetchForProxiedRequest"); | 1047 info->DLogResultsStats("DNS PrefetchForProxiedRequest"); |
| 1056 return NULL; | 1048 return NULL; |
| 1057 } | 1049 } |
| 1058 | 1050 |
| 1059 info->SetQueuedState(motivation); | 1051 info->SetQueuedState(motivation); |
| 1060 work_queue_.Push(url, motivation); | 1052 work_queue_.Push(url, motivation); |
| 1061 | 1053 |
| 1062 StartSomeQueuedResolutions(); | 1054 StartSomeQueuedResolutions(); |
| 1063 return info; | 1055 return info; |
| 1064 } | 1056 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1091 DCHECK(info->HasUrl(url)); | 1083 DCHECK(info->HasUrl(url)); |
| 1092 info->SetAssignedState(); | 1084 info->SetAssignedState(); |
| 1093 | 1085 |
| 1094 if (CongestionControlPerformed(info)) { | 1086 if (CongestionControlPerformed(info)) { |
| 1095 DCHECK(work_queue_.IsEmpty()); | 1087 DCHECK(work_queue_.IsEmpty()); |
| 1096 return; | 1088 return; |
| 1097 } | 1089 } |
| 1098 | 1090 |
| 1099 LookupRequest* request = new LookupRequest(this, host_resolver_, url); | 1091 LookupRequest* request = new LookupRequest(this, host_resolver_, url); |
| 1100 | 1092 |
| 1101 int status; | 1093 int status = request->Start(); |
| 1102 { | |
| 1103 // TODO(ttuttle): Remove ScopedTracker below once crbug.com/436671 is | |
| 1104 // fixed. | |
| 1105 tracked_objects::ScopedTracker tracking_profile( | |
| 1106 FROM_HERE_WITH_EXPLICIT_FUNCTION("436671 LookupRequest::Start()")); | |
| 1107 status = request->Start(); | |
| 1108 } | |
| 1109 | |
| 1110 if (status == net::ERR_IO_PENDING) { | 1094 if (status == net::ERR_IO_PENDING) { |
| 1111 // Will complete asynchronously. | 1095 // Will complete asynchronously. |
| 1112 pending_lookups_.insert(request); | 1096 pending_lookups_.insert(request); |
| 1113 peak_pending_lookups_ = std::max(peak_pending_lookups_, | 1097 peak_pending_lookups_ = std::max(peak_pending_lookups_, |
| 1114 pending_lookups_.size()); | 1098 pending_lookups_.size()); |
| 1115 } else { | 1099 } else { |
| 1116 // Completed synchronously (was already cached by HostResolver), or else | 1100 // Completed synchronously (was already cached by HostResolver), or else |
| 1117 // there was (equivalently) some network error that prevents us from | 1101 // there was (equivalently) some network error that prevents us from |
| 1118 // finding the name. Status net::OK means it was "found." | 1102 // finding the name. Status net::OK means it was "found." |
| 1119 LookupFinished(request, url, status == net::OK); | 1103 LookupFinished(request, url, status == net::OK); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 } | 1307 } |
| 1324 | 1308 |
| 1325 void SimplePredictor::ShutdownOnUIThread() { | 1309 void SimplePredictor::ShutdownOnUIThread() { |
| 1326 SetShutdown(true); | 1310 SetShutdown(true); |
| 1327 } | 1311 } |
| 1328 | 1312 |
| 1329 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; } | 1313 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; } |
| 1330 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; } | 1314 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; } |
| 1331 | 1315 |
| 1332 } // namespace chrome_browser_net | 1316 } // namespace chrome_browser_net |
| OLD | NEW |