OLD | NEW |
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 IOS_CHROME_BROWSER_FAVICON_FAVICON_LOADER_H_ | 5 #ifndef IOS_CHROME_BROWSER_FAVICON_FAVICON_LOADER_H_ |
6 #define IOS_CHROME_BROWSER_FAVICON_FAVICON_LOADER_H_ | 6 #define IOS_CHROME_BROWSER_FAVICON_FAVICON_LOADER_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #import "base/mac/scoped_nsobject.h" | 11 #import "base/mac/scoped_nsobject.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/task/cancelable_task_tracker.h" | 13 #include "base/task/cancelable_task_tracker.h" |
14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
15 #include "components/favicon_base/favicon_types.h" | 15 #include "components/favicon_base/favicon_types.h" |
16 #include "components/keyed_service/core/keyed_service.h" | 16 #include "components/keyed_service/core/keyed_service.h" |
17 | 17 |
18 class GURL; | 18 class GURL; |
19 @class NSMutableDictionary; | 19 @class NSMutableDictionary; |
20 @class UIImage; | 20 @class UIImage; |
21 | 21 |
22 namespace favicon { | 22 namespace favicon { |
(...skipping 23 matching lines...) Expand all Loading... |
46 | 46 |
47 // Purges the cache, in response to low-memory. | 47 // Purges the cache, in response to low-memory. |
48 void PurgeCache(); | 48 void PurgeCache(); |
49 | 49 |
50 private: | 50 private: |
51 struct RequestData; | 51 struct RequestData; |
52 | 52 |
53 // Called when the favicon load request completes. Saves image into the | 53 // Called when the favicon load request completes. Saves image into the |
54 // cache. Desktop code assumes this image is in PNG format. | 54 // cache. Desktop code assumes this image is in PNG format. |
55 void OnFaviconAvailable( | 55 void OnFaviconAvailable( |
56 scoped_ptr<RequestData> request_data, | 56 std::unique_ptr<RequestData> request_data, |
57 const std::vector<favicon_base::FaviconRawBitmapResult>& | 57 const std::vector<favicon_base::FaviconRawBitmapResult>& |
58 favicon_bitmap_results); | 58 favicon_bitmap_results); |
59 | 59 |
60 base::ThreadChecker thread_checker_; | 60 base::ThreadChecker thread_checker_; |
61 | 61 |
62 // The FaviconService used to retrieve favicon; may be null during testing. | 62 // The FaviconService used to retrieve favicon; may be null during testing. |
63 // Must outlive the FaviconLoader. | 63 // Must outlive the FaviconLoader. |
64 favicon::FaviconService* favicon_service_; | 64 favicon::FaviconService* favicon_service_; |
65 | 65 |
66 // Tracks tasks sent to FaviconService. | 66 // Tracks tasks sent to FaviconService. |
67 base::CancelableTaskTracker cancelable_task_tracker_; | 67 base::CancelableTaskTracker cancelable_task_tracker_; |
68 | 68 |
69 // Holds cached favicons. This dictionary is populated as favicons are | 69 // Holds cached favicons. This dictionary is populated as favicons are |
70 // retrieved from the FaviconService. This will be emptied during low-memory | 70 // retrieved from the FaviconService. This will be emptied during low-memory |
71 // conditions. Keyed by NSString of URL spec. | 71 // conditions. Keyed by NSString of URL spec. |
72 base::scoped_nsobject<NSMutableDictionary> favicon_cache_; | 72 base::scoped_nsobject<NSMutableDictionary> favicon_cache_; |
73 | 73 |
74 DISALLOW_COPY_AND_ASSIGN(FaviconLoader); | 74 DISALLOW_COPY_AND_ASSIGN(FaviconLoader); |
75 }; | 75 }; |
76 | 76 |
77 #endif // IOS_CHROME_BROWSER_FAVICON_FAVICON_LOADER_H_ | 77 #endif // IOS_CHROME_BROWSER_FAVICON_FAVICON_LOADER_H_ |
OLD | NEW |