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

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

Issue 330603004: Rename FaviconBitmapXxx to FaviconRawBitmapXxx (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>
(...skipping 27 matching lines...) Expand all
38 class HistoryClient; 38 class HistoryClient;
39 class VisitFilter; 39 class VisitFilter;
40 struct DownloadRow; 40 struct DownloadRow;
41 41
42 // The maximum number of icons URLs per page which can be stored in the 42 // The maximum number of icons URLs per page which can be stored in the
43 // thumbnail database. 43 // thumbnail database.
44 static const size_t kMaxFaviconsPerPage = 8; 44 static const size_t kMaxFaviconsPerPage = 8;
45 45
46 // The maximum number of bitmaps for a single icon URL which can be stored in 46 // The maximum number of bitmaps for a single icon URL which can be stored in
47 // the thumbnail database. 47 // the thumbnail database.
48 static const size_t kMaxFaviconBitmapsPerIconURL = 8; 48 static const size_t kMaxFaviconRawBitmapsPerIconURL = 8;
49 49
50 // *See the .cc file for more information on the design.* 50 // *See the .cc file for more information on the design.*
51 // 51 //
52 // Internal history implementation which does most of the work of the history 52 // Internal history implementation which does most of the work of the history
53 // system. This runs on a background thread (to not block the browser when we 53 // system. This runs on a background thread (to not block the browser when we
54 // do expensive operations) and is NOT threadsafe, so it must only be called 54 // do expensive operations) and is NOT threadsafe, so it must only be called
55 // from message handlers on the background thread. Invoking on another thread 55 // from message handlers on the background thread. Invoking on another thread
56 // requires threadsafe refcounting. 56 // requires threadsafe refcounting.
57 // 57 //
58 // Most functions here are just the implementations of the corresponding 58 // Most functions here are just the implementations of the corresponding
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 bool GetMostRecentRedirectsTo(const GURL& url, 209 bool GetMostRecentRedirectsTo(const GURL& url,
210 history::RedirectList* redirects); 210 history::RedirectList* redirects);
211 211
212 // Favicon ------------------------------------------------------------------- 212 // Favicon -------------------------------------------------------------------
213 213
214 void GetFavicons( 214 void GetFavicons(
215 const std::vector<GURL>& icon_urls, 215 const std::vector<GURL>& icon_urls,
216 int icon_types, 216 int icon_types,
217 int desired_size_in_dip, 217 int desired_size_in_dip,
218 const std::vector<ui::ScaleFactor>& desired_scale_factors, 218 const std::vector<ui::ScaleFactor>& desired_scale_factors,
219 std::vector<favicon_base::FaviconBitmapResult>* bitmap_results); 219 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results);
220 220
221 void GetLargestFaviconForURL( 221 void GetLargestFaviconForURL(
222 const GURL& page_url, 222 const GURL& page_url,
223 const std::vector<int>& icon_types, 223 const std::vector<int>& icon_types,
224 int minimum_size_in_pixels, 224 int minimum_size_in_pixels,
225 favicon_base::FaviconBitmapResult* bitmap_result); 225 favicon_base::FaviconRawBitmapResult* bitmap_result);
226 226
227 void GetFaviconsForURL( 227 void GetFaviconsForURL(
228 const GURL& page_url, 228 const GURL& page_url,
229 int icon_types, 229 int icon_types,
230 int desired_size_in_dip, 230 int desired_size_in_dip,
231 const std::vector<ui::ScaleFactor>& desired_scale_factors, 231 const std::vector<ui::ScaleFactor>& desired_scale_factors,
232 std::vector<favicon_base::FaviconBitmapResult>* bitmap_results); 232 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results);
233 233
234 void GetFaviconForID( 234 void GetFaviconForID(
235 favicon_base::FaviconID favicon_id, 235 favicon_base::FaviconID favicon_id,
236 int desired_size_in_dip, 236 int desired_size_in_dip,
237 ui::ScaleFactor desired_scale_factor, 237 ui::ScaleFactor desired_scale_factor,
238 std::vector<favicon_base::FaviconBitmapResult>* bitmap_results); 238 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results);
239 239
240 void UpdateFaviconMappingsAndFetch( 240 void UpdateFaviconMappingsAndFetch(
241 const GURL& page_url, 241 const GURL& page_url,
242 const std::vector<GURL>& icon_urls, 242 const std::vector<GURL>& icon_urls,
243 int icon_types, 243 int icon_types,
244 int desired_size_in_dip, 244 int desired_size_in_dip,
245 const std::vector<ui::ScaleFactor>& desired_scale_factors, 245 const std::vector<ui::ScaleFactor>& desired_scale_factors,
246 std::vector<favicon_base::FaviconBitmapResult>* bitmap_results); 246 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results);
247 247
248 void MergeFavicon(const GURL& page_url, 248 void MergeFavicon(const GURL& page_url,
249 const GURL& icon_url, 249 const GURL& icon_url,
250 favicon_base::IconType icon_type, 250 favicon_base::IconType icon_type,
251 scoped_refptr<base::RefCountedMemory> bitmap_data, 251 scoped_refptr<base::RefCountedMemory> bitmap_data,
252 const gfx::Size& pixel_size); 252 const gfx::Size& pixel_size);
253 253
254 void SetFavicons( 254 void SetFavicons(const GURL& page_url,
255 const GURL& page_url, 255 favicon_base::IconType icon_type,
256 favicon_base::IconType icon_type, 256 const std::vector<favicon_base::FaviconRawBitmapData>&
257 const std::vector<favicon_base::FaviconBitmapData>& favicon_bitmap_data); 257 favicon_bitmap_data);
258 258
259 void SetFaviconsOutOfDateForPage(const GURL& page_url); 259 void SetFaviconsOutOfDateForPage(const GURL& page_url);
260 260
261 void CloneFavicons(const GURL& old_page_url, const GURL& new_page_url); 261 void CloneFavicons(const GURL& old_page_url, const GURL& new_page_url);
262 262
263 void SetImportedFavicons( 263 void SetImportedFavicons(
264 const std::vector<ImportedFaviconUsage>& favicon_usage); 264 const std::vector<ImportedFaviconUsage>& favicon_usage);
265 265
266 // Downloads ----------------------------------------------------------------- 266 // Downloads -----------------------------------------------------------------
267 267
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 496 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
497 SetFaviconsSameFaviconURLForTwoPages); 497 SetFaviconsSameFaviconURLForTwoPages);
498 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 498 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
499 UpdateFaviconMappingsAndFetchNoChange); 499 UpdateFaviconMappingsAndFetchNoChange);
500 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconPageURLNotInDB); 500 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconPageURLNotInDB);
501 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconPageURLInDB); 501 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconPageURLInDB);
502 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconMaxFaviconsPerPage); 502 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MergeFaviconMaxFaviconsPerPage);
503 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 503 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
504 MergeFaviconIconURLMappedToDifferentPageURL); 504 MergeFaviconIconURLMappedToDifferentPageURL);
505 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 505 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
506 MergeFaviconMaxFaviconBitmapsPerIconURL); 506 MergeFaviconMaxFaviconRawBitmapsPerIconURL);
507 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 507 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
508 UpdateFaviconMappingsAndFetchMultipleIconTypes); 508 UpdateFaviconMappingsAndFetchMultipleIconTypes);
509 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBEmpty); 509 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBEmpty);
510 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 510 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
511 GetFaviconsFromDBNoFaviconBitmaps); 511 GetFaviconsFromDBNoFaviconRawBitmaps);
512 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 512 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
513 GetFaviconsFromDBSelectClosestMatch); 513 GetFaviconsFromDBSelectClosestMatch);
514 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBSingleIconURL); 514 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBSingleIconURL);
515 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBIconType); 515 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBIconType);
516 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBExpired); 516 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, GetFaviconsFromDBExpired);
517 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 517 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
518 UpdateFaviconMappingsAndFetchNoDB); 518 UpdateFaviconMappingsAndFetchNoDB);
519 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, 519 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest,
520 CloneFaviconIsRestrictedToSameDomain); 520 CloneFaviconIsRestrictedToSameDomain);
521 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs); 521 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, QueryFilteredURLs);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 // If |page_url| is non-null, |icon_types| can be multiple icon types 645 // If |page_url| is non-null, |icon_types| can be multiple icon types
646 // only if |icon_types| == TOUCH_ICON | TOUCH_PRECOMPOSED_ICON. 646 // only if |icon_types| == TOUCH_ICON | TOUCH_PRECOMPOSED_ICON.
647 // If multiple icon types are specified, |page_url| will be mapped to the 647 // If multiple icon types are specified, |page_url| will be mapped to the
648 // icon URLs of the largest type available in the database. 648 // icon URLs of the largest type available in the database.
649 void UpdateFaviconMappingsAndFetchImpl( 649 void UpdateFaviconMappingsAndFetchImpl(
650 const GURL* page_url, 650 const GURL* page_url,
651 const std::vector<GURL>& icon_urls, 651 const std::vector<GURL>& icon_urls,
652 int icon_types, 652 int icon_types,
653 int desired_size_in_dip, 653 int desired_size_in_dip,
654 const std::vector<ui::ScaleFactor>& desired_scale_factors, 654 const std::vector<ui::ScaleFactor>& desired_scale_factors,
655 std::vector<favicon_base::FaviconBitmapResult>* results); 655 std::vector<favicon_base::FaviconRawBitmapResult>* results);
656 656
657 // Set the favicon bitmaps for |icon_id|. 657 // Set the favicon bitmaps for |icon_id|.
658 // For each entry in |favicon_bitmap_data|, if a favicon bitmap already 658 // For each entry in |favicon_bitmap_data|, if a favicon bitmap already
659 // exists at the entry's pixel size, replace the favicon bitmap's data with 659 // exists at the entry's pixel size, replace the favicon bitmap's data with
660 // the entry's bitmap data. Otherwise add a new favicon bitmap. 660 // the entry's bitmap data. Otherwise add a new favicon bitmap.
661 // Any favicon bitmaps already mapped to |icon_id| whose pixel sizes are not 661 // Any favicon bitmaps already mapped to |icon_id| whose pixel sizes are not
662 // in |favicon_bitmap_data| are deleted. 662 // in |favicon_bitmap_data| are deleted.
663 // If not NULL, |favicon_bitmaps_changed| is set to whether any of the bitmap 663 // If not NULL, |favicon_bitmaps_changed| is set to whether any of the bitmap
664 // data at |icon_id| is changed as a result of calling this method. 664 // data at |icon_id| is changed as a result of calling this method.
665 // Computing |favicon_bitmaps_changed| requires additional database queries 665 // Computing |favicon_bitmaps_changed| requires additional database queries
666 // so should be avoided if unnecessary. 666 // so should be avoided if unnecessary.
667 void SetFaviconBitmaps( 667 void SetFaviconRawBitmaps(
668 favicon_base::FaviconID icon_id, 668 favicon_base::FaviconID icon_id,
669 const std::vector<favicon_base::FaviconBitmapData>& favicon_bitmap_data, 669 const std::vector<favicon_base::FaviconRawBitmapData>&
670 favicon_bitmap_data,
670 bool* favicon_bitmaps_changed); 671 bool* favicon_bitmaps_changed);
671 672
672 // Returns true if |favicon_bitmap_data| passed to SetFavicons() is valid. 673 // Returns true if |favicon_bitmap_data| passed to SetFavicons() is valid.
673 // Criteria: 674 // Criteria:
674 // 1) |favicon_bitmap_data| contains no more than 675 // 1) |favicon_bitmap_data| contains no more than
675 // kMaxFaviconsPerPage unique icon URLs. 676 // kMaxFaviconsPerPage unique icon URLs.
676 // kMaxFaviconBitmapsPerIconURL favicon bitmaps for each icon URL. 677 // kMaxFaviconRawBitmapsPerIconURL favicon bitmaps for each icon URL.
677 // 2) FaviconBitmapData::bitmap_data contains non NULL bitmap data. 678 // 2) FaviconRawBitmapData::bitmap_data contains non NULL bitmap data.
678 bool ValidateSetFaviconsParams(const std::vector< 679 bool ValidateSetFaviconsParams(const std::vector<
679 favicon_base::FaviconBitmapData>& favicon_bitmap_data) const; 680 favicon_base::FaviconRawBitmapData>& favicon_bitmap_data) const;
680 681
681 // Returns true if the bitmap data at |bitmap_id| equals |new_bitmap_data|. 682 // Returns true if the bitmap data at |bitmap_id| equals |new_bitmap_data|.
682 bool IsFaviconBitmapDataEqual( 683 bool IsFaviconRawBitmapDataEqual(
683 FaviconBitmapID bitmap_id, 684 FaviconRawBitmapID bitmap_id,
684 const scoped_refptr<base::RefCountedMemory>& new_bitmap_data); 685 const scoped_refptr<base::RefCountedMemory>& new_bitmap_data);
685 686
686 // Returns true if there are favicons for |page_url| and one of the types in 687 // Returns true if there are favicons for |page_url| and one of the types in
687 // |icon_types|. 688 // |icon_types|.
688 // |favicon_bitmap_results| is set to the favicon bitmaps which most closely 689 // |favicon_bitmap_results| is set to the favicon bitmaps which most closely
689 // match |desired_size_in_dip| and |desired_scale_factors|. If 690 // match |desired_size_in_dip| and |desired_scale_factors|. If
690 // |desired_size_in_dip| is 0, the largest favicon bitmap with one of the icon 691 // |desired_size_in_dip| is 0, the largest favicon bitmap with one of the icon
691 // types in |icon_types| is returned. If |icon_types| contains multiple icon 692 // types in |icon_types| is returned. If |icon_types| contains multiple icon
692 // types and there are several matched icon types in the database, results 693 // types and there are several matched icon types in the database, results
693 // will only be returned for a single icon type in the priority of 694 // will only be returned for a single icon type in the priority of
694 // TOUCH_PRECOMPOSED_ICON, TOUCH_ICON, and FAVICON. See the comment for 695 // TOUCH_PRECOMPOSED_ICON, TOUCH_ICON, and FAVICON. See the comment for
695 // GetFaviconResultsForBestMatch() for more details on how 696 // GetFaviconResultsForBestMatch() for more details on how
696 // |favicon_bitmap_results| is constructed. 697 // |favicon_bitmap_results| is constructed.
697 bool GetFaviconsFromDB( 698 bool GetFaviconsFromDB(
698 const GURL& page_url, 699 const GURL& page_url,
699 int icon_types, 700 int icon_types,
700 const int desired_size_in_dip, 701 const int desired_size_in_dip,
701 const std::vector<ui::ScaleFactor>& desired_scale_factors, 702 const std::vector<ui::ScaleFactor>& desired_scale_factors,
702 std::vector<favicon_base::FaviconBitmapResult>* favicon_bitmap_results); 703 std::vector<favicon_base::FaviconRawBitmapResult>*
704 favicon_bitmap_results);
703 705
704 // Returns the favicon bitmaps which most closely match |desired_size_in_dip| 706 // Returns the favicon bitmaps which most closely match |desired_size_in_dip|
705 // and |desired_scale_factors| in |favicon_bitmap_results|. If 707 // and |desired_scale_factors| in |favicon_bitmap_results|. If
706 // |desired_size_in_dip| is 0, only the largest favicon bitmap is returned. 708 // |desired_size_in_dip| is 0, only the largest favicon bitmap is returned.
707 // Goodness is computed via SelectFaviconBitmapIDs(). It is computed on a 709 // Goodness is computed via SelectFaviconRawBitmapIDs(). It is computed on a
708 // per favicon id basis, thus all |favicon_bitmap_results| are guaranteed to 710 // per favicon id basis, thus all |favicon_bitmap_results| are guaranteed to
709 // be for the same FaviconID. |favicon_bitmap_results| will have at most one 711 // be for the same FaviconID. |favicon_bitmap_results| will have at most one
710 // entry for each desired scale factor. There will be less entries if the same 712 // entry for each desired scale factor. There will be less entries if the same
711 // favicon bitmap is the best result for multiple scale factors. 713 // favicon bitmap is the best result for multiple scale factors.
712 // Returns true if there were no errors. 714 // Returns true if there were no errors.
713 bool GetFaviconBitmapResultsForBestMatch( 715 bool GetFaviconRawBitmapResultsForBestMatch(
714 const std::vector<favicon_base::FaviconID>& candidate_favicon_ids, 716 const std::vector<favicon_base::FaviconID>& candidate_favicon_ids,
715 int desired_size_in_dip, 717 int desired_size_in_dip,
716 const std::vector<ui::ScaleFactor>& desired_scale_factors, 718 const std::vector<ui::ScaleFactor>& desired_scale_factors,
717 std::vector<favicon_base::FaviconBitmapResult>* favicon_bitmap_results); 719 std::vector<favicon_base::FaviconRawBitmapResult>*
720 favicon_bitmap_results);
718 721
719 // Maps the favicon ids in |icon_ids| to |page_url| (and all redirects) 722 // Maps the favicon ids in |icon_ids| to |page_url| (and all redirects)
720 // for |icon_type|. 723 // for |icon_type|.
721 // Returns true if the mappings for the page or any of its redirects were 724 // Returns true if the mappings for the page or any of its redirects were
722 // changed. 725 // changed.
723 bool SetFaviconMappingsForPageAndRedirects( 726 bool SetFaviconMappingsForPageAndRedirects(
724 const GURL& page_url, 727 const GURL& page_url,
725 favicon_base::IconType icon_type, 728 favicon_base::IconType icon_type,
726 const std::vector<favicon_base::FaviconID>& icon_ids); 729 const std::vector<favicon_base::FaviconID>& icon_ids);
727 730
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 874
872 // Listens for the system being under memory pressure. 875 // Listens for the system being under memory pressure.
873 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; 876 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_;
874 877
875 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); 878 DISALLOW_COPY_AND_ASSIGN(HistoryBackend);
876 }; 879 };
877 880
878 } // namespace history 881 } // namespace history
879 882
880 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ 883 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698