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

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

Issue 10857037: Make FaviconService a ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Override Shutdown() in FaviconService to NULL the profile_ pointer. 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
« no previous file with comments | « no previous file | chrome/browser/favicon/favicon_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browser/profiles/profile_keyed_service.h"
14 #include "chrome/common/ref_counted_util.h" 15 #include "chrome/common/ref_counted_util.h"
15 16
16 class GURL; 17 class GURL;
18 class HistoryService;
17 class Profile; 19 class Profile;
18 20
19 // The favicon service provides methods to access favicons. It calls the history 21 // The favicon service provides methods to access favicons. It calls the history
20 // backend behind the scenes. 22 // backend behind the scenes.
21 // 23 //
22 // This service is thread safe. Each request callback is invoked in the 24 // This service is thread safe. Each request callback is invoked in the
23 // thread that made the request. 25 // thread that made the request.
24 class FaviconService : public CancelableRequestProvider { 26 class FaviconService : public CancelableRequestProvider,
27 public ProfileKeyedService {
25 public: 28 public:
26 explicit FaviconService(Profile* profile); 29 // FIXME: We should not take a Profile pointer here.
30 // We do this now because we need to pass a Profile pointer to
31 // ChromeWebUIControllerFactory::GetFaviconForURL() until that
32 // component gets untangled too.
33 FaviconService(scoped_refptr<HistoryService>, Profile*);
27 34
28 virtual ~FaviconService(); 35 virtual ~FaviconService();
29 36
30 // Callback for GetFavicon. If we have previously inquired about the favicon 37 // Callback for GetFavicon. If we have previously inquired about the favicon
31 // for this URL, |know_favicon| will be true, and the rest of the fields will 38 // for this URL, |know_favicon| will be true, and the rest of the fields will
32 // be valid (otherwise they will be ignored). 39 // be valid (otherwise they will be ignored).
33 // 40 //
34 // On |know_favicon| == true, |data| will either contain the PNG encoded 41 // On |know_favicon| == true, |data| will either contain the PNG encoded
35 // favicon data, or it will be NULL to indicate that the site does not have 42 // favicon data, or it will be NULL to indicate that the site does not have
36 // a favicon (in other words, we know the site doesn't have a favicon, as 43 // a favicon (in other words, we know the site doesn't have a favicon, as
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // favicons will not be overwritten. 104 // favicons will not be overwritten.
98 void SetImportedFavicons( 105 void SetImportedFavicons(
99 const std::vector<history::ImportedFaviconUsage>& favicon_usage); 106 const std::vector<history::ImportedFaviconUsage>& favicon_usage);
100 107
101 // Sets the favicon for a page. 108 // Sets the favicon for a page.
102 void SetFavicon(const GURL& page_url, 109 void SetFavicon(const GURL& page_url,
103 const GURL& icon_url, 110 const GURL& icon_url,
104 const std::vector<unsigned char>& image_data, 111 const std::vector<unsigned char>& image_data,
105 history::IconType icon_type); 112 history::IconType icon_type);
106 113
114 // ProfileKeyedService
115 virtual void Shutdown();
107 private: 116 private:
117 scoped_refptr<HistoryService> history_service_;
118 // FIXME: remove this member variable. See comment in the constructor.
108 Profile* profile_; 119 Profile* profile_;
109
110 // Helper to forward an empty result if we cannot get the history service. 120 // Helper to forward an empty result if we cannot get the history service.
111 void ForwardEmptyResultAsync(GetFaviconRequest* request); 121 void ForwardEmptyResultAsync(GetFaviconRequest* request);
112 122
113 DISALLOW_COPY_AND_ASSIGN(FaviconService); 123 DISALLOW_COPY_AND_ASSIGN(FaviconService);
114 }; 124 };
115 125
116 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ 126 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/favicon/favicon_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698