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

Side by Side Diff: components/ntp_tiles/icon_cacher_impl.h

Issue 2873403002: [NTP Tiles] Avoid duplicate requests from IconCacherImpl (Closed)
Patch Set: Fix build for windows Created 3 years, 7 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
« no previous file with comments | « no previous file | components/ntp_tiles/icon_cacher_impl.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_NTP_TILES_ICON_CACHER_IMPL_H_ 5 #ifndef COMPONENTS_NTP_TILES_ICON_CACHER_IMPL_H_
6 #define COMPONENTS_NTP_TILES_ICON_CACHER_IMPL_H_ 6 #define COMPONENTS_NTP_TILES_ICON_CACHER_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set>
9 #include <string> 10 #include <string>
11 #include <vector>
10 12
11 #include "base/callback.h" 13 #include "base/callback.h"
12 #include "base/cancelable_callback.h" 14 #include "base/cancelable_callback.h"
13 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
14 #include "base/task/cancelable_task_tracker.h" 16 #include "base/task/cancelable_task_tracker.h"
15 #include "components/ntp_tiles/icon_cacher.h" 17 #include "components/ntp_tiles/icon_cacher.h"
16 #include "components/ntp_tiles/popular_sites.h" 18 #include "components/ntp_tiles/popular_sites.h"
17 19
18 namespace favicon { 20 namespace favicon {
19 class FaviconService; 21 class FaviconService;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 const base::Closure& preliminary_icon_available) override; 53 const base::Closure& preliminary_icon_available) override;
52 void StartFetchMostLikely(const GURL& page_url, 54 void StartFetchMostLikely(const GURL& page_url,
53 const base::Closure& icon_available) override; 55 const base::Closure& icon_available) override;
54 56
55 private: 57 private:
56 using CancelableImageCallback = 58 using CancelableImageCallback =
57 base::CancelableCallback<void(const gfx::Image&)>; 59 base::CancelableCallback<void(const gfx::Image&)>;
58 60
59 void OnGetFaviconImageForPageURLFinished( 61 void OnGetFaviconImageForPageURLFinished(
60 PopularSites::Site site, 62 PopularSites::Site site,
61 const base::Closure& icon_available,
62 const base::Closure& preliminary_icon_available, 63 const base::Closure& preliminary_icon_available,
63 const favicon_base::FaviconImageResult& result); 64 const favicon_base::FaviconImageResult& result);
64 65
65 void OnPopularSitesFaviconDownloaded( 66 void OnPopularSitesFaviconDownloaded(
66 PopularSites::Site site, 67 PopularSites::Site site,
67 std::unique_ptr<CancelableImageCallback> preliminary_callback, 68 std::unique_ptr<CancelableImageCallback> preliminary_callback,
68 const base::Closure& icon_available,
69 const std::string& id, 69 const std::string& id,
70 const gfx::Image& fetched_image, 70 const gfx::Image& fetched_image,
71 const image_fetcher::RequestMetadata& metadata); 71 const image_fetcher::RequestMetadata& metadata);
72 72
73 std::unique_ptr<CancelableImageCallback> MaybeProvideDefaultIcon( 73 std::unique_ptr<CancelableImageCallback> MaybeProvideDefaultIcon(
74 const PopularSites::Site& site, 74 const PopularSites::Site& site,
75 const base::Closure& icon_available); 75 const base::Closure& preliminary_icon_available);
76 void SaveAndNotifyIconForSite(const PopularSites::Site& site, 76 void SaveAndNotifyDefaultIconForSite(
77 const base::Closure& icon_available, 77 const PopularSites::Site& site,
78 const gfx::Image& image); 78 const base::Closure& preliminary_icon_available,
79 const gfx::Image& image);
80 void SaveIconForSite(const PopularSites::Site& site, const gfx::Image& image);
79 81
80 void OnGetLargeIconOrFallbackStyleFinished( 82 void OnGetLargeIconOrFallbackStyleFinished(
81 const GURL& page_url, 83 const GURL& page_url,
82 const base::Closure& icon_available,
83 const favicon_base::LargeIconResult& result); 84 const favicon_base::LargeIconResult& result);
84 85
85 void OnMostLikelyFaviconDownloaded(const base::Closure& icon_available, 86 bool StartRequest(const GURL& request_url,
86 bool success); 87 const base::Closure& icon_available);
88 void FinishRequestAndNotifyIconAvailable(const GURL& request_url,
89 bool newly_available);
87 90
88 base::CancelableTaskTracker tracker_; 91 base::CancelableTaskTracker tracker_;
89 favicon::FaviconService* const favicon_service_; 92 favicon::FaviconService* const favicon_service_;
90 favicon::LargeIconService* const large_icon_service_; 93 favicon::LargeIconService* const large_icon_service_;
91 std::unique_ptr<image_fetcher::ImageFetcher> const image_fetcher_; 94 std::unique_ptr<image_fetcher::ImageFetcher> const image_fetcher_;
95 std::map<GURL, std::vector<base::Closure>> in_flight_requests_;
92 96
93 base::WeakPtrFactory<IconCacherImpl> weak_ptr_factory_; 97 base::WeakPtrFactory<IconCacherImpl> weak_ptr_factory_;
94 98
95 DISALLOW_COPY_AND_ASSIGN(IconCacherImpl); 99 DISALLOW_COPY_AND_ASSIGN(IconCacherImpl);
96 }; 100 };
97 101
98 } // namespace ntp_tiles 102 } // namespace ntp_tiles
99 103
100 #endif // COMPONENTS_NTP_TILES_ICON_CACHER_IMPL_H_ 104 #endif // COMPONENTS_NTP_TILES_ICON_CACHER_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | components/ntp_tiles/icon_cacher_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698