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

Side by Side Diff: components/history/core/browser/top_sites_cache.cc

Issue 2481923002: [WIP] make GURL::path() return a StringPiece (Closed)
Patch Set: thanks asan Created 4 years, 1 month 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 #include "components/history/core/browser/top_sites_cache.h" 5 #include "components/history/core/browser/top_sites_cache.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ref_counted_memory.h" 8 #include "base/memory/ref_counted_memory.h"
9 9
10 namespace history { 10 namespace history {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 86 }
87 // Everything on or after |it_hi| is irrelevant. 87 // Everything on or after |it_hi| is irrelevant.
88 88
89 GURL base_url(url.ReplaceComponents(clear_path_query_ref_)); 89 GURL base_url(url.ReplaceComponents(clear_path_query_ref_));
90 CanonicalURLs::const_iterator it_lo = 90 CanonicalURLs::const_iterator it_lo =
91 canonical_urls_.lower_bound(CanonicalURLQuery(base_url).entry()); 91 canonical_urls_.lower_bound(CanonicalURLQuery(base_url).entry());
92 if (it_lo == canonical_urls_.end()) 92 if (it_lo == canonical_urls_.end())
93 return GURL::EmptyGURL(); 93 return GURL::EmptyGURL();
94 GURL compare_url_lo(GetURLFromIterator(it_lo)); 94 GURL compare_url_lo(GetURLFromIterator(it_lo));
95 if (!HaveSameSchemeHostAndPort(base_url, compare_url_lo) || 95 if (!HaveSameSchemeHostAndPort(base_url, compare_url_lo) ||
96 !IsPathPrefix(base_url.path(), compare_url_lo.path())) { 96 !IsPathPrefix(base_url.path().as_string(),
97 compare_url_lo.path().as_string())) {
97 return GURL::EmptyGURL(); 98 return GURL::EmptyGURL();
98 } 99 }
99 // Everything before |it_lo| is irrelevant. 100 // Everything before |it_lo| is irrelevant.
100 101
101 // Search in [|it_lo|, |it_hi|) in reversed order. The first URL found that's 102 // Search in [|it_lo|, |it_hi|) in reversed order. The first URL found that's
102 // a prefix of |url| (ignoring "?query#ref") would be returned. 103 // a prefix of |url| (ignoring "?query#ref") would be returned.
103 for (CanonicalURLs::const_iterator it = it_hi; it != it_lo;) { 104 for (CanonicalURLs::const_iterator it = it_hi; it != it_lo;) {
104 --it; 105 --it;
105 GURL compare_url(GetURLFromIterator(it)); 106 GURL compare_url(GetURLFromIterator(it));
106 DCHECK(HaveSameSchemeHostAndPort(compare_url, url)); 107 DCHECK(HaveSameSchemeHostAndPort(compare_url, url));
107 if (IsPathPrefix(compare_url.path(), url.path())) 108 if (IsPathPrefix(compare_url.path().as_string(), url.path().as_string()))
108 return it->first.first->url; 109 return it->first.first->url;
109 } 110 }
110 111
111 return GURL::EmptyGURL(); 112 return GURL::EmptyGURL();
112 } 113 }
113 114
114 bool TopSitesCache::IsKnownURL(const GURL& url) const { 115 bool TopSitesCache::IsKnownURL(const GURL& url) const {
115 return GetCanonicalURLsIterator(url) != canonical_urls_.end(); 116 return GetCanonicalURLsIterator(url) != canonical_urls_.end();
116 } 117 }
117 118
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 return canonical_urls_.find(CanonicalURLQuery(url).entry()); 174 return canonical_urls_.find(CanonicalURLQuery(url).entry());
174 } 175 }
175 176
176 const GURL& TopSitesCache::GetURLFromIterator( 177 const GURL& TopSitesCache::GetURLFromIterator(
177 CanonicalURLs::const_iterator it) const { 178 CanonicalURLs::const_iterator it) const {
178 DCHECK(it != canonical_urls_.end()); 179 DCHECK(it != canonical_urls_.end());
179 return it->first.first->redirects[it->first.second]; 180 return it->first.first->redirects[it->first.second];
180 } 181 }
181 182
182 } // namespace history 183 } // namespace history
OLDNEW
« no previous file with comments | « components/domain_reliability/util.cc ('k') | components/history/core/browser/web_history_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698