OLD | NEW |
---|---|
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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 // given RedirectList. For example, if we have the redirect list A -> B -> C, | 214 // given RedirectList. For example, if we have the redirect list A -> B -> C, |
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 const std::vector<int>& desired_sizes, |
226 const std::vector<ui::ScaleFactor>& desired_scale_factors, | |
227 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results); | 225 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results); |
228 | 226 |
229 void GetLargestFaviconForURL( | 227 void GetLargestFaviconForURL( |
230 const GURL& page_url, | 228 const GURL& page_url, |
231 const std::vector<int>& icon_types, | 229 const std::vector<int>& icon_types, |
232 int minimum_size_in_pixels, | 230 int minimum_size_in_pixels, |
233 favicon_base::FaviconRawBitmapResult* bitmap_result); | 231 favicon_base::FaviconRawBitmapResult* bitmap_result); |
234 | 232 |
235 void GetFaviconsForURL( | 233 void GetFaviconsForURL( |
236 const GURL& page_url, | 234 const GURL& page_url, |
237 int icon_types, | 235 int icon_types, |
238 int desired_size_in_dip, | 236 const std::vector<int>& desired_sizes, |
239 const std::vector<ui::ScaleFactor>& desired_scale_factors, | |
240 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results); | 237 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results); |
241 | 238 |
242 void GetFaviconForID( | 239 void GetFaviconForID( |
243 favicon_base::FaviconID favicon_id, | 240 favicon_base::FaviconID favicon_id, |
244 int desired_size_in_dip, | 241 int desired_size, |
245 ui::ScaleFactor desired_scale_factor, | |
246 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results); | 242 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results); |
247 | 243 |
248 void UpdateFaviconMappingsAndFetch( | 244 void UpdateFaviconMappingsAndFetch( |
249 const GURL& page_url, | 245 const GURL& page_url, |
250 const std::vector<GURL>& icon_urls, | 246 const std::vector<GURL>& icon_urls, |
251 int icon_types, | 247 int icon_types, |
252 int desired_size_in_dip, | 248 const std::vector<int>& desired_sizes, |
253 const std::vector<ui::ScaleFactor>& desired_scale_factors, | |
254 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results); | 249 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results); |
255 | 250 |
256 void MergeFavicon(const GURL& page_url, | 251 void MergeFavicon(const GURL& page_url, |
257 const GURL& icon_url, | 252 const GURL& icon_url, |
258 favicon_base::IconType icon_type, | 253 favicon_base::IconType icon_type, |
259 scoped_refptr<base::RefCountedMemory> bitmap_data, | 254 scoped_refptr<base::RefCountedMemory> bitmap_data, |
260 const gfx::Size& pixel_size); | 255 const gfx::Size& pixel_size); |
261 | 256 |
262 void SetFavicons(const GURL& page_url, | 257 void SetFavicons(const GURL& page_url, |
263 favicon_base::IconType icon_type, | 258 favicon_base::IconType icon_type, |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
651 // redirects) are set to the subset of |icon_urls| for which icons are | 646 // redirects) are set to the subset of |icon_urls| for which icons are |
652 // already stored in the database. | 647 // already stored in the database. |
653 // If |page_url| is non-null, |icon_types| can be multiple icon types | 648 // If |page_url| is non-null, |icon_types| can be multiple icon types |
654 // only if |icon_types| == TOUCH_ICON | TOUCH_PRECOMPOSED_ICON. | 649 // only if |icon_types| == TOUCH_ICON | TOUCH_PRECOMPOSED_ICON. |
655 // If multiple icon types are specified, |page_url| will be mapped to the | 650 // If multiple icon types are specified, |page_url| will be mapped to the |
656 // icon URLs of the largest type available in the database. | 651 // icon URLs of the largest type available in the database. |
657 void UpdateFaviconMappingsAndFetchImpl( | 652 void UpdateFaviconMappingsAndFetchImpl( |
658 const GURL* page_url, | 653 const GURL* page_url, |
659 const std::vector<GURL>& icon_urls, | 654 const std::vector<GURL>& icon_urls, |
660 int icon_types, | 655 int icon_types, |
661 int desired_size_in_dip, | 656 const std::vector<int>& desired_sizes, |
662 const std::vector<ui::ScaleFactor>& desired_scale_factors, | |
663 std::vector<favicon_base::FaviconRawBitmapResult>* results); | 657 std::vector<favicon_base::FaviconRawBitmapResult>* results); |
664 | 658 |
665 // Set the favicon bitmaps for |icon_id|. | 659 // Set the favicon bitmaps for |icon_id|. |
666 // For each entry in |favicon_bitmap_data|, if a favicon bitmap already | 660 // 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 | 661 // 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. | 662 // 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 | 663 // Any favicon bitmaps already mapped to |icon_id| whose pixel sizes are not |
670 // in |favicon_bitmap_data| are deleted. | 664 // in |favicon_bitmap_data| are deleted. |
671 // If not NULL, |favicon_bitmaps_changed| is set to whether any of the bitmap | 665 // 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. | 666 // data at |icon_id| is changed as a result of calling this method. |
(...skipping 13 matching lines...) Expand all Loading... | |
686 bool ValidateSetFaviconsParams(const std::vector< | 680 bool ValidateSetFaviconsParams(const std::vector< |
687 favicon_base::FaviconRawBitmapData>& favicon_bitmap_data) const; | 681 favicon_base::FaviconRawBitmapData>& favicon_bitmap_data) const; |
688 | 682 |
689 // Returns true if the bitmap data at |bitmap_id| equals |new_bitmap_data|. | 683 // Returns true if the bitmap data at |bitmap_id| equals |new_bitmap_data|. |
690 bool IsFaviconBitmapDataEqual( | 684 bool IsFaviconBitmapDataEqual( |
691 FaviconBitmapID bitmap_id, | 685 FaviconBitmapID bitmap_id, |
692 const scoped_refptr<base::RefCountedMemory>& new_bitmap_data); | 686 const scoped_refptr<base::RefCountedMemory>& new_bitmap_data); |
693 | 687 |
694 // Returns true if there are favicons for |page_url| and one of the types in | 688 // Returns true if there are favicons for |page_url| and one of the types in |
695 // |icon_types|. | 689 // |icon_types|. |
696 // |favicon_bitmap_results| is set to the favicon bitmaps which most closely | 690 // |favicon_bitmap_results| is set to the favicon bitmaps whose edge sizes |
697 // match |desired_size_in_dip| and |desired_scale_factors|. If | 691 // most closely match |desired_sizes|. If |desired_sizes| has a '0' entry, the |
sky
2014/06/18 22:16:51
Would an empty vector be a better way to indicate
pkotwicz
2014/06/18 23:32:02
Yes! But in a subsequent CL. I added a TODO in sel
| |
698 // |desired_size_in_dip| is 0, the largest favicon bitmap with one of the icon | 692 // largest favicon bitmap with one of the icon types in |icon_types| is |
699 // types in |icon_types| is returned. If |icon_types| contains multiple icon | 693 // returned. If |icon_types| contains multiple icon types and there are |
700 // types and there are several matched icon types in the database, results | 694 // several matched icon types in the database, results will only be returned |
701 // will only be returned for a single icon type in the priority of | 695 // for a single icon type in the priority of TOUCH_PRECOMPOSED_ICON, |
702 // TOUCH_PRECOMPOSED_ICON, TOUCH_ICON, and FAVICON. See the comment for | 696 // TOUCH_ICON, and FAVICON. See the comment for |
703 // GetFaviconResultsForBestMatch() for more details on how | 697 // GetFaviconResultsForBestMatch() for more details on how |
704 // |favicon_bitmap_results| is constructed. | 698 // |favicon_bitmap_results| is constructed. |
705 bool GetFaviconsFromDB( | 699 bool GetFaviconsFromDB( |
706 const GURL& page_url, | 700 const GURL& page_url, |
707 int icon_types, | 701 int icon_types, |
708 const int desired_size_in_dip, | 702 const std::vector<int>& desired_sizes, |
709 const std::vector<ui::ScaleFactor>& desired_scale_factors, | |
710 std::vector<favicon_base::FaviconRawBitmapResult>* | 703 std::vector<favicon_base::FaviconRawBitmapResult>* |
711 favicon_bitmap_results); | 704 favicon_bitmap_results); |
712 | 705 |
713 // Returns the favicon bitmaps which most closely match |desired_size_in_dip| | 706 // Returns the favicon bitmaps whose edge sizes most closely match |
714 // and |desired_scale_factors| in |favicon_bitmap_results|. If | 707 // |desired_sizes| in |favicon_bitmap_results|. If |desired_sizes| has a '0' |
715 // |desired_size_in_dip| is 0, only the largest favicon bitmap is returned. | 708 // entry, only the largest favicon bitmap is returned. Goodness is computed |
716 // Goodness is computed via SelectFaviconBitmapIDs(). It is computed on a | 709 // via SelectFaviconFrameIndices(). It is computed on a per FaviconID basis, |
717 // per favicon id basis, thus all |favicon_bitmap_results| are guaranteed to | 710 // thus all |favicon_bitmap_results| are guaranteed to be for the same |
718 // be for the same FaviconID. |favicon_bitmap_results| will have at most one | 711 // FaviconID. |favicon_bitmap_results| will have at most one entry for each |
719 // entry for each desired scale factor. There will be less entries if the same | 712 // desired edge size. There will be fewer entries if the same favicon bitmap |
720 // favicon bitmap is the best result for multiple scale factors. | 713 // is the best result for multiple edge sizes. |
721 // Returns true if there were no errors. | 714 // Returns true if there were no errors. |
722 bool GetFaviconBitmapResultsForBestMatch( | 715 bool GetFaviconBitmapResultsForBestMatch( |
723 const std::vector<favicon_base::FaviconID>& candidate_favicon_ids, | 716 const std::vector<favicon_base::FaviconID>& candidate_favicon_ids, |
724 int desired_size_in_dip, | 717 const std::vector<int>& desired_sizes, |
725 const std::vector<ui::ScaleFactor>& desired_scale_factors, | |
726 std::vector<favicon_base::FaviconRawBitmapResult>* | 718 std::vector<favicon_base::FaviconRawBitmapResult>* |
727 favicon_bitmap_results); | 719 favicon_bitmap_results); |
728 | 720 |
729 // Maps the favicon ids in |icon_ids| to |page_url| (and all redirects) | 721 // Maps the favicon ids in |icon_ids| to |page_url| (and all redirects) |
730 // for |icon_type|. | 722 // for |icon_type|. |
731 // Returns true if the mappings for the page or any of its redirects were | 723 // Returns true if the mappings for the page or any of its redirects were |
732 // changed. | 724 // changed. |
733 bool SetFaviconMappingsForPageAndRedirects( | 725 bool SetFaviconMappingsForPageAndRedirects( |
734 const GURL& page_url, | 726 const GURL& page_url, |
735 favicon_base::IconType icon_type, | 727 favicon_base::IconType icon_type, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
881 | 873 |
882 // Listens for the system being under memory pressure. | 874 // Listens for the system being under memory pressure. |
883 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; | 875 scoped_ptr<base::MemoryPressureListener> memory_pressure_listener_; |
884 | 876 |
885 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); | 877 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
886 }; | 878 }; |
887 | 879 |
888 } // namespace history | 880 } // namespace history |
889 | 881 |
890 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ | 882 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
OLD | NEW |