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

Side by Side Diff: net/base/registry_controlled_domains/registry_controlled_domain.h

Issue 2380523004: Avoid unnecessary std::string allocations. (Closed)
Patch Set: Correct comment. Created 4 years, 2 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
OLDNEW
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 // NB: Modelled after Mozilla's code (originally written by Pamela Greene, 5 // NB: Modelled after Mozilla's code (originally written by Pamela Greene,
6 // later modified by others), but almost entirely rewritten for Chrome. 6 // later modified by others), but almost entirely rewritten for Chrome.
7 // (netwerk/dns/src/nsEffectiveTLDService.h) 7 // (netwerk/dns/src/nsEffectiveTLDService.h)
8 /* ***** BEGIN LICENSE BLOCK ***** 8 /* ***** BEGIN LICENSE BLOCK *****
9 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 9 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
10 * 10 *
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // http://a.b.co.uk/file.html -> "b.co.uk" (co.uk) 175 // http://a.b.co.uk/file.html -> "b.co.uk" (co.uk)
176 // file:///C:/bar.html -> "" (no host) 176 // file:///C:/bar.html -> "" (no host)
177 // http://foo.com../file.html -> "" (multiple trailing dots) 177 // http://foo.com../file.html -> "" (multiple trailing dots)
178 // http://192.168.0.1/file.html -> "" (IP address) 178 // http://192.168.0.1/file.html -> "" (IP address)
179 // http://bar/file.html -> "" (no subcomponents) 179 // http://bar/file.html -> "" (no subcomponents)
180 // http://co.uk/file.html -> "" (host is a registry) 180 // http://co.uk/file.html -> "" (host is a registry)
181 // http://foo.bar/file.html -> "foo.bar" (no rule; assume bar) 181 // http://foo.bar/file.html -> "foo.bar" (no rule; assume bar)
182 NET_EXPORT std::string GetDomainAndRegistry(const GURL& gurl, 182 NET_EXPORT std::string GetDomainAndRegistry(const GURL& gurl,
183 PrivateRegistryFilter filter); 183 PrivateRegistryFilter filter);
184 184
185 // Same as above, but returns the domain and registry as a StringPiece that
186 // references the underlying string of the passed-in |gurl|.
187 // TODO(pkalinnikov): Rename this to GetDomainAndRegistry and get rid of the
188 // std::string-returning version. Update clients.
189 NET_EXPORT base::StringPiece GetDomainAndRegistryAsStringPiece(
190 const GURL& gurl,
191 PrivateRegistryFilter filter);
192
185 // Like the GURL version, but takes a host (which is canonicalized internally) 193 // Like the GURL version, but takes a host (which is canonicalized internally)
186 // instead of a full GURL. 194 // instead of a full GURL.
187 NET_EXPORT std::string GetDomainAndRegistry(base::StringPiece host, 195 NET_EXPORT std::string GetDomainAndRegistry(base::StringPiece host,
188 PrivateRegistryFilter filter); 196 PrivateRegistryFilter filter);
189 197
190 // These convenience functions return true if the two GURLs or Origins both have 198 // These convenience functions return true if the two GURLs or Origins both have
191 // hosts and one of the following is true: 199 // hosts and one of the following is true:
192 // * They each have a known domain and registry, and it is the same for both 200 // * They each have a known domain and registry, and it is the same for both
193 // URLs. Note that this means the trailing dot, if any, must match too. 201 // URLs. Note that this means the trailing dot, if any, must match too.
194 // * They don't have known domains/registries, but the hosts are identical. 202 // * They don't have known domains/registries, but the hosts are identical.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // Used for unit tests. Use default domains. 246 // Used for unit tests. Use default domains.
239 NET_EXPORT_PRIVATE void SetFindDomainGraph(); 247 NET_EXPORT_PRIVATE void SetFindDomainGraph();
240 248
241 // Used for unit tests, so that a frozen list of domains is used. 249 // Used for unit tests, so that a frozen list of domains is used.
242 NET_EXPORT_PRIVATE void SetFindDomainGraph(const unsigned char* domains, 250 NET_EXPORT_PRIVATE void SetFindDomainGraph(const unsigned char* domains,
243 size_t length); 251 size_t length);
244 } // namespace registry_controlled_domains 252 } // namespace registry_controlled_domains
245 } // namespace net 253 } // namespace net
246 254
247 #endif // NET_BASE_REGISTRY_CONTROLLED_DOMAINS_REGISTRY_CONTROLLED_DOMAIN_H_ 255 #endif // NET_BASE_REGISTRY_CONTROLLED_DOMAINS_REGISTRY_CONTROLLED_DOMAIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698