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

Side by Side Diff: chrome/browser/history/history_backend.cc

Issue 10911149: Cleanup FaviconHandler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
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 "chrome/browser/history/history_backend.h" 5 #include "chrome/browser/history/history_backend.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 2149 matching lines...) Expand 10 before | Expand all | Expand 10 after
2160 // TODO(pkotwicz): Select bitmap results from multiple favicons once 2160 // TODO(pkotwicz): Select bitmap results from multiple favicons once
2161 // content::FaviconStatus supports multiple icon URLs. 2161 // content::FaviconStatus supports multiple icon URLs.
2162 FaviconID best_favicon_id = 0; 2162 FaviconID best_favicon_id = 0;
2163 std::vector<FaviconBitmapID> best_bitmap_ids; 2163 std::vector<FaviconBitmapID> best_bitmap_ids;
2164 float highest_score = kSelectFaviconFramesInvalidScore; 2164 float highest_score = kSelectFaviconFramesInvalidScore;
2165 for (size_t i = 0; i < candidate_favicon_ids.size(); ++i) { 2165 for (size_t i = 0; i < candidate_favicon_ids.size(); ++i) {
2166 std::vector<FaviconBitmapIDSize> bitmap_id_sizes; 2166 std::vector<FaviconBitmapIDSize> bitmap_id_sizes;
2167 thumbnail_db_->GetFaviconBitmapIDSizes(candidate_favicon_ids[i], 2167 thumbnail_db_->GetFaviconBitmapIDSizes(candidate_favicon_ids[i],
2168 &bitmap_id_sizes); 2168 &bitmap_id_sizes);
2169 2169
2170 std::vector<FaviconBitmapID> candidate_bitmap_ids; 2170 // Get vector of gfx::Size from |bitmap_id_sizes|.
2171 std::vector<gfx::Size> sizes;
2172 for (size_t j = 0; j < bitmap_id_sizes.size(); ++j)
2173 sizes.push_back(bitmap_id_sizes[j].pixel_size);
2174
2175 std::vector<size_t> candidate_bitmap_indices;
2171 float score = 0; 2176 float score = 0;
2172 SelectFaviconBitmapIDs(bitmap_id_sizes, 2177 SelectFaviconFrameIndices(sizes,
2173 desired_scale_factors, 2178 desired_scale_factors,
2174 desired_size_in_dip, 2179 desired_size_in_dip,
2175 &candidate_bitmap_ids, 2180 &candidate_bitmap_indices,
2176 &score); 2181 &score);
2177 if (score > highest_score) { 2182 if (score > highest_score) {
2183 highest_score = score;
2178 best_favicon_id = candidate_favicon_ids[i], 2184 best_favicon_id = candidate_favicon_ids[i],
2179 best_bitmap_ids.swap(candidate_bitmap_ids); 2185 best_bitmap_ids.clear();
2180 highest_score = score; 2186 for (size_t j = 0; j < candidate_bitmap_indices.size(); ++j) {
2187 size_t candidate_index = candidate_bitmap_indices[j];
2188 best_bitmap_ids.push_back(
2189 bitmap_id_sizes[candidate_index].bitmap_id);
2190 }
2181 } 2191 }
2182 } 2192 }
2183 2193
2184 // Construct FaviconBitmapResults from |best_favicon_id| and 2194 // Construct FaviconBitmapResults from |best_favicon_id| and
2185 // |best_bitmap_ids|. 2195 // |best_bitmap_ids|.
2186 GURL icon_url; 2196 GURL icon_url;
2187 IconType icon_type; 2197 IconType icon_type;
2188 if (!thumbnail_db_->GetFaviconHeader(best_favicon_id, &icon_url, 2198 if (!thumbnail_db_->GetFaviconHeader(best_favicon_id, &icon_url,
2189 &icon_type, NULL)) { 2199 &icon_type, NULL)) {
2190 return false; 2200 return false;
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
2710 info.url_id = visit.url_id; 2720 info.url_id = visit.url_id;
2711 info.time = visit.visit_time; 2721 info.time = visit.visit_time;
2712 info.transition = visit.transition; 2722 info.transition = visit.transition;
2713 // If we don't have a delegate yet during setup or shutdown, we will drop 2723 // If we don't have a delegate yet during setup or shutdown, we will drop
2714 // these notifications. 2724 // these notifications.
2715 if (delegate_.get()) 2725 if (delegate_.get())
2716 delegate_->NotifyVisitDBObserversOnAddVisit(info); 2726 delegate_->NotifyVisitDBObserversOnAddVisit(info);
2717 } 2727 }
2718 2728
2719 } // namespace history 2729 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698