OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <set> | 8 #include <set> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 TOO_NEW, | 142 TOO_NEW, |
143 SUBRESOURCE_VALUE_MAX | 143 SUBRESOURCE_VALUE_MAX |
144 }; | 144 }; |
145 | 145 |
146 void Predictor::PredictFrameSubresources(const GURL& url) { | 146 void Predictor::PredictFrameSubresources(const GURL& url) { |
147 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 147 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
148 DCHECK(url.GetWithEmptyPath() == url); | 148 DCHECK(url.GetWithEmptyPath() == url); |
149 Referrers::iterator it = referrers_.find(url); | 149 Referrers::iterator it = referrers_.find(url); |
150 if (referrers_.end() == it) | 150 if (referrers_.end() == it) |
151 return; | 151 return; |
| 152 ChromeThread::PostTask( |
| 153 ChromeThread::IO, |
| 154 FROM_HERE, |
| 155 NewRunnableMethod(this, |
| 156 &Predictor::PrepareFrameSubresources, url)); |
| 157 } |
| 158 |
| 159 void Predictor::PrepareFrameSubresources(const GURL& url) { |
| 160 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| 161 DCHECK(url.GetWithEmptyPath() == url); |
| 162 Referrers::iterator it = referrers_.find(url); |
| 163 if (referrers_.end() == it) |
| 164 return; |
| 165 |
152 Referrer* referrer = &(it->second); | 166 Referrer* referrer = &(it->second); |
153 referrer->IncrementUseCount(); | 167 referrer->IncrementUseCount(); |
154 const UrlInfo::ResolutionMotivation motivation = | 168 const UrlInfo::ResolutionMotivation motivation = |
155 UrlInfo::LEARNED_REFERAL_MOTIVATED; | 169 UrlInfo::LEARNED_REFERAL_MOTIVATED; |
156 for (Referrer::iterator future_url = referrer->begin(); | 170 for (Referrer::iterator future_url = referrer->begin(); |
157 future_url != referrer->end(); ++future_url) { | 171 future_url != referrer->end(); ++future_url) { |
158 SubresourceValue evalution(TOO_NEW); | 172 SubresourceValue evalution(TOO_NEW); |
159 double connection_expectation = future_url->second.subresource_use_rate(); | 173 double connection_expectation = future_url->second.subresource_use_rate(); |
160 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.PreconnectSubresourceExpectation", | 174 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.PreconnectSubresourceExpectation", |
161 static_cast<int>(connection_expectation * 100), | 175 static_cast<int>(connection_expectation * 100), |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 GURL Predictor::HostNameQueue::Pop() { | 574 GURL Predictor::HostNameQueue::Pop() { |
561 DCHECK(!IsEmpty()); | 575 DCHECK(!IsEmpty()); |
562 std::queue<GURL> *queue(rush_queue_.empty() ? &background_queue_ | 576 std::queue<GURL> *queue(rush_queue_.empty() ? &background_queue_ |
563 : &rush_queue_); | 577 : &rush_queue_); |
564 GURL url(queue->front()); | 578 GURL url(queue->front()); |
565 queue->pop(); | 579 queue->pop(); |
566 return url; | 580 return url; |
567 } | 581 } |
568 | 582 |
569 } // namespace chrome_browser_net | 583 } // namespace chrome_browser_net |
OLD | NEW |