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

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

Issue 7605019: Reduce number of unnamed-type-template-args violations. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/net/predictor.h ('k') | chrome/browser/net/predictor_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 11 matching lines...) Expand all
22 #include "net/base/host_resolver.h" 22 #include "net/base/host_resolver.h"
23 #include "net/base/net_errors.h" 23 #include "net/base/net_errors.h"
24 #include "net/base/net_log.h" 24 #include "net/base/net_log.h"
25 #include "net/base/single_request_host_resolver.h" 25 #include "net/base/single_request_host_resolver.h"
26 26
27 using base::TimeDelta; 27 using base::TimeDelta;
28 28
29 namespace chrome_browser_net { 29 namespace chrome_browser_net {
30 30
31 // static 31 // static
32 const int Predictor::kPredictorReferrerVersion = 2;
32 const double Predictor::kPreconnectWorthyExpectedValue = 0.8; 33 const double Predictor::kPreconnectWorthyExpectedValue = 0.8;
33 // static
34 const double Predictor::kDNSPreresolutionWorthyExpectedValue = 0.1; 34 const double Predictor::kDNSPreresolutionWorthyExpectedValue = 0.1;
35 // static
36 const double Predictor::kDiscardableExpectedValue = 0.05; 35 const double Predictor::kDiscardableExpectedValue = 0.05;
37 // The goal is of trimming is to to reduce the importance (number of expected 36 // The goal is of trimming is to to reduce the importance (number of expected
38 // subresources needed) by a factor of 2 after about 24 hours of uptime. We will 37 // subresources needed) by a factor of 2 after about 24 hours of uptime. We will
39 // trim roughly once-an-hour of uptime. The ratio to use in each trim operation 38 // trim roughly once-an-hour of uptime. The ratio to use in each trim operation
40 // is then the 24th root of 0.5. If a user only surfs for 4 hours a day, then 39 // is then the 24th root of 0.5. If a user only surfs for 4 hours a day, then
41 // after about 6 days they will have halved all their estimates of subresource 40 // after about 6 days they will have halved all their estimates of subresource
42 // connections. Once this falls below kDiscardableExpectedValue the referrer 41 // connections. Once this falls below kDiscardableExpectedValue the referrer
43 // will be discarded. 42 // will be discarded.
44 // TODO(jar): Measure size of referrer lists in the field. Consider an adaptive 43 // TODO(jar): Measure size of referrer lists in the field. Consider an adaptive
45 // system that uses a higher trim ratio when the list is large. 44 // system that uses a higher trim ratio when the list is large.
46 // static 45 // static
47 const double Predictor::kReferrerTrimRatio = 0.97153; 46 const double Predictor::kReferrerTrimRatio = 0.97153;
48
49 // static
50 const TimeDelta Predictor::kDurationBetweenTrimmings = TimeDelta::FromHours(1); 47 const TimeDelta Predictor::kDurationBetweenTrimmings = TimeDelta::FromHours(1);
51 // static
52 const TimeDelta Predictor::kDurationBetweenTrimmingIncrements = 48 const TimeDelta Predictor::kDurationBetweenTrimmingIncrements =
53 TimeDelta::FromSeconds(15); 49 TimeDelta::FromSeconds(15);
54 // static
55 const size_t Predictor::kUrlsTrimmedPerIncrement = 5u; 50 const size_t Predictor::kUrlsTrimmedPerIncrement = 5u;
56 51
57 class Predictor::LookupRequest { 52 class Predictor::LookupRequest {
58 public: 53 public:
59 LookupRequest(Predictor* predictor, 54 LookupRequest(Predictor* predictor,
60 net::HostResolver* host_resolver, 55 net::HostResolver* host_resolver,
61 const GURL& url) 56 const GURL& url)
62 : ALLOW_THIS_IN_INITIALIZER_LIST( 57 : ALLOW_THIS_IN_INITIALIZER_LIST(
63 net_callback_(this, &LookupRequest::OnLookupFinished)), 58 net_callback_(this, &LookupRequest::OnLookupFinished)),
64 predictor_(predictor), 59 predictor_(predictor),
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 594 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
600 // Just finish up work if an incremental trim is in progress. 595 // Just finish up work if an incremental trim is in progress.
601 if (urls_being_trimmed_.empty()) 596 if (urls_being_trimmed_.empty())
602 LoadUrlsForTrimming(); 597 LoadUrlsForTrimming();
603 IncrementalTrimReferrers(true); // Do everything now. 598 IncrementalTrimReferrers(true); // Do everything now.
604 } 599 }
605 600
606 void Predictor::SerializeReferrers(ListValue* referral_list) { 601 void Predictor::SerializeReferrers(ListValue* referral_list) {
607 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 602 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
608 referral_list->Clear(); 603 referral_list->Clear();
609 referral_list->Append(new base::FundamentalValue(PREDICTOR_REFERRER_VERSION)); 604 referral_list->Append(new base::FundamentalValue(kPredictorReferrerVersion));
610 for (Referrers::const_iterator it = referrers_.begin(); 605 for (Referrers::const_iterator it = referrers_.begin();
611 it != referrers_.end(); ++it) { 606 it != referrers_.end(); ++it) {
612 // Serialize the list of subresource names. 607 // Serialize the list of subresource names.
613 Value* subresource_list(it->second.Serialize()); 608 Value* subresource_list(it->second.Serialize());
614 609
615 // Create a list for each referer. 610 // Create a list for each referer.
616 ListValue* motivator(new ListValue); 611 ListValue* motivator(new ListValue);
617 motivator->Append(new StringValue(it->first.spec())); 612 motivator->Append(new StringValue(it->first.spec()));
618 motivator->Append(subresource_list); 613 motivator->Append(subresource_list);
619 614
620 referral_list->Append(motivator); 615 referral_list->Append(motivator);
621 } 616 }
622 } 617 }
623 618
624 void Predictor::DeserializeReferrers(const ListValue& referral_list) { 619 void Predictor::DeserializeReferrers(const ListValue& referral_list) {
625 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 620 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
626 int format_version = -1; 621 int format_version = -1;
627 if (referral_list.GetSize() > 0 && 622 if (referral_list.GetSize() > 0 &&
628 referral_list.GetInteger(0, &format_version) && 623 referral_list.GetInteger(0, &format_version) &&
629 format_version == PREDICTOR_REFERRER_VERSION) { 624 format_version == kPredictorReferrerVersion) {
630 for (size_t i = 1; i < referral_list.GetSize(); ++i) { 625 for (size_t i = 1; i < referral_list.GetSize(); ++i) {
631 ListValue* motivator; 626 ListValue* motivator;
632 if (!referral_list.GetList(i, &motivator)) { 627 if (!referral_list.GetList(i, &motivator)) {
633 NOTREACHED(); 628 NOTREACHED();
634 return; 629 return;
635 } 630 }
636 std::string motivating_url_spec; 631 std::string motivating_url_spec;
637 if (!motivator->GetString(0, &motivating_url_spec)) { 632 if (!motivator->GetString(0, &motivating_url_spec)) {
638 NOTREACHED(); 633 NOTREACHED();
639 return; 634 return;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 // If we omit a port, it will default to 80 or 443 as appropriate. 758 // If we omit a port, it will default to 80 or 443 as appropriate.
764 std::string colon_plus_port; 759 std::string colon_plus_port;
765 if (url.has_port()) 760 if (url.has_port())
766 colon_plus_port = ":" + url.port(); 761 colon_plus_port = ":" + url.port();
767 762
768 return GURL(scheme + "://" + url.host() + colon_plus_port); 763 return GURL(scheme + "://" + url.host() + colon_plus_port);
769 } 764 }
770 765
771 766
772 } // namespace chrome_browser_net 767 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/predictor.h ('k') | chrome/browser/net/predictor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698