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

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

Issue 2738663002: FaviconHandler test rewrite
Patch Set: Merge branch 'mastiz_cl' into favicon_handler_unittest2 Created 3 years, 9 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 (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 COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ 5 #ifndef COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_
6 #define COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ 6 #define COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 virtual ~FaviconHandler(); 124 virtual ~FaviconHandler();
125 125
126 // Initiates loading the favicon for the specified url. 126 // Initiates loading the favicon for the specified url.
127 void FetchFavicon(const GURL& url); 127 void FetchFavicon(const GURL& url);
128 128
129 // Message Handler. Must be public, because also called from 129 // Message Handler. Must be public, because also called from
130 // PrerenderContents. Collects the |image_urls| list. 130 // PrerenderContents. Collects the |image_urls| list.
131 void OnUpdateFaviconURL(const GURL& page_url, 131 void OnUpdateFaviconURL(const GURL& page_url,
132 const std::vector<favicon::FaviconURL>& candidates); 132 const std::vector<favicon::FaviconURL>& candidates);
133 133
134 // Get the maximal icon size in pixels for a icon of type |icon_type| for the
135 // current platform. Public for testing.
136 static int GetMaximalIconSize(favicon_base::IconType icon_type);
137
134 // For testing. 138 // For testing.
135 const std::vector<favicon::FaviconURL>& image_urls() const { 139 const std::vector<favicon::FaviconURL>& image_urls() const {
136 return image_urls_; 140 return image_urls_;
137 } 141 }
138 142
139 // Returns whether the handler is waiting for a download to complete or for 143 // Returns whether the handler is waiting for a download to complete or for
140 // data from the FaviconService. Reserved for testing. 144 // data from the FaviconService. Reserved for testing.
141 bool HasPendingTasksForTest(); 145 bool HasPendingTasksForTest();
142 146
143 protected: 147 protected:
(...skipping 22 matching lines...) Expand all
166 170
167 virtual void SetHistoryFavicons(const GURL& page_url, 171 virtual void SetHistoryFavicons(const GURL& page_url,
168 const GURL& icon_url, 172 const GURL& icon_url,
169 favicon_base::IconType icon_type, 173 favicon_base::IconType icon_type,
170 const gfx::Image& image); 174 const gfx::Image& image);
171 175
172 // Returns true if the favicon should be saved. 176 // Returns true if the favicon should be saved.
173 virtual bool ShouldSaveFavicon(); 177 virtual bool ShouldSaveFavicon();
174 178
175 private: 179 private:
176 // For testing:
177 friend class TestFaviconHandler;
178
179 // Represents an in progress download of an image from the renderer. 180 // Represents an in progress download of an image from the renderer.
180 struct DownloadRequest { 181 struct DownloadRequest {
181 DownloadRequest(); 182 DownloadRequest();
182 ~DownloadRequest(); 183 ~DownloadRequest();
183 184
184 DownloadRequest(const GURL& image_url, favicon_base::IconType icon_type); 185 DownloadRequest(const GURL& image_url, favicon_base::IconType icon_type);
185 186
186 GURL image_url; 187 GURL image_url;
187 favicon_base::IconType icon_type; 188 favicon_base::IconType icon_type;
188 }; 189 };
(...skipping 11 matching lines...) Expand all
200 GURL image_url; 201 GURL image_url;
201 gfx::Image image; 202 gfx::Image image;
202 float score; 203 float score;
203 favicon_base::IconType icon_type; 204 favicon_base::IconType icon_type;
204 }; 205 };
205 206
206 // Returns the bit mask of favicon_base::IconType based on the handler's type. 207 // Returns the bit mask of favicon_base::IconType based on the handler's type.
207 static int GetIconTypesFromHandlerType( 208 static int GetIconTypesFromHandlerType(
208 FaviconDriverObserver::NotificationIconType handler_type); 209 FaviconDriverObserver::NotificationIconType handler_type);
209 210
210 // Get the maximal icon size in pixels for a icon of type |icon_type| for the
211 // current platform.
212 static int GetMaximalIconSize(favicon_base::IconType icon_type);
213
214 // Called when the history request for favicon data mapped to |url_| has 211 // Called when the history request for favicon data mapped to |url_| has
215 // completed and the renderer has told us the icon URLs used by |url_| 212 // completed and the renderer has told us the icon URLs used by |url_|
216 void OnGotInitialHistoryDataAndIconURLCandidates(); 213 void OnGotInitialHistoryDataAndIconURLCandidates();
217 214
218 // See description above class for details. 215 // See description above class for details.
219 void OnFaviconDataForInitialURLFromFaviconService(const std::vector< 216 void OnFaviconDataForInitialURLFromFaviconService(const std::vector<
220 favicon_base::FaviconRawBitmapResult>& favicon_bitmap_results); 217 favicon_base::FaviconRawBitmapResult>& favicon_bitmap_results);
221 218
222 // If the favicon currently mapped to |url_| has expired, downloads the 219 // If the favicon currently mapped to |url_| has expired, downloads the
223 // current candidate favicon from the renderer. Otherwise requests data for 220 // current candidate favicon from the renderer. Otherwise requests data for
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 FaviconCandidate best_favicon_candidate_; 334 FaviconCandidate best_favicon_candidate_;
338 335
339 base::WeakPtrFactory<FaviconHandler> weak_ptr_factory_; 336 base::WeakPtrFactory<FaviconHandler> weak_ptr_factory_;
340 337
341 DISALLOW_COPY_AND_ASSIGN(FaviconHandler); 338 DISALLOW_COPY_AND_ASSIGN(FaviconHandler);
342 }; 339 };
343 340
344 } // namespace favicon 341 } // namespace favicon
345 342
346 #endif // COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_ 343 #endif // COMPONENTS_FAVICON_CORE_FAVICON_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | components/favicon/core/favicon_handler.cc » ('j') | components/favicon/core/favicon_handler_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698