| OLD | NEW |
| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 // There is no record in the store, and no previous attempts to retrieve | 158 // There is no record in the store, and no previous attempts to retrieve |
| 159 // one. Start a request to retrieve a salient image if there is an image | 159 // one. Start a request to retrieve a salient image if there is an image |
| 160 // url set on a bookmark, and then enqueue the request for the record to | 160 // url set on a bookmark, and then enqueue the request for the record to |
| 161 // be triggered when the retrieval is finished. | 161 // be triggered when the retrieval is finished. |
| 162 RetrieveSalientImageForPageUrl(page_url); | 162 RetrieveSalientImageForPageUrl(page_url); |
| 163 SalientImageForUrl(page_url, false, original_callback); | 163 SalientImageForUrl(page_url, false, original_callback); |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| 167 void BookmarkImageService::SalientImageForUrl(const GURL& page_url, | 167 void BookmarkImageService::SalientImageForUrl(const GURL& page_url, |
| 168 bool fetch_from_bookmark, | 168 bool fetch_from_web, |
| 169 ImageCallback callback) { | 169 ImageCallback callback) { |
| 170 DCHECK(CalledOnValidThread()); | 170 DCHECK(CalledOnValidThread()); |
| 171 | 171 |
| 172 // If the request is done while the image is currently being retrieved, just | 172 // If the request is done while the image is currently being retrieved, just |
| 173 // store the appropriate callbacks to call once the image is retrieved. | 173 // store the appropriate callbacks to call once the image is retrieved. |
| 174 if (IsPageUrlInProgress(page_url)) { | 174 if (IsPageUrlInProgress(page_url)) { |
| 175 callbacks_[page_url].push_back(callback); | 175 callbacks_[page_url].push_back(callback); |
| 176 return; | 176 return; |
| 177 } | 177 } |
| 178 | 178 |
| 179 if (!fetch_from_bookmark) { | 179 if (!fetch_from_web) { |
| 180 RetrieveImageFromStore(page_url, callback); | 180 RetrieveImageFromStore(page_url, callback); |
| 181 } else { | 181 } else { |
| 182 RetrieveImageFromStore(page_url, | 182 RetrieveImageFromStore(page_url, |
| 183 base::Bind(&BookmarkImageService::FetchCallback, | 183 base::Bind(&BookmarkImageService::FetchCallback, |
| 184 base::Unretained(this), | 184 base::Unretained(this), |
| 185 page_url, | 185 page_url, |
| 186 callback)); | 186 callback)); |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 | 189 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 const BookmarkNode* node) { | 358 const BookmarkNode* node) { |
| 359 } | 359 } |
| 360 | 360 |
| 361 void BookmarkImageService::BookmarkAllUserNodesRemoved( | 361 void BookmarkImageService::BookmarkAllUserNodesRemoved( |
| 362 BookmarkModel* model, | 362 BookmarkModel* model, |
| 363 const std::set<GURL>& removed_urls) { | 363 const std::set<GURL>& removed_urls) { |
| 364 ClearAll(); | 364 ClearAll(); |
| 365 } | 365 } |
| 366 | 366 |
| 367 } // namespace enhanced_bookmarks | 367 } // namespace enhanced_bookmarks |
| OLD | NEW |