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

Side by Side Diff: components/enhanced_bookmarks/bookmark_image_service.cc

Issue 899653003: [Enhanced Bookmark]Upstream image fetching code in android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 5 years, 10 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 | « components/enhanced_bookmarks/bookmark_image_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/enhanced_bookmarks/bookmark_image_service.h" 5 #include "components/enhanced_bookmarks/bookmark_image_service.h"
6 6
7 #include "base/single_thread_task_runner.h" 7 #include "base/single_thread_task_runner.h"
8 #include "base/task_runner_util.h" 8 #include "base/task_runner_util.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "base/threading/sequenced_worker_pool.h" 10 #include "base/threading/sequenced_worker_pool.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // There is no record in the store, and no previous attempts to retrieve 159 // There is no record in the store, and no previous attempts to retrieve
160 // one. Start a request to retrieve a salient image if there is an image 160 // one. Start a request to retrieve a salient image if there is an image
161 // url set on a bookmark, and then enqueue the request for the record to 161 // url set on a bookmark, and then enqueue the request for the record to
162 // be triggered when the retrieval is finished. 162 // be triggered when the retrieval is finished.
163 RetrieveSalientImageForPageUrl(page_url); 163 RetrieveSalientImageForPageUrl(page_url);
164 SalientImageForUrl(page_url, false, original_callback); 164 SalientImageForUrl(page_url, false, original_callback);
165 } 165 }
166 } 166 }
167 167
168 void BookmarkImageService::SalientImageForUrl(const GURL& page_url, 168 void BookmarkImageService::SalientImageForUrl(const GURL& page_url,
169 bool fetch_from_bookmark, 169 bool fetch_from_web,
170 ImageCallback callback) { 170 ImageCallback callback) {
171 DCHECK(CalledOnValidThread()); 171 DCHECK(CalledOnValidThread());
172 172
173 // If the request is done while the image is currently being retrieved, just 173 // If the request is done while the image is currently being retrieved, just
174 // store the appropriate callbacks to call once the image is retrieved. 174 // store the appropriate callbacks to call once the image is retrieved.
175 if (IsPageUrlInProgress(page_url)) { 175 if (IsPageUrlInProgress(page_url)) {
176 callbacks_[page_url].push_back(callback); 176 callbacks_[page_url].push_back(callback);
177 return; 177 return;
178 } 178 }
179 179
180 if (!fetch_from_bookmark) { 180 if (!fetch_from_web) {
181 RetrieveImageFromStore(page_url, callback); 181 RetrieveImageFromStore(page_url, callback);
182 } else { 182 } else {
183 RetrieveImageFromStore(page_url, 183 RetrieveImageFromStore(page_url,
184 base::Bind(&BookmarkImageService::FetchCallback, 184 base::Bind(&BookmarkImageService::FetchCallback,
185 base::Unretained(this), 185 base::Unretained(this),
186 page_url, 186 page_url,
187 callback)); 187 callback));
188 } 188 }
189 } 189 }
190 190
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 const BookmarkNode* node) { 359 const BookmarkNode* node) {
360 } 360 }
361 361
362 void BookmarkImageService::BookmarkAllUserNodesRemoved( 362 void BookmarkImageService::BookmarkAllUserNodesRemoved(
363 BookmarkModel* model, 363 BookmarkModel* model,
364 const std::set<GURL>& removed_urls) { 364 const std::set<GURL>& removed_urls) {
365 ClearAll(); 365 ClearAll();
366 } 366 }
367 367
368 } // namespace enhanced_bookmarks 368 } // namespace enhanced_bookmarks
OLDNEW
« no previous file with comments | « components/enhanced_bookmarks/bookmark_image_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698