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

Side by Side Diff: chrome/common/visitedlink_common.h

Issue 40226: Fix files with lines > 80 cols. Part 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 9 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/common/time_format_unittest.cc ('k') | chrome/common/visitedlink_common.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #ifndef CHROME_COMMON_VISITEDLINK_COMMON_H__ 5 #ifndef CHROME_COMMON_VISITEDLINK_COMMON_H__
6 #define CHROME_COMMON_VISITEDLINK_COMMON_H__ 6 #define CHROME_COMMON_VISITEDLINK_COMMON_H__
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // can get stats on the table 84 // can get stats on the table
85 struct SharedHeader { 85 struct SharedHeader {
86 // see goes into table_length_ 86 // see goes into table_length_
87 uint32 length; 87 uint32 length;
88 88
89 // goes into salt_ 89 // goes into salt_
90 uint8 salt[LINK_SALT_LENGTH]; 90 uint8 salt[LINK_SALT_LENGTH];
91 }; 91 };
92 92
93 // Returns the fingerprint at the given index into the URL table. This 93 // Returns the fingerprint at the given index into the URL table. This
94 // function should be called instead of accessing the table directly to contai n 94 // function should be called instead of accessing the table directly to
95 // endian issues. 95 // contain endian issues.
96 Fingerprint FingerprintAt(int32 table_offset) const { 96 Fingerprint FingerprintAt(int32 table_offset) const {
97 DCHECK(hash_table_); 97 DCHECK(hash_table_);
98 if (!hash_table_) 98 if (!hash_table_)
99 return 0; 99 return 0;
100 return hash_table_[table_offset]; 100 return hash_table_[table_offset];
101 } 101 }
102 102
103 // Computes the fingerprint of the given canonical URL. It is static so the 103 // Computes the fingerprint of the given canonical URL. It is static so the
104 // same algorithm can be re-used by the table rebuilder, so you will have to 104 // same algorithm can be re-used by the table rebuilder, so you will have to
105 // pass the salt as a parameter. See the non-static version above if you 105 // pass the salt as a parameter. See the non-static version above if you
106 // want to use the current class' salt. 106 // want to use the current class' salt.
107 static Fingerprint ComputeURLFingerprint(const char* canonical_url, 107 static Fingerprint ComputeURLFingerprint(const char* canonical_url,
108 size_t url_len, 108 size_t url_len,
109 const uint8 salt[LINK_SALT_LENGTH]); 109 const uint8 salt[LINK_SALT_LENGTH]);
110 110
111 // Computes the hash value of the given fingerprint, this is used as a lookup 111 // Computes the hash value of the given fingerprint, this is used as a lookup
112 // into the hashtable. 112 // into the hashtable.
113 static Hash HashFingerprint(Fingerprint fingerprint, int32 table_length) { 113 static Hash HashFingerprint(Fingerprint fingerprint, int32 table_length) {
114 return static_cast<Hash>(fingerprint % table_length); 114 return static_cast<Hash>(fingerprint % table_length);
115 } 115 }
116 Hash HashFingerprint(Fingerprint fingerprint) const { // uses the current hash table 116 // Uses the current hashtable.
117 Hash HashFingerprint(Fingerprint fingerprint) const {
117 return HashFingerprint(fingerprint, table_length_); 118 return HashFingerprint(fingerprint, table_length_);
118 } 119 }
119 120
120 // pointer to the first item 121 // pointer to the first item
121 VisitedLinkCommon::Fingerprint* hash_table_; 122 VisitedLinkCommon::Fingerprint* hash_table_;
122 123
123 // the number of items in the hash table 124 // the number of items in the hash table
124 int32 table_length_; 125 int32 table_length_;
125 126
126 // salt used for each URL when computing the fingerprint 127 // salt used for each URL when computing the fingerprint
127 uint8 salt_[LINK_SALT_LENGTH]; 128 uint8 salt_[LINK_SALT_LENGTH];
128 129
129 private: 130 private:
130 DISALLOW_EVIL_CONSTRUCTORS(VisitedLinkCommon); 131 DISALLOW_EVIL_CONSTRUCTORS(VisitedLinkCommon);
131 }; 132 };
132 133
133 #endif // WIN_COMMON_VISITEDLINK_COMMON_H__ 134 #endif // WIN_COMMON_VISITEDLINK_COMMON_H__
134 135
OLDNEW
« no previous file with comments | « chrome/common/time_format_unittest.cc ('k') | chrome/common/visitedlink_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698