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

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

Issue 335233003: Convert ui::ScaleFactor -> float in favicon/history code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 #ifndef CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_
6 #define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ 6 #define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/containers/mru_cache.h" 13 #include "base/containers/mru_cache.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/memory/memory_pressure_listener.h" 16 #include "base/memory/memory_pressure_listener.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "chrome/browser/history/expire_history_backend.h" 18 #include "chrome/browser/history/expire_history_backend.h"
19 #include "chrome/browser/history/history_database.h" 19 #include "chrome/browser/history/history_database.h"
20 #include "chrome/browser/history/history_marshaling.h" 20 #include "chrome/browser/history/history_marshaling.h"
21 #include "chrome/browser/history/history_types.h" 21 #include "chrome/browser/history/history_types.h"
22 #include "chrome/browser/history/thumbnail_database.h" 22 #include "chrome/browser/history/thumbnail_database.h"
23 #include "chrome/browser/history/visit_tracker.h" 23 #include "chrome/browser/history/visit_tracker.h"
24 #include "components/search_engines/template_url_id.h" 24 #include "components/search_engines/template_url_id.h"
25 #include "sql/init_status.h" 25 #include "sql/init_status.h"
26 #include "ui/base/layout.h"
27 26
28 class TestingProfile; 27 class TestingProfile;
29 class TypedUrlSyncableService; 28 class TypedUrlSyncableService;
30 struct ThumbnailScore; 29 struct ThumbnailScore;
31 30
32 namespace history { 31 namespace history {
33 #if defined(OS_ANDROID) 32 #if defined(OS_ANDROID)
34 class AndroidProviderBackend; 33 class AndroidProviderBackend;
35 #endif 34 #endif
36 35
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // then calling this function with url=C would fill redirects with {B, A}. 215 // then calling this function with url=C would fill redirects with {B, A}.
217 bool GetMostRecentRedirectsTo(const GURL& url, 216 bool GetMostRecentRedirectsTo(const GURL& url,
218 history::RedirectList* redirects); 217 history::RedirectList* redirects);
219 218
220 // Favicon ------------------------------------------------------------------- 219 // Favicon -------------------------------------------------------------------
221 220
222 void GetFavicons( 221 void GetFavicons(
223 const std::vector<GURL>& icon_urls, 222 const std::vector<GURL>& icon_urls,
224 int icon_types, 223 int icon_types,
225 int desired_size_in_dip, 224 int desired_size_in_dip,
226 const std::vector<ui::ScaleFactor>& desired_scale_factors, 225 const std::vector<float>& desired_favicon_scales,
227 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results); 226 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results);
228 227
229 void GetLargestFaviconForURL( 228 void GetLargestFaviconForURL(
230 const GURL& page_url, 229 const GURL& page_url,
231 const std::vector<int>& icon_types, 230 const std::vector<int>& icon_types,
232 int minimum_size_in_pixels, 231 int minimum_size_in_pixels,
233 favicon_base::FaviconRawBitmapResult* bitmap_result); 232 favicon_base::FaviconRawBitmapResult* bitmap_result);
234 233
235 void GetFaviconsForURL( 234 void GetFaviconsForURL(
236 const GURL& page_url, 235 const GURL& page_url,
237 int icon_types, 236 int icon_types,
238 int desired_size_in_dip, 237 int desired_size_in_dip,
239 const std::vector<ui::ScaleFactor>& desired_scale_factors, 238 const std::vector<float>& desired_favicon_scales,
240 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results); 239 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results);
241 240
242 void GetFaviconForID( 241 void GetFaviconForID(
243 favicon_base::FaviconID favicon_id, 242 favicon_base::FaviconID favicon_id,
244 int desired_size_in_dip, 243 int desired_size_in_dip,
245 ui::ScaleFactor desired_scale_factor, 244 float desired_favicon_scale,
246 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results); 245 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results);
247 246
248 void UpdateFaviconMappingsAndFetch( 247 void UpdateFaviconMappingsAndFetch(
249 const GURL& page_url, 248 const GURL& page_url,
250 const std::vector<GURL>& icon_urls, 249 const std::vector<GURL>& icon_urls,
251 int icon_types, 250 int icon_types,
252 int desired_size_in_dip, 251 int desired_size_in_dip,
253 const std::vector<ui::ScaleFactor>& desired_scale_factors, 252 const std::vector<float>& desired_favicon_scales,
254 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results); 253 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results);
255 254
256 void MergeFavicon(const GURL& page_url, 255 void MergeFavicon(const GURL& page_url,
257 const GURL& icon_url, 256 const GURL& icon_url,
258 favicon_base::IconType icon_type, 257 favicon_base::IconType icon_type,
259 scoped_refptr<base::RefCountedMemory> bitmap_data, 258 scoped_refptr<base::RefCountedMemory> bitmap_data,
260 const gfx::Size& pixel_size); 259 const gfx::Size& pixel_size);
261 260
262 void SetFavicons(const GURL& page_url, 261 void SetFavicons(const GURL& page_url,
263 favicon_base::IconType icon_type, 262 favicon_base::IconType icon_type,
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 // already stored in the database. 651 // already stored in the database.
653 // If |page_url| is non-null, |icon_types| can be multiple icon types 652 // If |page_url| is non-null, |icon_types| can be multiple icon types
654 // only if |icon_types| == TOUCH_ICON | TOUCH_PRECOMPOSED_ICON. 653 // only if |icon_types| == TOUCH_ICON | TOUCH_PRECOMPOSED_ICON.
655 // If multiple icon types are specified, |page_url| will be mapped to the 654 // If multiple icon types are specified, |page_url| will be mapped to the
656 // icon URLs of the largest type available in the database. 655 // icon URLs of the largest type available in the database.
657 void UpdateFaviconMappingsAndFetchImpl( 656 void UpdateFaviconMappingsAndFetchImpl(
658 const GURL* page_url, 657 const GURL* page_url,
659 const std::vector<GURL>& icon_urls, 658 const std::vector<GURL>& icon_urls,
660 int icon_types, 659 int icon_types,
661 int desired_size_in_dip, 660 int desired_size_in_dip,
662 const std::vector<ui::ScaleFactor>& desired_scale_factors, 661 const std::vector<float>& desired_favicon_scales,
663 std::vector<favicon_base::FaviconRawBitmapResult>* results); 662 std::vector<favicon_base::FaviconRawBitmapResult>* results);
664 663
665 // Set the favicon bitmaps for |icon_id|. 664 // Set the favicon bitmaps for |icon_id|.
666 // For each entry in |favicon_bitmap_data|, if a favicon bitmap already 665 // For each entry in |favicon_bitmap_data|, if a favicon bitmap already
667 // exists at the entry's pixel size, replace the favicon bitmap's data with 666 // exists at the entry's pixel size, replace the favicon bitmap's data with
668 // the entry's bitmap data. Otherwise add a new favicon bitmap. 667 // the entry's bitmap data. Otherwise add a new favicon bitmap.
669 // Any favicon bitmaps already mapped to |icon_id| whose pixel sizes are not 668 // Any favicon bitmaps already mapped to |icon_id| whose pixel sizes are not
670 // in |favicon_bitmap_data| are deleted. 669 // in |favicon_bitmap_data| are deleted.
671 // If not NULL, |favicon_bitmaps_changed| is set to whether any of the bitmap 670 // If not NULL, |favicon_bitmaps_changed| is set to whether any of the bitmap
672 // data at |icon_id| is changed as a result of calling this method. 671 // data at |icon_id| is changed as a result of calling this method.
(...skipping 14 matching lines...) Expand all
687 favicon_base::FaviconRawBitmapData>& favicon_bitmap_data) const; 686 favicon_base::FaviconRawBitmapData>& favicon_bitmap_data) const;
688 687
689 // Returns true if the bitmap data at |bitmap_id| equals |new_bitmap_data|. 688 // Returns true if the bitmap data at |bitmap_id| equals |new_bitmap_data|.
690 bool IsFaviconBitmapDataEqual( 689 bool IsFaviconBitmapDataEqual(
691 FaviconBitmapID bitmap_id, 690 FaviconBitmapID bitmap_id,
692 const scoped_refptr<base::RefCountedMemory>& new_bitmap_data); 691 const scoped_refptr<base::RefCountedMemory>& new_bitmap_data);
693 692
694 // Returns true if there are favicons for |page_url| and one of the types in 693 // Returns true if there are favicons for |page_url| and one of the types in
695 // |icon_types|. 694 // |icon_types|.
696 // |favicon_bitmap_results| is set to the favicon bitmaps which most closely 695 // |favicon_bitmap_results| is set to the favicon bitmaps which most closely
697 // match |desired_size_in_dip| and |desired_scale_factors|. If 696 // match |desired_size_in_dip| and |desired_favicon_scales|. If
698 // |desired_size_in_dip| is 0, the largest favicon bitmap with one of the icon 697 // |desired_size_in_dip| is 0, the largest favicon bitmap with one of the icon
699 // types in |icon_types| is returned. If |icon_types| contains multiple icon 698 // types in |icon_types| is returned. If |icon_types| contains multiple icon
700 // types and there are several matched icon types in the database, results 699 // types and there are several matched icon types in the database, results
701 // will only be returned for a single icon type in the priority of 700 // will only be returned for a single icon type in the priority of
702 // TOUCH_PRECOMPOSED_ICON, TOUCH_ICON, and FAVICON. See the comment for 701 // TOUCH_PRECOMPOSED_ICON, TOUCH_ICON, and FAVICON. See the comment for
703 // GetFaviconResultsForBestMatch() for more details on how 702 // GetFaviconResultsForBestMatch() for more details on how
704 // |favicon_bitmap_results| is constructed. 703 // |favicon_bitmap_results| is constructed.
705 bool GetFaviconsFromDB( 704 bool GetFaviconsFromDB(const GURL& page_url,
706 const GURL& page_url, 705 int icon_types,
707 int icon_types, 706 const int desired_size_in_dip,
708 const int desired_size_in_dip, 707 const std::vector<float>& desired_favicon_scales,
709 const std::vector<ui::ScaleFactor>& desired_scale_factors, 708 std::vector<favicon_base::FaviconRawBitmapResult>*
710 std::vector<favicon_base::FaviconRawBitmapResult>* 709 favicon_bitmap_results);
711 favicon_bitmap_results);
712 710
713 // Returns the favicon bitmaps which most closely match |desired_size_in_dip| 711 // Returns the favicon bitmaps which most closely match |desired_size_in_dip|
714 // and |desired_scale_factors| in |favicon_bitmap_results|. If 712 // and |desired_favicon_scales| in |favicon_bitmap_results|. If
715 // |desired_size_in_dip| is 0, only the largest favicon bitmap is returned. 713 // |desired_size_in_dip| is 0, only the largest favicon bitmap is returned.
716 // Goodness is computed via SelectFaviconBitmapIDs(). It is computed on a 714 // Goodness is computed via SelectFaviconBitmapIDs(). It is computed on a
717 // per favicon id basis, thus all |favicon_bitmap_results| are guaranteed to 715 // per favicon id basis, thus all |favicon_bitmap_results| are guaranteed to
718 // be for the same FaviconID. |favicon_bitmap_results| will have at most one 716 // be for the same FaviconID. |favicon_bitmap_results| will have at most one
719 // entry for each desired scale factor. There will be less entries if the same 717 // entry for each desired scale factor. There will be less entries if the same
720 // favicon bitmap is the best result for multiple scale factors. 718 // favicon bitmap is the best result for multiple scale factors.
721 // Returns true if there were no errors. 719 // Returns true if there were no errors.
722 bool GetFaviconBitmapResultsForBestMatch( 720 bool GetFaviconBitmapResultsForBestMatch(
723 const std::vector<favicon_base::FaviconID>& candidate_favicon_ids, 721 const std::vector<favicon_base::FaviconID>& candidate_favicon_ids,
724 int desired_size_in_dip, 722 int desired_size_in_dip,
725 const std::vector<ui::ScaleFactor>& desired_scale_factors, 723 const std::vector<float>& desired_favicon_scales,
726 std::vector<favicon_base::FaviconRawBitmapResult>* 724 std::vector<favicon_base::FaviconRawBitmapResult>*
727 favicon_bitmap_results); 725 favicon_bitmap_results);
728 726
729 // Maps the favicon ids in |icon_ids| to |page_url| (and all redirects) 727 // Maps the favicon ids in |icon_ids| to |page_url| (and all redirects)
730 // for |icon_type|. 728 // for |icon_type|.
731 // Returns true if the mappings for the page or any of its redirects were 729 // Returns true if the mappings for the page or any of its redirects were
732 // changed. 730 // changed.
733 bool SetFaviconMappingsForPageAndRedirects( 731 bool SetFaviconMappingsForPageAndRedirects(
734 const GURL& page_url, 732 const GURL& page_url,
735 favicon_base::IconType icon_type, 733 favicon_base::IconType icon_type,
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 879
882 // Listens for the system being under memory pressure. 880 // Listens for the system being under memory pressure.
883 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; 881 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_;
884 882
885 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); 883 DISALLOW_COPY_AND_ASSIGN(HistoryBackend);
886 }; 884 };
887 885
888 } // namespace history 886 } // namespace history
889 887
890 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ 888 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698