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 COMPONENTS_FAVICON_CORE_FAVICON_SERVICE_H_ | 5 #ifndef COMPONENTS_FAVICON_CORE_FAVICON_SERVICE_H_ |
6 #define COMPONENTS_FAVICON_CORE_FAVICON_SERVICE_H_ | 6 #define COMPONENTS_FAVICON_CORE_FAVICON_SERVICE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "base/task/cancelable_task_tracker.h" | 17 #include "base/task/cancelable_task_tracker.h" |
17 #include "components/favicon_base/favicon_callback.h" | 18 #include "components/favicon_base/favicon_callback.h" |
18 #include "components/favicon_base/favicon_types.h" | 19 #include "components/favicon_base/favicon_types.h" |
19 #include "components/favicon_base/favicon_usage_data.h" | 20 #include "components/favicon_base/favicon_usage_data.h" |
20 #include "components/keyed_service/core/keyed_service.h" | 21 #include "components/keyed_service/core/keyed_service.h" |
21 | 22 |
22 class GURL; | 23 class GURL; |
23 | 24 |
24 namespace history { | 25 namespace history { |
25 class HistoryService; | 26 class HistoryService; |
26 } | 27 } |
27 | 28 |
28 namespace favicon { | 29 namespace favicon { |
29 | 30 |
30 class FaviconClient; | 31 class FaviconClient; |
31 | 32 |
32 // The favicon service provides methods to access favicons. It calls the history | 33 // The favicon service provides methods to access favicons. It calls the history |
33 // backend behind the scenes. The callbacks are run asynchronously, even in the | 34 // backend behind the scenes. The callbacks are run asynchronously, even in the |
34 // case of an error. | 35 // case of an error. |
35 class FaviconService : public KeyedService { | 36 class FaviconService : public KeyedService { |
36 public: | 37 public: |
37 // The FaviconClient must outlive the constructed FaviconService. | 38 // The FaviconClient must outlive the constructed FaviconService. |
38 FaviconService(scoped_ptr<FaviconClient> favicon_client, | 39 FaviconService(std::unique_ptr<FaviconClient> favicon_client, |
39 history::HistoryService* history_service); | 40 history::HistoryService* history_service); |
40 | 41 |
41 ~FaviconService() override; | 42 ~FaviconService() override; |
42 | 43 |
43 // We usually pass parameters with pointer to avoid copy. This function is a | 44 // We usually pass parameters with pointer to avoid copy. This function is a |
44 // helper to run FaviconResultsCallback with pointer parameters. | 45 // helper to run FaviconResultsCallback with pointer parameters. |
45 static void FaviconResultsCallbackRunner( | 46 static void FaviconResultsCallbackRunner( |
46 const favicon_base::FaviconResultsCallback& callback, | 47 const favicon_base::FaviconResultsCallback& callback, |
47 const std::vector<favicon_base::FaviconRawBitmapResult>* results); | 48 const std::vector<favicon_base::FaviconRawBitmapResult>* results); |
48 | 49 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // so that history service can deal solely with FaviconResultsCallback. | 238 // so that history service can deal solely with FaviconResultsCallback. |
238 // Resizes favicon_base::FaviconRawBitmapResult if necessary and runs | 239 // Resizes favicon_base::FaviconRawBitmapResult if necessary and runs |
239 // |callback|. | 240 // |callback|. |
240 void RunFaviconRawBitmapCallbackWithBitmapResults( | 241 void RunFaviconRawBitmapCallbackWithBitmapResults( |
241 const favicon_base::FaviconRawBitmapCallback& callback, | 242 const favicon_base::FaviconRawBitmapCallback& callback, |
242 int desired_size_in_pixel, | 243 int desired_size_in_pixel, |
243 const std::vector<favicon_base::FaviconRawBitmapResult>& | 244 const std::vector<favicon_base::FaviconRawBitmapResult>& |
244 favicon_bitmap_results); | 245 favicon_bitmap_results); |
245 | 246 |
246 base::hash_set<MissingFaviconURLHash> missing_favicon_urls_; | 247 base::hash_set<MissingFaviconURLHash> missing_favicon_urls_; |
247 scoped_ptr<FaviconClient> favicon_client_; | 248 std::unique_ptr<FaviconClient> favicon_client_; |
248 history::HistoryService* history_service_; | 249 history::HistoryService* history_service_; |
249 | 250 |
250 DISALLOW_COPY_AND_ASSIGN(FaviconService); | 251 DISALLOW_COPY_AND_ASSIGN(FaviconService); |
251 }; | 252 }; |
252 | 253 |
253 } // namespace favicon | 254 } // namespace favicon |
254 | 255 |
255 #endif // COMPONENTS_FAVICON_CORE_FAVICON_SERVICE_H_ | 256 #endif // COMPONENTS_FAVICON_CORE_FAVICON_SERVICE_H_ |
OLD | NEW |