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

Side by Side Diff: chrome/browser/net/referrer.h

Issue 7259019: Move base/values.h into the base namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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_api.h ('k') | chrome/browser/net/service_providers_win.h » ('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 // This class helps to remember what domains may be needed to be resolved when a 5 // This class helps to remember what domains may be needed to be resolved when a
6 // navigation takes place to a given URL. This information is gathered when a 6 // navigation takes place to a given URL. This information is gathered when a
7 // navigation to a subresource identifies a referring URL. 7 // navigation to a subresource identifies a referring URL.
8 // When future navigations take place to known referrer sites, then we 8 // When future navigations take place to known referrer sites, then we
9 // speculatively either pre-warm a TCP/IP conneciton, or at a minimum, resolve 9 // speculatively either pre-warm a TCP/IP conneciton, or at a minimum, resolve
10 // the host name via DNS. 10 // the host name via DNS.
11 11
12 // All access to this class is performed via the Predictor class, which only 12 // All access to this class is performed via the Predictor class, which only
13 // operates on the IO thread. 13 // operates on the IO thread.
14 14
15 #ifndef CHROME_BROWSER_NET_REFERRER_H_ 15 #ifndef CHROME_BROWSER_NET_REFERRER_H_
16 #define CHROME_BROWSER_NET_REFERRER_H_ 16 #define CHROME_BROWSER_NET_REFERRER_H_
17 #pragma once 17 #pragma once
18 18
19 #include <map> 19 #include <map>
20 20
21 #include "base/basictypes.h" 21 #include "base/basictypes.h"
22 #include "base/task.h" 22 #include "base/task.h"
23 #include "base/time.h" 23 #include "base/time.h"
24 #include "googleurl/src/gurl.h" 24 #include "googleurl/src/gurl.h"
25 #include "net/base/host_port_pair.h" 25 #include "net/base/host_port_pair.h"
26 26
27 namespace base {
27 class Value; 28 class Value;
29 }
28 30
29 namespace chrome_browser_net { 31 namespace chrome_browser_net {
30 32
31 //------------------------------------------------------------------------------ 33 //------------------------------------------------------------------------------
32 // For each hostname in a Referrer, we have a ReferrerValue. It indicates 34 // For each hostname in a Referrer, we have a ReferrerValue. It indicates
33 // exactly how much value (re: latency reduction, or connection use) has 35 // exactly how much value (re: latency reduction, or connection use) has
34 // resulted from having this entry. 36 // resulted from having this entry.
35 class ReferrerValue { 37 class ReferrerValue {
36 public: 38 public:
37 ReferrerValue(); 39 ReferrerValue();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // navigates to this referrer. Note that if the list is long, an entry may be 110 // navigates to this referrer. Note that if the list is long, an entry may be
109 // discarded to make room for this insertion. 111 // discarded to make room for this insertion.
110 void SuggestHost(const GURL& url); 112 void SuggestHost(const GURL& url);
111 113
112 // Trim the Referrer, by first diminishing (scaling down) the subresource 114 // Trim the Referrer, by first diminishing (scaling down) the subresource
113 // use expectation for each ReferredValue. 115 // use expectation for each ReferredValue.
114 // Returns true if expected use rate is greater than the threshold. 116 // Returns true if expected use rate is greater than the threshold.
115 bool Trim(double reduce_rate, double threshold); 117 bool Trim(double reduce_rate, double threshold);
116 118
117 // Provide methods for persisting, and restoring contents into a Value class. 119 // Provide methods for persisting, and restoring contents into a Value class.
118 Value* Serialize() const; 120 base::Value* Serialize() const;
119 void Deserialize(const Value& referrers); 121 void Deserialize(const base::Value& referrers);
120 122
121 private: 123 private:
122 // Helper function for pruning list. Metric for usefulness is "large accrued 124 // Helper function for pruning list. Metric for usefulness is "large accrued
123 // value," in the form of latency_ savings associated with a host name. We 125 // value," in the form of latency_ savings associated with a host name. We
124 // also give credit for a name being newly added, by scalling latency per 126 // also give credit for a name being newly added, by scalling latency per
125 // lifetime (time since birth). For instance, when two names have accrued 127 // lifetime (time since birth). For instance, when two names have accrued
126 // the same latency_ savings, the older one is less valuable as it didn't 128 // the same latency_ savings, the older one is less valuable as it didn't
127 // accrue savings as quickly. 129 // accrue savings as quickly.
128 void DeleteLeastUseful(); 130 void DeleteLeastUseful();
129 131
130 // The number of times this referer had its subresources scanned for possible 132 // The number of times this referer had its subresources scanned for possible
131 // preconnection or DNS preresolution. 133 // preconnection or DNS preresolution.
132 int64 use_count_; 134 int64 use_count_;
133 135
134 // We put these into a std::map<>, so we need copy constructors. 136 // We put these into a std::map<>, so we need copy constructors.
135 // DISALLOW_COPY_AND_ASSIGN(Referrer); 137 // DISALLOW_COPY_AND_ASSIGN(Referrer);
136 // TODO(jar): Consider optimization to use pointers to these instances, and 138 // TODO(jar): Consider optimization to use pointers to these instances, and
137 // avoid deep copies during re-alloc of the containing map. 139 // avoid deep copies during re-alloc of the containing map.
138 }; 140 };
139 141
140 } // namespace chrome_browser_net 142 } // namespace chrome_browser_net
141 143
142 #endif // CHROME_BROWSER_NET_REFERRER_H_ 144 #endif // CHROME_BROWSER_NET_REFERRER_H_
OLDNEW
« no previous file with comments | « chrome/browser/net/predictor_api.h ('k') | chrome/browser/net/service_providers_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698