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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 |
191 void BookmarkImageService::ProcessNewImage(const GURL& page_url, | 191 void BookmarkImageService::ProcessNewImage(const GURL& page_url, |
192 bool update_bookmarks, | 192 bool update_bookmarks, |
193 const gfx::Image& image, | 193 const GURL& image_url, |
194 const GURL& image_url) { | 194 const gfx::Image& image) { |
195 DCHECK(CalledOnValidThread()); | |
196 base::Callback<gfx::Image(void)> task = base::Bind( | |
197 &BookmarkImageService::ResizeImage, base::Unretained(this), image); | |
Kibeom Kim (inactive)
2015/02/12 23:24:15
How about just resizing inside BookmarkImageServic
Ian Wen
2015/02/13 00:52:41
Done.
| |
198 base::Callback<void(const gfx::Image&)> reply = | |
199 base::Bind(&BookmarkImageService::ProcessNewImageInternal, | |
200 base::Unretained(this), page_url, update_bookmarks, image_url); | |
201 base::PostTaskAndReplyWithResult(pool_.get(), FROM_HERE, task, reply); | |
202 } | |
203 | |
204 void BookmarkImageService::ProcessNewImageInternal(const GURL& page_url, | |
205 bool update_bookmarks, | |
206 const GURL& image_url, | |
207 const gfx::Image& image) { | |
195 DCHECK(CalledOnValidThread()); | 208 DCHECK(CalledOnValidThread()); |
196 PostTaskToStoreImage(image, image_url, page_url); | 209 PostTaskToStoreImage(image, image_url, page_url); |
197 if (update_bookmarks && image_url.is_valid()) { | 210 if (update_bookmarks && image_url.is_valid()) { |
198 const BookmarkNode* bookmark = | 211 const BookmarkNode* bookmark = |
199 enhanced_bookmark_model_->bookmark_model() | 212 enhanced_bookmark_model_->bookmark_model() |
200 ->GetMostRecentlyAddedUserNodeForURL(page_url); | 213 ->GetMostRecentlyAddedUserNodeForURL(page_url); |
201 if (bookmark) { | 214 if (bookmark) { |
202 const gfx::Size& size = image.Size(); | 215 const gfx::Size& size = image.Size(); |
203 bool result = enhanced_bookmark_model_->SetOriginalImage( | 216 bool result = enhanced_bookmark_model_->SetOriginalImage( |
204 bookmark, image_url, size.width(), size.height()); | 217 bookmark, image_url, size.width(), size.height()); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 const BookmarkNode* node) { | 372 const BookmarkNode* node) { |
360 } | 373 } |
361 | 374 |
362 void BookmarkImageService::BookmarkAllUserNodesRemoved( | 375 void BookmarkImageService::BookmarkAllUserNodesRemoved( |
363 BookmarkModel* model, | 376 BookmarkModel* model, |
364 const std::set<GURL>& removed_urls) { | 377 const std::set<GURL>& removed_urls) { |
365 ClearAll(); | 378 ClearAll(); |
366 } | 379 } |
367 | 380 |
368 } // namespace enhanced_bookmarks | 381 } // namespace enhanced_bookmarks |
OLD | NEW |