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

Side by Side Diff: components/favicon/core/large_icon_service.h

Issue 2784233003: [LargeIconService] Allow decoding of images in the service (Closed)
Patch Set: Peter's comments #2 Created 3 years, 8 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_ 5 #ifndef COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_
6 #define COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_ 6 #define COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 30 matching lines...) Expand all
41 // Case 1. An icon exists whose size is >= |min_source_size_in_pixel|: 41 // Case 1. An icon exists whose size is >= |min_source_size_in_pixel|:
42 // - If |desired_size_in_pixel| == 0: returns icon as is. 42 // - If |desired_size_in_pixel| == 0: returns icon as is.
43 // - Else: returns the icon resized to |desired_size_in_pixel|. 43 // - Else: returns the icon resized to |desired_size_in_pixel|.
44 // Case 2. An icon exists whose size is < |min_source_size_in_pixel|: 44 // Case 2. An icon exists whose size is < |min_source_size_in_pixel|:
45 // - Extracts dominant color of smaller image, returns a fallback icon style 45 // - Extracts dominant color of smaller image, returns a fallback icon style
46 // that has a matching background. 46 // that has a matching background.
47 // Case 3. No icon exists. 47 // Case 3. No icon exists.
48 // - Returns the default fallback icon style. 48 // - Returns the default fallback icon style.
49 // For cases 2 and 3, this function returns the style of the fallback icon 49 // For cases 2 and 3, this function returns the style of the fallback icon
50 // instead of rendering an icon so clients can render the icon themselves. 50 // instead of rendering an icon so clients can render the icon themselves.
51 // TODO(jkrcal): Rename to GetLargeIconRawBitmapOrFallbackStyle.
51 base::CancelableTaskTracker::TaskId GetLargeIconOrFallbackStyle( 52 base::CancelableTaskTracker::TaskId GetLargeIconOrFallbackStyle(
52 const GURL& page_url, 53 const GURL& page_url,
53 int min_source_size_in_pixel, 54 int min_source_size_in_pixel,
54 int desired_size_in_pixel, 55 int desired_size_in_pixel,
55 const favicon_base::LargeIconCallback& callback, 56 const favicon_base::LargeIconCallback& callback,
56 base::CancelableTaskTracker* tracker); 57 base::CancelableTaskTracker* tracker);
58
59 // Behaves the same as GetLargeIconOrFallbackStyle, only returns the large
pkotwicz 2017/04/04 12:43:43 Nit: GetLargeIconOrFallbackStyle -> GetLargeIconOr
jkrcal 2017/04/04 14:44:40 Done.
60 // icon (if available) decoded.
61 base::CancelableTaskTracker::TaskId GetLargeIconImageOrFallbackStyle(
62 const GURL& page_url,
63 int min_source_size_in_pixel,
64 int desired_size_in_pixel,
65 const favicon_base::LargeIconImageCallback& callback,
66 base::CancelableTaskTracker* tracker);
57 67
58 // Fetches the best large icon for the page at |page_url| from a Google 68 // Fetches the best large icon for the page at |page_url| from a Google
59 // favicon server and stores the result in the FaviconService database 69 // favicon server and stores the result in the FaviconService database
60 // (implemented in HistoryService). The write will be a no-op if the local 70 // (implemented in HistoryService). The write will be a no-op if the local
61 // favicon database contains an icon for |page_url|, so clients are 71 // favicon database contains an icon for |page_url|, so clients are
62 // encouraged to use GetLargeIconOrFallbackStyle() first. 72 // encouraged to use GetLargeIconOrFallbackStyle() first.
63 // 73 //
64 // A minimum size |min_source_size_in_pixel| can be specified as a constraint. 74 // A minimum size |min_source_size_in_pixel| can be specified as a constraint.
65 // 75 //
66 // The callback is triggered when the operation finishes, where |success| 76 // The callback is triggered when the operation finishes, where |success|
67 // tells whether the fetch actually managed to database a new icon in the 77 // tells whether the fetch actually managed to database a new icon in the
68 // FaviconService. 78 // FaviconService.
69 // 79 //
70 // WARNING: This function will share the |page_url| with a Google server. This 80 // WARNING: This function will share the |page_url| with a Google server. This
71 // Can be used only for urls that are not privacy sensitive or for users that 81 // Can be used only for urls that are not privacy sensitive or for users that
72 // sync their history with Google servers. 82 // sync their history with Google servers.
73 void GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( 83 void GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache(
74 const GURL& page_url, 84 const GURL& page_url,
75 int min_source_size_in_pixel, 85 int min_source_size_in_pixel,
76 const base::Callback<void(bool success)>& callback); 86 const base::Callback<void(bool success)>& callback);
77 87
78 private: 88 private:
89 base::CancelableTaskTracker::TaskId GetLargeIconOrFallbackStyleImpl(
90 const GURL& page_url,
91 int min_source_size_in_pixel,
92 int desired_size_in_pixel,
93 const favicon_base::LargeIconCallback& raw_bitmap_callback,
94 const favicon_base::LargeIconImageCallback& image_callback,
95 base::CancelableTaskTracker* tracker);
96
79 FaviconService* favicon_service_; 97 FaviconService* favicon_service_;
80 scoped_refptr<base::TaskRunner> background_task_runner_; 98 scoped_refptr<base::TaskRunner> background_task_runner_;
81 99
82 // A pre-populated list of icon types to consider when looking for large 100 // A pre-populated list of icon types to consider when looking for large
83 // icons. This is an optimization over populating an icon type vector on each 101 // icons. This is an optimization over populating an icon type vector on each
84 // request. 102 // request.
85 std::vector<int> large_icon_types_; 103 std::vector<int> large_icon_types_;
86 104
87 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher_; 105 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher_;
88 106
89 DISALLOW_COPY_AND_ASSIGN(LargeIconService); 107 DISALLOW_COPY_AND_ASSIGN(LargeIconService);
90 }; 108 };
91 109
92 } // namespace favicon 110 } // namespace favicon
93 111
94 #endif // COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_ 112 #endif // COMPONENTS_FAVICON_CORE_LARGE_ICON_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | components/favicon/core/large_icon_service.cc » ('j') | components/favicon/core/large_icon_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698