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

Side by Side Diff: chrome/browser/favicon/favicon_service.h

Issue 10870022: Change FaviconData to be able to return data for multiple bitmaps for same icon URL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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_FAVICON_FAVICON_SERVICE_H_ 5 #ifndef CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_
6 #define CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ 6 #define CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "chrome/browser/cancelable_request.h" 12 #include "chrome/browser/cancelable_request.h"
13 #include "chrome/browser/history/history_types.h" 13 #include "chrome/browser/history/history_types.h"
14 #include "chrome/common/ref_counted_util.h" 14 #include "chrome/common/ref_counted_util.h"
15 15
16 class GURL; 16 class GURL;
17 class Profile; 17 class Profile;
18 18
19 // The favicon service provides methods to access favicons. It calls the history 19 // The favicon service provides methods to access favicons. It calls the history
20 // backend behind the scenes. 20 // backend behind the scenes.
21 // 21 //
22 // This service is thread safe. Each request callback is invoked in the 22 // This service is thread safe. Each request callback is invoked in the
23 // thread that made the request. 23 // thread that made the request.
24 class FaviconService : public CancelableRequestProvider { 24 class FaviconService : public CancelableRequestProvider {
25 public: 25 public:
26 explicit FaviconService(Profile* profile); 26 explicit FaviconService(Profile* profile);
27 27
28 virtual ~FaviconService(); 28 virtual ~FaviconService();
29 29
30 // Callback for GetFavicon. If we have previously inquired about the favicon 30 // Callback for GetFavicon.
31 // for this URL, |know_favicon| will be true, and the rest of the fields will 31 // If we have previously inquired about the favicon for this URL,
32 // be valid (otherwise they will be ignored). 32 // |know_favicon| will be true, and the rest of the fields will be valid
33 // 33 // (otherwise they will be ignored).
34 // On |know_favicon| == true, |data| will either contain the PNG encoded 34 // On |know_favicon| == true, |icon_url| will be set to the URL whose favicon
35 // favicon data, or it will be NULL to indicate that the site does not have 35 // sizes best match the optimal favicon sizes of 16x16 and 32x32.
36 // a favicon (in other words, we know the site doesn't have a favicon, as 36 // See history_types.h for a detailed description of the FaviconData struct.
37 // opposed to not knowing anything). |expired| will be set to true if we 37 // Third argument:
38 // refreshed the favicon "too long" ago and should be updated if the page 38 // a) If the callback is called as a result of GetFaviconForURL()
39 // is visited again. 39 // The third argument is a list of the icon URLs of the requested icon type
40 // mapped to the passed in |page_url|.
41 // b) If the callback is called as a result of GetFavicon() or
42 // UpdateFaviconMappingAndFetch()
43 // The third argument has a single entry with the passed in |icon_url| if
44 // it is known to the history backend. Otherwise, an empty vector is
45 // returned.
40 typedef base::Callback< 46 typedef base::Callback<
sky 2012/08/23 15:50:38 As discussed over IM, this is temporary. Long term
41 void(Handle, // handle 47 void(Handle, // handle
42 history::FaviconData)> // the type of favicon 48 history::FaviconData,
49 std::vector<GURL>)>
43 FaviconDataCallback; 50 FaviconDataCallback;
44 51
45 typedef CancelableRequest<FaviconDataCallback> GetFaviconRequest; 52 typedef CancelableRequest<FaviconDataCallback> GetFaviconRequest;
46 53
47 // Requests the |icon_type| of favicon. |consumer| is notified when the bits 54 // Requests the |icon_type| of favicon. |consumer| is notified when the bits
48 // have been fetched. |icon_url| is the URL of the icon itself, e.g. 55 // have been fetched. |icon_url| is the URL of the icon itself, e.g.
49 // <http://www.google.com/favicon.ico>. 56 // <http://www.google.com/favicon.ico>.
50 Handle GetFavicon(const GURL& icon_url, 57 Handle GetFavicon(const GURL& icon_url,
51 history::IconType icon_type, 58 history::IconType icon_type,
52 CancelableRequestConsumerBase* consumer, 59 CancelableRequestConsumerBase* consumer,
(...skipping 16 matching lines...) Expand all
69 // priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON and FAVICON. 76 // priority of TOUCH_PRECOMPOSED_ICON, TOUCH_ICON and FAVICON.
70 // 77 //
71 // Note: this version is intended to be used to retrieve the favicon of a 78 // Note: this version is intended to be used to retrieve the favicon of a
72 // page that has been browsed in the past. |expired| in the callback is 79 // page that has been browsed in the past. |expired| in the callback is
73 // always false. 80 // always false.
74 Handle GetFaviconForURL(const GURL& page_url, 81 Handle GetFaviconForURL(const GURL& page_url,
75 int icon_types, 82 int icon_types,
76 CancelableRequestConsumerBase* consumer, 83 CancelableRequestConsumerBase* consumer,
77 const FaviconDataCallback& callback); 84 const FaviconDataCallback& callback);
78 85
79 // Requests the favicon for |favicon_id|. The |consumer| is notified when the
80 // bits have been fetched.
81 Handle GetFaviconForID(history::FaviconID favicon_id,
82 CancelableRequestConsumerBase* consumer,
83 const FaviconDataCallback& callback);
84
85 // Marks all types of favicon for the page as being out of date. 86 // Marks all types of favicon for the page as being out of date.
86 void SetFaviconOutOfDateForPage(const GURL& page_url); 87 void SetFaviconOutOfDateForPage(const GURL& page_url);
87 88
88 // Clones all icons from an existing page. This associates the icons from 89 // Clones all icons from an existing page. This associates the icons from
89 // |old_page_url| with |new_page_url|, provided |new_page_url| has no 90 // |old_page_url| with |new_page_url|, provided |new_page_url| has no
90 // recorded associations to any other icons. 91 // recorded associations to any other icons.
91 // Needed if you want to declare favicons (tentatively) in advance, before a 92 // Needed if you want to declare favicons (tentatively) in advance, before a
92 // page is ever visited. 93 // page is ever visited.
93 void CloneFavicon(const GURL& old_page_url, const GURL& new_page_url); 94 void CloneFavicon(const GURL& old_page_url, const GURL& new_page_url);
94 95
(...skipping 12 matching lines...) Expand all
107 private: 108 private:
108 Profile* profile_; 109 Profile* profile_;
109 110
110 // Helper to forward an empty result if we cannot get the history service. 111 // Helper to forward an empty result if we cannot get the history service.
111 void ForwardEmptyResultAsync(GetFaviconRequest* request); 112 void ForwardEmptyResultAsync(GetFaviconRequest* request);
112 113
113 DISALLOW_COPY_AND_ASSIGN(FaviconService); 114 DISALLOW_COPY_AND_ASSIGN(FaviconService);
114 }; 115 };
115 116
116 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ 117 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698