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

Side by Side Diff: components/ntp_snippets/ntp_snippets_service.cc

Issue 1974013002: Replace SkBitmap with gfx::Image in the ImageFetcher API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix iOS build errors. Created 4 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
OLDNEW
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 #include "components/ntp_snippets/ntp_snippets_service.h" 5 #include "components/ntp_snippets/ntp_snippets_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/location.h" 14 #include "base/location.h"
15 #include "base/metrics/histogram_macros.h" 15 #include "base/metrics/histogram_macros.h"
16 #include "base/metrics/sparse_histogram.h" 16 #include "base/metrics/sparse_histogram.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/task_runner_util.h" 19 #include "base/task_runner_util.h"
20 #include "base/time/time.h" 20 #include "base/time/time.h"
21 #include "base/values.h" 21 #include "base/values.h"
22 #include "components/image_fetcher/image_fetcher.h" 22 #include "components/image_fetcher/image_fetcher.h"
23 #include "components/ntp_snippets/pref_names.h" 23 #include "components/ntp_snippets/pref_names.h"
24 #include "components/ntp_snippets/switches.h" 24 #include "components/ntp_snippets/switches.h"
25 #include "components/prefs/pref_registry_simple.h" 25 #include "components/prefs/pref_registry_simple.h"
26 #include "components/prefs/pref_service.h" 26 #include "components/prefs/pref_service.h"
27 #include "components/suggestions/proto/suggestions.pb.h" 27 #include "components/suggestions/proto/suggestions.pb.h"
28 #include "ui/gfx/image/image.h"
28 29
29 using image_fetcher::ImageFetcher; 30 using image_fetcher::ImageFetcher;
30 using suggestions::ChromeSuggestion; 31 using suggestions::ChromeSuggestion;
31 using suggestions::SuggestionsProfile; 32 using suggestions::SuggestionsProfile;
32 using suggestions::SuggestionsService; 33 using suggestions::SuggestionsService;
33 34
34 namespace ntp_snippets { 35 namespace ntp_snippets {
35 36
36 namespace { 37 namespace {
37 38
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 const std::string& id = needle->id(); 141 const std::string& id = needle->id();
141 return std::find_if(haystack.begin(), haystack.end(), 142 return std::find_if(haystack.begin(), haystack.end(),
142 [&id](const std::unique_ptr<NTPSnippet>& snippet) { 143 [&id](const std::unique_ptr<NTPSnippet>& snippet) {
143 return snippet->id() == id; 144 return snippet->id() == id;
144 }) != haystack.end(); 145 }) != haystack.end();
145 } 146 }
146 147
147 void WrapImageFetchedCallback( 148 void WrapImageFetchedCallback(
148 const NTPSnippetsService::ImageFetchedCallback& callback, 149 const NTPSnippetsService::ImageFetchedCallback& callback,
149 const GURL& snippet_id_url, 150 const GURL& snippet_id_url,
150 const SkBitmap* bitmap) { 151 const gfx::Image& image) {
152 const SkBitmap* bitmap = NULL;
Marc Treib 2016/05/13 15:54:00 nit: nullptr
markusheintz_ 2016/05/17 13:08:22 Done.
153 if (!image.IsEmpty())
154 bitmap = image.ToSkBitmap();
151 callback.Run(snippet_id_url.spec(), bitmap); 155 callback.Run(snippet_id_url.spec(), bitmap);
152 } 156 }
153 157
154 } // namespace 158 } // namespace
155 159
156 NTPSnippetsService::NTPSnippetsService( 160 NTPSnippetsService::NTPSnippetsService(
157 PrefService* pref_service, 161 PrefService* pref_service,
158 SuggestionsService* suggestions_service, 162 SuggestionsService* suggestions_service,
159 scoped_refptr<base::SequencedTaskRunner> file_task_runner, 163 scoped_refptr<base::SequencedTaskRunner> file_task_runner,
160 const std::string& application_language_code, 164 const std::string& application_language_code,
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 if (snippet->expiry_date() < next_expiry) 497 if (snippet->expiry_date() < next_expiry)
494 next_expiry = snippet->expiry_date(); 498 next_expiry = snippet->expiry_date();
495 } 499 }
496 DCHECK_GT(next_expiry, expiry); 500 DCHECK_GT(next_expiry, expiry);
497 expiry_timer_.Start(FROM_HERE, next_expiry - expiry, 501 expiry_timer_.Start(FROM_HERE, next_expiry - expiry,
498 base::Bind(&NTPSnippetsService::LoadingSnippetsFinished, 502 base::Bind(&NTPSnippetsService::LoadingSnippetsFinished,
499 base::Unretained(this))); 503 base::Unretained(this)));
500 } 504 }
501 505
502 } // namespace ntp_snippets 506 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698